diff --git a/dynamic.c b/dynamic.c index 1ec47769bc..f764a97bf0 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1062,8 +1062,8 @@ bool rarch_environment_cb(unsigned cmd, void *data) *g_extern.fullpath = '\0'; #if defined(RARCH_CONSOLE) - rarch_main_set_state(RARCH_ACTION_STATE_EXITSPAWN); - g_extern.lifecycle_state |= (1ULL << MODE_EXITSPAWN_START_GAME); + if (driver.frontend_ctx && driver.frontend_ctx->set_fork) + driver.frontend_ctx->set_fork(true, true); #elif defined(HAVE_DYNAMIC) rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT); #endif diff --git a/frontend/frontend.c b/frontend/frontend.c index 0623f9beb5..6bda28f3a6 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -113,9 +113,7 @@ void main_exit(args_type() args) if (driver.frontend_ctx && driver.frontend_ctx->deinit) driver.frontend_ctx->deinit(args); - if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN) - && driver.frontend_ctx - && driver.frontend_ctx->exitspawn) + if (driver.frontend_ctx && driver.frontend_ctx->exitspawn) driver.frontend_ctx->exitspawn(g_settings.libretro, sizeof(g_settings.libretro)); diff --git a/frontend/frontend_context.h b/frontend/frontend_context.h index 3ebe895ff7..b6997cced5 100644 --- a/frontend/frontend_context.h +++ b/frontend/frontend_context.h @@ -61,6 +61,7 @@ typedef struct frontend_ctx_driver process_args_t process_args; int (*process_events)(void *data); void (*exec)(const char *, bool); + void (*set_fork)(bool exitspawn, bool start_game); void (*shutdown)(bool); void (*get_name)(char *, size_t); int (*get_rating)(void); diff --git a/frontend/platform/platform_android.c b/frontend/platform/platform_android.c index eba9c6d3c8..8a382d002d 100644 --- a/frontend/platform/platform_android.c +++ b/frontend/platform/platform_android.c @@ -889,6 +889,7 @@ const frontend_ctx_driver_t frontend_ctx_android = { NULL, /* process_args */ frontend_android_process_events, /* process_events */ NULL, /* exec */ + NULL, /* set_fork */ frontend_android_shutdown, /* shutdown */ frontend_android_get_name, /* get_name */ frontend_android_get_rating, /* get_rating */ diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c index cabefc3fa4..791611bbc6 100644 --- a/frontend/platform/platform_apple.c +++ b/frontend/platform/platform_apple.c @@ -73,6 +73,7 @@ const frontend_ctx_driver_t frontend_ctx_apple = { NULL, /* process_args */ NULL, /* process_events */ NULL, /* exec */ + NULL, /* set_fork */ frontend_apple_shutdown, /* shutdown */ NULL, /* get_name */ frontend_apple_get_rating, /* get_rating */ diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index e17d8dd348..f358b826f1 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -59,6 +59,9 @@ enum GX_DEVICE_END }; +static bool exit_spawn = false; +static bool exitspawn_start_game = false; + #if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER) static devoptab_t dotab_stdout = { "stdout", // device name @@ -306,8 +309,10 @@ static void frontend_gx_exitspawn(char *core_path, size_t sizeof_core_path) if (gx_rom_path[0] != '\0') should_load_game = true; #elif defined(HW_RVL) - if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN_START_GAME)) - should_load_game = true; + should_load_game = exitspawn_start_game; + + if (!exit_spawn) + return; frontend_gx_exec(core_path, should_load_game); @@ -342,6 +347,12 @@ static void frontend_gx_exec(const char *path, bool should_load_game) #endif } +static void frontend_gx_set_fork(bool exitspawn, bool start_game) +{ + exit_spawn = exitspawn; + exitspawn_start_game = start_game; +} + static int frontend_gx_get_rating(void) { #ifdef HW_RVL @@ -359,6 +370,7 @@ const frontend_ctx_driver_t frontend_ctx_gx = { frontend_gx_process_args, /* process_args */ NULL, /* process_events */ frontend_gx_exec, /* exec */ + frontend_gx_set_fork, /* set_fork */ NULL, /* shutdown */ NULL, /* get_name */ frontend_gx_get_rating, /* get_rating */ diff --git a/frontend/platform/platform_null.c b/frontend/platform/platform_null.c index 8c337cfe63..f367cb6165 100644 --- a/frontend/platform/platform_null.c +++ b/frontend/platform/platform_null.c @@ -29,6 +29,7 @@ const frontend_ctx_driver_t frontend_ctx_null = { NULL, /* process_args */ NULL, /* process_events */ NULL, /* exec */ + NULL, /* set_fork */ NULL, /* shutdown */ NULL, /* get_name */ NULL, /* get_rating */ diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index 0706c6905a..e8d5907acf 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -41,6 +41,8 @@ SYS_PROCESS_PARAM(1001, 0x200000) static bool multiman_detected = false; #endif +static bool exit_spawn = false; +static bool exitspawn_start_game = false; #ifdef IS_SALAMANDER #include @@ -306,6 +308,12 @@ static void frontend_ps3_deinit(void *data) static void frontend_ps3_exec(const char *path, bool should_load_game); +static void frontend_ps3_set_fork(bool exit, bool start_game) +{ + exit_spawn = exitspawn; + exitspawn_start_game = start_game; +} + static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size) { #ifdef HAVE_RARCH_EXEC @@ -315,8 +323,10 @@ static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size) bool original_verbose = g_extern.verbosity; g_extern.verbosity = true; - if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN_START_GAME)) - should_load_game = true; + should_load_game = exitspawn_start_game; + + if (!exit_spawn) + return; #endif frontend_ps3_exec(core_path, should_load_game); @@ -439,6 +449,7 @@ const frontend_ctx_driver_t frontend_ctx_ps3 = { NULL, /* process_args */ NULL, /* process_events */ frontend_ps3_exec, /* exec */ + frontend_ps3_set_fork, /* set_fork */ NULL, /* shutdown */ NULL, /* get_name */ frontend_ps3_get_rating, /* get_rating */ diff --git a/frontend/platform/platform_psp.c b/frontend/platform/platform_psp.c index 5e713bd757..bc5007de80 100644 --- a/frontend/platform/platform_psp.c +++ b/frontend/platform/platform_psp.c @@ -42,6 +42,9 @@ PSP_HEAP_SIZE_MAX(); char eboot_path[512]; +static bool exit_spawn = false; +static bool exitspawn_start_game = false; + #ifdef IS_SALAMANDER #include "../../file_ext.h" #endif @@ -206,14 +209,20 @@ static void frontend_psp_exec(const char *path, bool should_load_game) #endif } +static void frontend_psp_set_fork(bool exit, bool start_game) +{ + exit_spawn = true; + exitspawn_start_game = start_game; +} static void frontend_psp_exitspawn(char *core_path, size_t sizeof_core_path) { bool should_load_game = false; #ifndef IS_SALAMANDER - if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN_START_GAME)) - should_load_game = true; + should_load_game = exitspawn_start_game; + if (!exit_spawn) + return; #endif frontend_psp_exec(core_path, should_load_game); } @@ -231,6 +240,7 @@ const frontend_ctx_driver_t frontend_ctx_psp = { NULL, /* process_args */ NULL, /* process_events */ frontend_psp_exec, /* exec */ + frontend_psp_set_fork, /* set_fork */ frontend_psp_shutdown, /* shutdown */ NULL, /* get_name */ frontend_psp_get_rating, /* get_rating */ diff --git a/frontend/platform/platform_qnx.c b/frontend/platform/platform_qnx.c index 735d8ccac2..52900c4b93 100644 --- a/frontend/platform/platform_qnx.c +++ b/frontend/platform/platform_qnx.c @@ -67,6 +67,7 @@ const frontend_ctx_driver_t frontend_ctx_qnx = { NULL, /* process_args */ NULL, /* process_events */ NULL, /* exec */ + NULL, /* set_fork */ frontend_qnx_shutdown, /* shutdown */ NULL, /* get_name */ frontend_qnx_get_rating, /* get_rating */ diff --git a/frontend/platform/platform_xdk.c b/frontend/platform/platform_xdk.c index 23728c33b7..1b7ffbb3e9 100644 --- a/frontend/platform/platform_xdk.c +++ b/frontend/platform/platform_xdk.c @@ -31,6 +31,9 @@ #include "../../general.h" #endif +static bool exit_spawn; +static bool exitspawn_start_game; + #ifdef _XBOX1 static HRESULT xbox_io_mount(char *szDrive, char *szDevice) { @@ -258,13 +261,21 @@ static void frontend_xdk_init(void *data) static void frontend_xdk_exec(const char *path, bool should_load_game); +static void frontend_xdk_set_fork(bool exit, bool start_game) +{ + exit_spawn = exit; + exitspawn_start_game = start_game; +} + static void frontend_xdk_exitspawn(char *core_path, size_t sizeof_core_path) { bool should_load_game = false; #ifndef IS_SALAMANDER - if (g_extern.lifecycle_state & (1ULL << MODE_EXITSPAWN_START_GAME)) - should_load_game = true; + should_load_game = exitspawn_start_game; + + if (!exit_spawn) + return; #endif frontend_xdk_exec(core_path, should_load_game); } @@ -330,6 +341,7 @@ const frontend_ctx_driver_t frontend_ctx_xdk = { NULL, /* process_args */ NULL, /* process_events */ frontend_xdk_exec, /* exec */ + frontend_xdk_set_fork, /* set_fork */ NULL, /* shutdown */ NULL, /* get_name */ frontend_xdk_get_rating, /* get_rating */ diff --git a/general.h b/general.h index 7a3f6e0b89..7b8ae32656 100644 --- a/general.h +++ b/general.h @@ -137,7 +137,6 @@ enum action_state RARCH_ACTION_STATE_LOAD_CONTENT, RARCH_ACTION_STATE_MENU_RUNNING, RARCH_ACTION_STATE_MENU_RUNNING_FINISHED, - RARCH_ACTION_STATE_EXITSPAWN, RARCH_ACTION_STATE_QUIT, RARCH_ACTION_STATE_FORCE_QUIT, }; @@ -147,8 +146,6 @@ enum menu_enums MODE_NONE = 0, MODE_MENU_WIDESCREEN, MODE_MENU_HD, - MODE_EXITSPAWN, - MODE_EXITSPAWN_START_GAME, }; enum sound_mode_enums diff --git a/retroarch.c b/retroarch.c index 3347281c52..b1b0ebacf0 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2927,9 +2927,6 @@ void rarch_main_set_state(unsigned cmd) /* Restore libretro keyboard callback. */ g_extern.system.key_event = g_extern.frontend_key_event; break; - case RARCH_ACTION_STATE_EXITSPAWN: - g_extern.lifecycle_state |= (1ULL << MODE_EXITSPAWN); - break; case RARCH_ACTION_STATE_QUIT: g_extern.system.shutdown = true; rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED); @@ -3272,7 +3269,8 @@ void rarch_main_command(unsigned cmd) SALAMANDER_FILE, sizeof(g_extern.fullpath)); #endif - rarch_main_set_state(RARCH_ACTION_STATE_EXITSPAWN); + if (driver.frontend_ctx && driver.frontend_ctx->set_fork) + driver.frontend_ctx->set_fork(true, false); break; case RARCH_CMD_MENU_SAVE_CONFIG: save_core_config();