From 182d2e5dc96c8ff695bc85ab44b22768eefc1f3b Mon Sep 17 00:00:00 2001 From: volzhs Date: Sun, 29 Nov 2015 13:18:21 +0900 Subject: Add ability to set "keep screen on" for iOS --- platform/iphone/app_delegate.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'platform/iphone/app_delegate.mm') diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 8a3dfe0623..e90a16a684 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -57,6 +57,7 @@ #endif Error _shell_open(String); +void _set_keep_screen_on(bool p_enabled); Error _shell_open(String p_uri) { NSString* url = [[NSString alloc] initWithUTF8String:p_uri.utf8().get_data()]; @@ -70,6 +71,10 @@ Error _shell_open(String p_uri) { return OK; }; +void _set_keep_screen_on(bool p_enabled) { + [[UIApplication sharedApplication] setIdleTimerDisabled:(BOOL)p_enabled]; +}; + @implementation AppDelegate @synthesize window; @@ -212,8 +217,8 @@ static int frame_count = 0; [application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; // disable idle timer - application.idleTimerDisabled = YES; - + //application.idleTimerDisabled = YES; + //Create a full-screen window window = [[UIWindow alloc] initWithFrame:rect]; //window.autoresizesSubviews = YES; @@ -238,6 +243,7 @@ static int frame_count = 0; view_controller.view = glView; window.rootViewController = view_controller; + _set_keep_screen_on(bool(GLOBAL_DEF("display/set_keep_screen_on",true)) ? YES : NO); glView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink",true)) ? YES : NO; printf("cadisaplylink: %d", glView.useCADisplayLink); glView.animationInterval = 1.0 / kRenderingFrequency; -- cgit v1.2.3