diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index e2b4e64e61..54efb3a8da 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -606,15 +606,19 @@ static int rgui_settings_toggle_setting(unsigned setting, rgui_action_t action, switch (setting) { case RGUI_SETTINGS_REWIND_ENABLE: - if (action == RGUI_ACTION_OK || action == RGUI_ACTION_LEFT || action == RGUI_ACTION_RIGHT) + if (action == RGUI_ACTION_OK || + action == RGUI_ACTION_LEFT || + action == RGUI_ACTION_RIGHT) { menu_settings_set(S_REWIND); - - if (g_extern.lifecycle_mode_state & (1ULL << MODE_INFO_DRAW)) - menu_settings_msg(S_MSG_RESTART_RARCH, 180); + if (g_settings.rewind_enable) + rarch_init_rewind(); } else if (action == RGUI_ACTION_START) + { g_settings.rewind_enable = false; + rarch_deinit_rewind(); + } break; case RGUI_SETTINGS_REWIND_GRANULARITY: if (action == RGUI_ACTION_OK || action == RGUI_ACTION_RIGHT) diff --git a/general.h b/general.h index ab101d1180..d02a64483b 100644 --- a/general.h +++ b/general.h @@ -647,6 +647,8 @@ void rarch_render_cached_frame(void); void rarch_init_msg_queue(void); void rarch_deinit_msg_queue(void); void rarch_input_poll(void); +void rarch_init_rewind(void); +void rarch_deinit_rewind(void); void rarch_load_state(void); void rarch_save_state(void); diff --git a/retroarch.c b/retroarch.c index ddd3ded8c6..5331b6d158 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1432,9 +1432,9 @@ static void deinit_cheats(void) cheat_manager_free(g_extern.cheat); } -static void init_rewind(void) +void rarch_init_rewind(void) { - if (!g_settings.rewind_enable) + if (!g_settings.rewind_enable || g_extern.state_manager) return; g_extern.state_size = pretro_serialize_size(); @@ -1469,7 +1469,7 @@ static void init_rewind(void) RARCH_WARN("Failed to init rewind buffer. Rewinding will be disabled.\n"); } -static void deinit_rewind(void) +void rarch_deinit_rewind(void) { if (g_extern.state_manager) state_manager_free(g_extern.state_manager); @@ -2802,7 +2802,7 @@ int rarch_main_init(int argc, char *argv[]) #ifdef HAVE_NETPLAY if (!g_extern.netplay) #endif - init_rewind(); + rarch_init_rewind(); init_libretro_cbs(); init_controllers(); @@ -2971,7 +2971,7 @@ void rarch_main_deinit(void) #ifdef HAVE_NETPLAY if (!g_extern.netplay) #endif - deinit_rewind(); + rarch_deinit_rewind(); deinit_cheats();