From 7c47695f3708d8ffa1bacd0475f5b938bd1c60f4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 13 Apr 2015 01:55:35 +0200 Subject: [PATCH] (UI CocoaTouch) Implement toggle --- apple/iOS/platform.h | 1 + apple/iOS/platform.m | 25 +++++++++++++++++++++---- runloop.h | 1 + ui/drivers/ui_cocoatouch.m | 12 +++++++++++- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/apple/iOS/platform.h b/apple/iOS/platform.h index fe20b67531..3e269ef282 100644 --- a/apple/iOS/platform.h +++ b/apple/iOS/platform.h @@ -43,6 +43,7 @@ const void* apple_get_frontend_settings(void); + (RetroArch_iOS*)get; - (void)showGameView; +- (void)toggleUI; - (void)loadingCore:(NSString*)core withFile:(const char*)file; - (void)unloadingCore; diff --git a/apple/iOS/platform.m b/apple/iOS/platform.m index fb3186c487..fdb96055e7 100644 --- a/apple/iOS/platform.m +++ b/apple/iOS/platform.m @@ -362,16 +362,19 @@ enum [[UIApplication sharedApplication] setIdleTimerDisabled:true]; [self.window setRootViewController:[RAGameView get]]; - runloop->is_paused = false; - runloop->is_idle = false; + runloop->is_paused = false; + runloop->is_idle = false; + runloop->ui_companion_is_on_foreground = false; } - (IBAction)showPauseMenu:(id)sender { runloop_t *runloop = rarch_main_get_ptr(); - runloop->is_paused = true; - runloop->is_idle = true; + runloop->is_paused = true; + runloop->is_idle = true; + runloop->ui_companion_is_on_foreground = true; + [[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setIdleTimerDisabled:false]; [self.window setRootViewController:self]; @@ -385,6 +388,20 @@ enum [self showGameView]; } +- (void)toggleUI +{ + runloop_t *runloop = rarch_main_get_ptr(); + + if (runloop->ui_companion_is_on_foreground) + { + [self showGameView]; + } + else + { + [self showPauseMenu:self]; + } +} + - (void)unloadingCore { [self showPauseMenu:self]; diff --git a/runloop.h b/runloop.h index f094430b91..497ac210aa 100644 --- a/runloop.h +++ b/runloop.h @@ -46,6 +46,7 @@ typedef struct runloop /* Lifecycle state checks. */ bool is_paused; bool is_idle; + bool ui_companion_is_on_foreground; bool is_menu; bool is_slowmotion; diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 0c117da116..46e5572958 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -53,6 +53,16 @@ static void ui_companion_cocoatouch_notify_content_loaded(void *data) [ap showGameView]; } +static void ui_companion_cocoatouch_toggle(void *data) +{ + RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform; + + (void)data; + + if (ap) + [ap toggleUI]; +} + static int ui_companion_cocoatouch_iterate(void *data, unsigned action) { (void)data; @@ -84,7 +94,7 @@ const ui_companion_driver_t ui_companion_cocoatouch = { ui_companion_cocoatouch_init, ui_companion_cocoatouch_deinit, ui_companion_cocoatouch_iterate, - NULL, + ui_companion_cocoatouch_toggle, ui_companion_cocoatouch_notify_content_loaded, "cocoatouch", };