From e2c7671e9fbb970dd54cceb8184e2a0333aca5b8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 15 May 2017 04:31:40 +0200 Subject: [PATCH] Create rarch_menu_running/rarch_menu_running_finished --- command.c | 6 +-- menu/cbs/menu_cbs_ok.c | 4 +- network/netplay/netplay_handshake.c | 4 +- retroarch.c | 66 +++++++++++++++-------------- retroarch.h | 8 ++-- tasks/task_content.c | 16 +++---- ui/drivers/ui_cocoatouch.m | 4 +- 7 files changed, 52 insertions(+), 56 deletions(-) diff --git a/command.c b/command.c index 655410f751..da5f13955f 100644 --- a/command.c +++ b/command.c @@ -1888,9 +1888,9 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_MENU_TOGGLE: #ifdef HAVE_MENU if (menu_driver_is_alive()) - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + rarch_menu_running_finished(); else - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + rarch_menu_running(); #endif break; case CMD_EVENT_CONTROLLERS_INIT: @@ -2304,7 +2304,7 @@ bool command_event(enum event_command cmd, void *data) #endif break; case CMD_EVENT_RESUME: - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + rarch_menu_running_finished(); if (ui_companion_is_on_foreground()) ui_companion_driver_toggle(); break; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 2782f44c7b..438e82467c 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -4104,9 +4104,7 @@ static void action_ok_netplay_enable_client_hostname_cb( } menu_input_dialog_end(); - - /* Force the menu to close */ - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + rarch_menu_running_finished(); } #endif diff --git a/network/netplay/netplay_handshake.c b/network/netplay/netplay_handshake.c index 7ff75230ab..5c44e90a97 100644 --- a/network/netplay/netplay_handshake.c +++ b/network/netplay/netplay_handshake.c @@ -295,7 +295,7 @@ static void handshake_password(void *ignore, const char *line) #ifdef HAVE_MENU menu_input_dialog_end(); - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + rarch_menu_running_finished(); #endif } #endif @@ -394,7 +394,7 @@ bool netplay_handshake_init(netplay_t *netplay, { #ifdef HAVE_MENU menu_input_ctx_line_t line; - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + rarch_menu_running(); #endif handshake_password_netplay = netplay; diff --git a/retroarch.c b/retroarch.c index a237dc08d3..f0fe9c3963 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1295,6 +1295,35 @@ bool retroarch_is_on_main_thread(void) return true; } +void rarch_menu_running(void) +{ +#ifdef HAVE_MENU + menu_driver_ctl(RARCH_MENU_CTL_SET_TOGGLE, NULL); +#endif +#ifdef HAVE_OVERLAY + { + settings_t *settings = config_get_ptr(); + if (settings && settings->bools.input_overlay_hide_in_menu) + command_event(CMD_EVENT_OVERLAY_DEINIT, NULL); + } +#endif +} + +void rarch_menu_running_finished(void) +{ +#ifdef HAVE_MENU + menu_driver_ctl(RARCH_MENU_CTL_UNSET_TOGGLE, NULL); +#endif + video_driver_set_texture_enable(false, false); +#ifdef HAVE_OVERLAY + { + settings_t *settings = config_get_ptr(); + if (settings && settings->bools.input_overlay_hide_in_menu) + command_event(CMD_EVENT_OVERLAY_INIT, NULL); + } +#endif +} + bool rarch_ctl(enum rarch_ctl_state state, void *data) { switch(state) @@ -1459,31 +1488,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) break; case RARCH_CTL_IS_BLOCK_CONFIG_READ: return rarch_block_config_read; - case RARCH_CTL_MENU_RUNNING: -#ifdef HAVE_MENU - menu_driver_ctl(RARCH_MENU_CTL_SET_TOGGLE, NULL); -#endif -#ifdef HAVE_OVERLAY - { - settings_t *settings = config_get_ptr(); - if (settings && settings->bools.input_overlay_hide_in_menu) - command_event(CMD_EVENT_OVERLAY_DEINIT, NULL); - } -#endif - break; - case RARCH_CTL_MENU_RUNNING_FINISHED: -#ifdef HAVE_MENU - menu_driver_ctl(RARCH_MENU_CTL_UNSET_TOGGLE, NULL); -#endif - video_driver_set_texture_enable(false, false); -#ifdef HAVE_OVERLAY - { - settings_t *settings = config_get_ptr(); - if (settings && settings->bools.input_overlay_hide_in_menu) - command_event(CMD_EVENT_OVERLAY_INIT, NULL); - } -#endif - break; case RARCH_CTL_NONE: default: return false; @@ -1806,9 +1810,7 @@ bool retroarch_main_quit(void) #endif runloop_shutdown_initiated = true; -#ifdef HAVE_MENU - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); -#endif + rarch_menu_running_finished(); return true; } @@ -2387,7 +2389,7 @@ static enum runloop_state runloop_check_state( iter.action = action; if (!menu_driver_iterate(&iter)) - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + rarch_menu_running_finished(); if (focused || !runloop_idle) menu_driver_render(runloop_idle, rarch_is_inited, @@ -2417,7 +2419,7 @@ static enum runloop_state runloop_check_state( { if (rarch_is_inited && (current_core_type != CORE_TYPE_DUMMY)) { - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + rarch_menu_running_finished(); menu_event_kb_set(false, RETROK_F1); } } @@ -2429,12 +2431,12 @@ static enum runloop_state runloop_check_state( if (menu_driver_is_alive()) { if (rarch_is_inited && (current_core_type != CORE_TYPE_DUMMY)) - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + rarch_menu_running_finished(); } else { menu_display_toggle_set_reason(MENU_TOGGLE_REASON_USER); - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + rarch_menu_running(); } } else diff --git a/retroarch.h b/retroarch.h index 7f5b8f3871..6a108031b3 100644 --- a/retroarch.h +++ b/retroarch.h @@ -49,10 +49,6 @@ enum rarch_ctl_state RARCH_CTL_DESTROY, - /* Menu running? */ - RARCH_CTL_MENU_RUNNING, - RARCH_CTL_MENU_RUNNING_FINISHED, - RARCH_CTL_SET_PATHS_REDIRECT, RARCH_CTL_IS_BPS_PREF, @@ -355,6 +351,10 @@ void runloop_set(enum runloop_action action); void runloop_unset(enum runloop_action action); +void rarch_menu_running(void); + +void rarch_menu_running_finished(void); + bool retroarch_is_on_main_thread(void); rarch_system_info_t *runloop_get_system_info(void); diff --git a/tasks/task_content.c b/tasks/task_content.c index 7e650d9f09..a9738db88b 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1150,7 +1150,7 @@ bool task_push_load_content_from_playlist_from_menu( free(error_string); } - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + rarch_menu_running(); ret = false; goto end; @@ -1158,7 +1158,7 @@ bool task_push_load_content_from_playlist_from_menu( #ifndef HAVE_DYNAMIC runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + rarch_menu_running_finished(); #endif /* Load core */ @@ -1253,9 +1253,7 @@ bool task_push_start_current_core(content_ctx_info_t *content_info) free(error_string); } -#ifdef HAVE_MENU - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); -#endif + rarch_menu_running(); ret = false; goto end; @@ -1384,7 +1382,7 @@ bool task_push_load_content_with_new_core_from_menu( free(error_string); } - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + rarch_menu_running(); ret = false; goto end; @@ -1552,9 +1550,7 @@ bool task_push_start_builtin_core( /* Load content */ if (!task_load_content_callback(content_info, true, false)) { -#ifdef HAVE_MENU - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); -#endif + rarch_menu_running(); return false; } @@ -1603,7 +1599,7 @@ bool task_push_load_content_with_core_from_menu( /* Load content */ if (!task_load_content_callback(content_info, true, false)) { - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + rarch_menu_running(); return false; } diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 1635de089c..9b5f93d2fb 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -56,7 +56,7 @@ static void rarch_enable_ui(void) runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); runloop_ctl(RUNLOOP_CTL_SET_IDLE, &boolean); - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + rarch_menu_running(); } static void rarch_disable_ui(void) @@ -67,7 +67,7 @@ static void rarch_disable_ui(void) runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); runloop_ctl(RUNLOOP_CTL_SET_IDLE, &boolean); - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + rarch_menu_running_finished(); #ifdef HAVE_AVFOUNDATION [[RetroArch_iOS get] supportOtherAudioSessions]; #endif