diff --git a/config.def.h b/config.def.h index 5da33a5014..b7bc55bf91 100644 --- a/config.def.h +++ b/config.def.h @@ -259,6 +259,9 @@ static unsigned aspect_ratio_idx = ASPECT_RATIO_4_3; static unsigned aspect_ratio_idx = ASPECT_RATIO_CONFIG; // Use g_settings.video.aspect_ratio. #endif +// Save configuration file on exit +static bool config_save_on_exit = true; + // Crop overscanned frames. static const bool crop_overscan = true; diff --git a/frontend/frontend.c b/frontend/frontend.c index 88b7e3db15..57af1cce25 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -98,6 +98,16 @@ int main(int argc, char *argv[]) } menu_free(); + + // TODO: Commented for now since this conflicts with Phoenix config saving. + // Either Phoenix frontend needs to have the same amount of options as RGUI + // or we should slim down Phoenix even more (in terms of taking away the options) + // and do that with RGUI so that we can uncomment that without Phoenix modifying + // the config file on its own based on user preferences. + + //if (g_extern.config_save_on_exit) + //config_save_file(g_extern.config_path); + if (g_extern.main_is_init) rarch_main_deinit(); #else diff --git a/frontend/frontend_android.c b/frontend/frontend_android.c index e5389cee9d..664351c9ef 100644 --- a/frontend/frontend_android.c +++ b/frontend/frontend_android.c @@ -263,6 +263,9 @@ exit: menu_free(); + if (g_extern.config_save_on_exit) + config_save_file(g_extern.config_path); + if (g_extern.main_is_init) rarch_main_deinit(); diff --git a/frontend/frontend_bbqnx.c b/frontend/frontend_bbqnx.c index 2ba1eb4951..78035cb6f5 100644 --- a/frontend/frontend_bbqnx.c +++ b/frontend/frontend_bbqnx.c @@ -93,7 +93,8 @@ int rarch_main(int argc, char *argv[]) menu_free(); - config_save_file(g_extern.config_path); + if (g_extern.config_save_on_exit) + config_save_file(g_extern.config_path); if (g_extern.main_is_init) rarch_main_deinit(); diff --git a/frontend/frontend_console.c b/frontend/frontend_console.c index 6786341ba0..4c79d7e954 100644 --- a/frontend/frontend_console.c +++ b/frontend/frontend_console.c @@ -213,7 +213,8 @@ int rarch_main(int argc, char *argv[]) menu_free(); - config_save_file(g_extern.config_path); + if (g_extern.config_save_on_exit) + config_save_file(g_extern.config_path); #ifdef GEKKO /* Per-core input config saving */ diff --git a/frontend/frontend_ios.c b/frontend/frontend_ios.c index 34a42afe39..8022b6043a 100644 --- a/frontend/frontend_ios.c +++ b/frontend/frontend_ios.c @@ -151,6 +151,10 @@ void* rarch_main_ios(void* args) g_extern.system.shutdown = false; menu_free(); + + if (g_extern.config_save_on_exit) + config_save_file(g_extern.config_path); + if (g_extern.main_is_init) rarch_main_deinit(); diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index 39d8b61098..cdd9f5146c 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -141,6 +141,7 @@ typedef enum RGUI_SETTINGS_OPTIONS, RGUI_SETTINGS_REWIND_ENABLE, RGUI_SETTINGS_REWIND_GRANULARITY, + RGUI_SETTINGS_CONFIG_SAVE_ON_EXIT, RGUI_SETTINGS_SRAM_AUTOSAVE, RGUI_SETTINGS_SAVESTATE_SAVE, RGUI_SETTINGS_SAVESTATE_LOAD, diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index cd82b46157..0d65079258 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -619,6 +619,9 @@ static void render_text(rgui_handle_t *rgui) case RGUI_SETTINGS_REWIND_GRANULARITY: snprintf(type_str, sizeof(type_str), "%u", g_settings.rewind_granularity); break; + case RGUI_SETTINGS_CONFIG_SAVE_ON_EXIT: + strlcpy(type_str, g_extern.config_save_on_exit ? "ON" : "OFF", sizeof(type_str)); + break; case RGUI_SETTINGS_SRAM_AUTOSAVE: strlcpy(type_str, g_settings.autosave_interval ? "ON" : "OFF", sizeof(type_str)); break; @@ -914,6 +917,15 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r else if (action == RGUI_ACTION_START) g_settings.rewind_granularity = 1; break; + case RGUI_SETTINGS_CONFIG_SAVE_ON_EXIT: + if (action == RGUI_ACTION_OK || action == RGUI_ACTION_RIGHT + || action == RGUI_ACTION_LEFT) + { + g_extern.config_save_on_exit = !g_extern.config_save_on_exit; + } + else if (action == RGUI_ACTION_START) + g_extern.config_save_on_exit = true; + break; #if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE) case RGUI_SETTINGS_SRAM_AUTOSAVE: if (action == RGUI_ACTION_OK || action == RGUI_ACTION_RIGHT || action == RGUI_ACTION_LEFT) @@ -1383,6 +1395,7 @@ static void rgui_settings_options_populate_entries(rgui_handle_t *rgui) rgui_list_clear(rgui->selection_buf); rgui_list_push(rgui->selection_buf, "Rewind", RGUI_SETTINGS_REWIND_ENABLE, 0); rgui_list_push(rgui->selection_buf, "Rewind Granularity", RGUI_SETTINGS_REWIND_GRANULARITY, 0); + rgui_list_push(rgui->selection_buf, "Config Save On Exit", RGUI_SETTINGS_CONFIG_SAVE_ON_EXIT, 0); #if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE) rgui_list_push(rgui->selection_buf, "SRAM Autosave", RGUI_SETTINGS_SRAM_AUTOSAVE, 0); #endif diff --git a/general.h b/general.h index 3aa4e23b38..8d5a2094dc 100644 --- a/general.h +++ b/general.h @@ -583,6 +583,7 @@ struct global bool main_is_init; bool error_in_init; + bool config_save_on_exit; char error_string[1024]; jmp_buf error_sjlj_context; unsigned menu_toggle_behavior; diff --git a/settings.c b/settings.c index 5575121909..a7af34292f 100644 --- a/settings.c +++ b/settings.c @@ -292,6 +292,8 @@ void config_set_defaults(void) #endif #endif + g_extern.config_save_on_exit = config_save_on_exit; + #if defined(HAVE_RMENU) || defined(HAVE_RGUI) /* Avoid reloading config on every ROM load */ g_extern.block_config_read = true; @@ -673,6 +675,8 @@ bool config_load_file(const char *path) CONFIG_GET_INT(input.icade_profile[3], "input_autodetect_icade_profile_pad4"); #endif + CONFIG_GET_BOOL_EXTERN(config_save_on_exit, "config_save_on_exit"); + if (!g_extern.has_set_save_path && config_get_path(conf, "savefile_directory", tmp_str, sizeof(tmp_str))) { if (!strcmp(tmp_str, "default")) @@ -1002,6 +1006,7 @@ bool config_save_file(const char *path) config_set_float(conf, "video_font_size", g_settings.video.font_size); // g_extern + config_set_bool(conf, "config_save_on_exit", g_extern.config_save_on_exit); config_set_int(conf, "sound_mode", g_extern.console.sound.mode); config_set_int(conf, "state_slot", g_extern.state_slot); config_set_int(conf, "audio_mute", g_extern.audio_data.mute);