Add ability to set "keep screen on" for iOS
This commit is contained in:
parent
fb2bf78591
commit
182d2e5dc9
3 changed files with 15 additions and 2 deletions
|
@ -57,6 +57,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Error _shell_open(String);
|
Error _shell_open(String);
|
||||||
|
void _set_keep_screen_on(bool p_enabled);
|
||||||
|
|
||||||
Error _shell_open(String p_uri) {
|
Error _shell_open(String p_uri) {
|
||||||
NSString* url = [[NSString alloc] initWithUTF8String:p_uri.utf8().get_data()];
|
NSString* url = [[NSString alloc] initWithUTF8String:p_uri.utf8().get_data()];
|
||||||
|
@ -70,6 +71,10 @@ Error _shell_open(String p_uri) {
|
||||||
return OK;
|
return OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void _set_keep_screen_on(bool p_enabled) {
|
||||||
|
[[UIApplication sharedApplication] setIdleTimerDisabled:(BOOL)p_enabled];
|
||||||
|
};
|
||||||
|
|
||||||
@implementation AppDelegate
|
@implementation AppDelegate
|
||||||
|
|
||||||
@synthesize window;
|
@synthesize window;
|
||||||
|
@ -212,8 +217,8 @@ static int frame_count = 0;
|
||||||
|
|
||||||
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
|
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
|
||||||
// disable idle timer
|
// disable idle timer
|
||||||
application.idleTimerDisabled = YES;
|
//application.idleTimerDisabled = YES;
|
||||||
|
|
||||||
//Create a full-screen window
|
//Create a full-screen window
|
||||||
window = [[UIWindow alloc] initWithFrame:rect];
|
window = [[UIWindow alloc] initWithFrame:rect];
|
||||||
//window.autoresizesSubviews = YES;
|
//window.autoresizesSubviews = YES;
|
||||||
|
@ -238,6 +243,7 @@ static int frame_count = 0;
|
||||||
view_controller.view = glView;
|
view_controller.view = glView;
|
||||||
window.rootViewController = view_controller;
|
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;
|
glView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink",true)) ? YES : NO;
|
||||||
printf("cadisaplylink: %d", glView.useCADisplayLink);
|
printf("cadisaplylink: %d", glView.useCADisplayLink);
|
||||||
glView.animationInterval = 1.0 / kRenderingFrequency;
|
glView.animationInterval = 1.0 / kRenderingFrequency;
|
||||||
|
|
|
@ -454,6 +454,7 @@ bool OSIPhone::has_virtual_keyboard() const {
|
||||||
extern void _show_keyboard(String p_existing);
|
extern void _show_keyboard(String p_existing);
|
||||||
extern void _hide_keyboard();
|
extern void _hide_keyboard();
|
||||||
extern Error _shell_open(String p_uri);
|
extern Error _shell_open(String p_uri);
|
||||||
|
extern void _set_keep_screen_on(bool p_enabled);
|
||||||
|
|
||||||
void OSIPhone::show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect) {
|
void OSIPhone::show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect) {
|
||||||
_show_keyboard(p_existing_text);
|
_show_keyboard(p_existing_text);
|
||||||
|
@ -467,6 +468,10 @@ Error OSIPhone::shell_open(String p_uri) {
|
||||||
return _shell_open(p_uri);
|
return _shell_open(p_uri);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void OSIPhone::set_keep_screen_on(bool p_enabled) {
|
||||||
|
OS::set_keep_screen_on(p_enabled);
|
||||||
|
_set_keep_screen_on(p_enabled);
|
||||||
|
};
|
||||||
|
|
||||||
void OSIPhone::set_cursor_shape(CursorShape p_shape) {
|
void OSIPhone::set_cursor_shape(CursorShape p_shape) {
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,8 @@ public:
|
||||||
virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0);
|
virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0);
|
||||||
virtual VideoMode get_video_mode(int p_screen=0) const;
|
virtual VideoMode get_video_mode(int p_screen=0) const;
|
||||||
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
|
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
|
||||||
|
|
||||||
|
virtual void set_keep_screen_on(bool p_enabled);
|
||||||
|
|
||||||
virtual bool can_draw() const;
|
virtual bool can_draw() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue