Merge pull request #305 from libretro/configswap

Configswap
This commit is contained in:
Hans-Kristian Arntzen 2013-09-27 08:34:36 -07:00
commit 884ae34f0a
9 changed files with 297 additions and 87 deletions

View File

@ -545,6 +545,7 @@ void init_audio(void)
g_extern.audio_active = false;
}
g_extern.audio_data.use_float = false;
if (g_extern.audio_active && driver.audio->use_float && audio_use_float_func())
g_extern.audio_data.use_float = true;

3
file.h
View File

@ -74,6 +74,9 @@ bool path_is_directory(const char *path);
bool path_file_exists(const char *path);
const char *path_get_extension(const char *path);
// Removes all text after and including the last '.'
char *path_remove_extension(char *path);
// Returns basename from path.
const char *path_basename(const char *path);

View File

@ -185,6 +185,14 @@ const char *path_get_extension(const char *path)
return "";
}
char *path_remove_extension(char *path)
{
char *last = strrchr(path, '.');
if (*last)
*last = '\0';
return last;
}
static int qstrcmp_plain(const void *a_, const void *b_)
{
const struct string_list_elem *a = (const struct string_list_elem*)a_;

View File

@ -33,7 +33,25 @@ const menu_ctx_driver_t *menu_ctx;
#ifdef HAVE_SHADER_MANAGER
void shader_manager_init(rgui_handle_t *rgui)
{
memset(&rgui->shader, 0, sizeof(rgui->shader));
config_file_t *conf = NULL;
// In a multi-config setting, we can't have conflicts on rgui.cgp/rgui.glslp.
if (*g_extern.config_path)
{
fill_pathname_base(rgui->default_glslp, g_extern.config_path, sizeof(rgui->default_glslp));
path_remove_extension(rgui->default_glslp);
strlcat(rgui->default_glslp, ".glslp", sizeof(rgui->default_glslp));
fill_pathname_base(rgui->default_cgp, g_extern.config_path, sizeof(rgui->default_cgp));
path_remove_extension(rgui->default_cgp);
strlcat(rgui->default_cgp, ".cgp", sizeof(rgui->default_cgp));
}
else
{
strlcpy(rgui->default_glslp, "rgui.glslp", sizeof(rgui->default_glslp));
strlcpy(rgui->default_cgp, "rgui.cgp", sizeof(rgui->default_cgp));
}
char cgp_path[PATH_MAX];
const char *ext = path_get_extension(g_settings.video.shader_path);
@ -463,6 +481,47 @@ void load_menu_game_history(unsigned game_index)
#endif
}
static void menu_init_history(void)
{
if (rgui->history)
{
rom_history_free(rgui->history);
rgui->history = NULL;
}
if (*g_extern.config_path)
{
char history_path[PATH_MAX];
if (*g_settings.game_history_path)
strlcpy(history_path, g_settings.game_history_path, sizeof(history_path));
else
{
fill_pathname_resolve_relative(history_path, g_extern.config_path,
".retroarch-game-history.txt", sizeof(history_path));
}
RARCH_LOG("[RGUI]: Opening history: %s.\n", history_path);
rgui->history = rom_history_init(history_path, g_settings.game_history_size);
}
}
static void menu_update_libretro_info(void)
{
*rgui->libretro_dir = '\0';
#ifdef HAVE_DYNAMIC
libretro_free_system_info(&rgui->info);
if (path_is_directory(g_settings.libretro))
strlcpy(rgui->libretro_dir, g_settings.libretro, sizeof(rgui->libretro_dir));
else if (*g_settings.libretro)
{
fill_pathname_basedir(rgui->libretro_dir, g_settings.libretro, sizeof(rgui->libretro_dir));
libretro_get_system_info(g_settings.libretro, &rgui->info, NULL);
}
#else
retro_get_system_info(&rgui->info);
#endif
}
bool load_menu_game(void)
{
if (g_extern.main_is_init)
@ -475,13 +534,17 @@ bool load_menu_game(void)
args.sram_path = *g_extern.savefile_dir ? g_extern.savefile_dir : NULL;
args.state_path = *g_extern.savestate_dir ? g_extern.savestate_dir : NULL;
args.rom_path = *g_extern.fullpath ? g_extern.fullpath : NULL;
args.libretro_path = g_settings.libretro;
args.libretro_path = *g_settings.libretro ? g_settings.libretro : NULL;
args.no_rom = rgui->load_no_rom;
rgui->load_no_rom = false;
if (rarch_main_init_wrap(&args) == 0)
{
RARCH_LOG("rarch_main_init_wrap() succeeded.\n");
// Update menu state which depends on config.
menu_update_libretro_info();
menu_init_history();
shader_manager_init(rgui);
return true;
}
else
@ -511,24 +574,14 @@ void menu_init(void)
rgui->frame_buf_show = true;
rgui->current_pad = 0;
#ifdef HAVE_DYNAMIC
if (path_is_directory(g_settings.libretro))
strlcpy(rgui->libretro_dir, g_settings.libretro, sizeof(rgui->libretro_dir));
else if (*g_settings.libretro)
{
fill_pathname_basedir(rgui->libretro_dir, g_settings.libretro, sizeof(rgui->libretro_dir));
libretro_get_system_info(g_settings.libretro, &rgui->info, NULL);
}
#else
retro_get_system_info(&rgui->info);
#endif
menu_update_libretro_info();
#ifdef HAVE_FILEBROWSER
if (!(strlen(g_settings.rgui_browser_directory) > 0))
strlcpy(g_settings.rgui_browser_directory, default_paths.filebrowser_startup_dir,
sizeof(g_settings.rgui_browser_directory));
rgui->browser = (filebrowser_t*)calloc(1, sizeof(*(rgui->browser)));
rgui->browser = (filebrowser_t*)calloc(1, sizeof(*(rgui->browser)));
if (rgui->browser == NULL)
{
@ -556,21 +609,7 @@ void menu_init(void)
shader_manager_init(rgui);
#endif
if (*g_extern.config_path)
{
char history_path[PATH_MAX];
if (*g_settings.game_history_path)
strlcpy(history_path, g_settings.game_history_path, sizeof(history_path));
else
{
fill_pathname_resolve_relative(history_path, g_extern.config_path,
".retroarch-game-history.txt", sizeof(history_path));
}
RARCH_LOG("[RGUI]: Opening history: %s.\n", history_path);
rgui->history = rom_history_init(history_path, g_settings.game_history_size);
}
menu_init_history();
rgui->last_time = rarch_get_time_usec();
}
@ -778,3 +817,106 @@ deinit:
}
#endif
#endif
// Quite intrusive and error prone.
// Likely to have lots of small bugs.
// Cleanly exit the main loop to ensure that all the tiny details get set properly.
// This should mitigate most of the smaller bugs.
bool menu_replace_config(const char *path)
{
if (strcmp(path, g_extern.config_path) == 0)
return false;
if (g_extern.config_save_on_exit && *g_extern.config_path)
config_save_file(g_extern.config_path);
strlcpy(g_extern.config_path, path, sizeof(g_extern.config_path));
g_extern.block_config_read = false;
// Load dummy core.
*g_extern.fullpath = '\0';
*g_settings.libretro = '\0'; // Load core in new config.
g_extern.lifecycle_mode_state |= (1ULL << MODE_LOAD_GAME);
rgui->load_no_rom = false;
return true;
}
// Save a new config to a file. Filename is based on heuristics to avoid typing.
bool menu_save_new_config(void)
{
char config_dir[PATH_MAX];
*config_dir = '\0';
if (*g_settings.rgui_config_directory)
strlcpy(config_dir, g_settings.rgui_config_directory, sizeof(config_dir));
else if (*g_extern.config_path) // Fallback
fill_pathname_basedir(config_dir, g_extern.config_path, sizeof(config_dir));
else
{
const char *msg = "Config directory not set. Cannot save new config.";
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
RARCH_ERR("%s\n", msg);
return false;
}
bool found_path = false;
char config_name[PATH_MAX];
char config_path[PATH_MAX];
if (*g_settings.libretro && !path_is_directory(g_settings.libretro) && path_file_exists(g_settings.libretro)) // Infer file name based on libretro core.
{
// In case of collision, find an alternative name.
for (unsigned i = 0; i < 16; i++)
{
fill_pathname_base(config_name, g_settings.libretro, sizeof(config_name));
path_remove_extension(config_name);
fill_pathname_join(config_path, config_dir, config_name, sizeof(config_path));
char tmp[64];
*tmp = '\0';
if (i)
snprintf(tmp, sizeof(tmp), "-%u.cfg", i);
else
strlcpy(tmp, ".cfg", sizeof(tmp));
strlcat(config_path, tmp, sizeof(config_path));
if (!path_file_exists(config_path))
{
found_path = true;
break;
}
}
}
// Fallback to system time ...
if (!found_path)
{
RARCH_WARN("Cannot infer new config path. Use current time.\n");
fill_dated_filename(config_name, "cfg", sizeof(config_name));
fill_pathname_join(config_path, config_dir, config_name, sizeof(config_path));
}
char msg[512];
bool ret;
if (config_save_file(config_path))
{
strlcpy(g_extern.config_path, config_path, sizeof(g_extern.config_path));
snprintf(msg, sizeof(msg), "Saved new config to \"%s\".", config_path);
RARCH_LOG("%s\n", msg);
ret = true;
}
else
{
snprintf(msg, sizeof(msg), "Failed saving config to \"%s\".", config_path);
RARCH_ERR("%s\n", msg);
ret = false;
}
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
return ret;
}

View File

@ -98,6 +98,8 @@ typedef enum
RGUI_SETTINGS_OPEN_FILEBROWSER,
RGUI_SETTINGS_OPEN_HISTORY,
RGUI_SETTINGS_CORE,
RGUI_SETTINGS_CONFIG,
RGUI_SETTINGS_SAVE_CONFIG,
RGUI_SETTINGS_CORE_OPTIONS,
RGUI_SETTINGS_AUDIO_OPTIONS,
RGUI_SETTINGS_INPUT_OPTIONS,
@ -122,6 +124,7 @@ typedef enum
RGUI_SAVESTATE_DIR_PATH,
RGUI_SAVEFILE_DIR_PATH,
RGUI_LIBRETRO_DIR_PATH,
RGUI_CONFIG_DIR_PATH,
#ifdef HAVE_OVERLAY
RGUI_OVERLAY_DIR_PATH,
#endif
@ -207,6 +210,8 @@ typedef struct
bool msg_force;
char base_path[PATH_MAX];
char default_glslp[PATH_MAX];
char default_cgp[PATH_MAX];
const uint8_t *font;
bool alloc_font;
@ -259,6 +264,10 @@ void menu_rom_history_push(const char *path, const char *core_path,
const char *core_name);
void menu_rom_history_push_current(void);
bool menu_replace_config(const char *path);
bool menu_save_new_config(void);
#ifdef __cplusplus
}
#endif

View File

@ -219,6 +219,7 @@ static bool menu_type_is_directory_browser(unsigned type)
#ifdef HAVE_DYNAMIC
type == RGUI_LIBRETRO_DIR_PATH ||
#endif
type == RGUI_CONFIG_DIR_PATH ||
type == RGUI_SAVEFILE_DIR_PATH ||
#ifdef HAVE_OVERLAY
type == RGUI_OVERLAY_DIR_PATH ||
@ -443,6 +444,8 @@ static void render_text(rgui_handle_t *rgui)
if (menu_type == RGUI_SETTINGS_CORE)
snprintf(title, sizeof(title), "CORE SELECTION %s", dir);
else if (menu_type == RGUI_SETTINGS_CONFIG)
snprintf(title, sizeof(title), "CONFIG %s", dir);
else if (menu_type == RGUI_SETTINGS_DISK_APPEND)
snprintf(title, sizeof(title), "DISK APPEND %s", dir);
else if (menu_type == RGUI_SETTINGS_VIDEO_OPTIONS)
@ -487,6 +490,8 @@ static void render_text(rgui_handle_t *rgui)
else if (menu_type == RGUI_LIBRETRO_DIR_PATH)
snprintf(title, sizeof(title), "LIBRETRO DIR %s", dir);
#endif
else if (menu_type == RGUI_CONFIG_DIR_PATH)
snprintf(title, sizeof(title), "CONFIG DIR %s", dir);
else if (menu_type == RGUI_SAVEFILE_DIR_PATH)
snprintf(title, sizeof(title), "SAVEFILE DIR %s", dir);
#ifdef HAVE_OVERLAY
@ -561,6 +566,7 @@ static void render_text(rgui_handle_t *rgui)
else
#endif
if (menu_type == RGUI_SETTINGS_CORE ||
menu_type == RGUI_SETTINGS_CONFIG ||
#ifdef HAVE_OVERLAY
menu_type == RGUI_SETTINGS_OVERLAY_PRESET ||
#endif
@ -721,6 +727,9 @@ static void render_text(rgui_handle_t *rgui)
strlcpy(type_str, *rgui->libretro_dir ? rgui->libretro_dir : "<None>", sizeof(type_str));
break;
#endif
case RGUI_CONFIG_DIR_PATH:
strlcpy(type_str, *g_settings.rgui_config_directory ? g_settings.rgui_config_directory : "<default>", sizeof(type_str));
break;
case RGUI_SHADER_DIR_PATH:
strlcpy(type_str, *g_settings.video.shader_dir ? g_settings.video.shader_dir : "<default>", sizeof(type_str));
break;
@ -738,6 +747,12 @@ static void render_text(rgui_handle_t *rgui)
snprintf(type_str, sizeof(type_str), "%u", current + 1);
break;
}
case RGUI_SETTINGS_CONFIG:
if (*g_extern.config_path)
fill_pathname_base(type_str, g_extern.config_path, sizeof(type_str));
else
strlcpy(type_str, "<default>", sizeof(type_str));
break;
case RGUI_SETTINGS_OPEN_FILEBROWSER:
case RGUI_SETTINGS_OPEN_HISTORY:
case RGUI_SETTINGS_CORE_OPTIONS:
@ -746,6 +761,7 @@ static void render_text(rgui_handle_t *rgui)
case RGUI_SETTINGS_VIDEO_OPTIONS:
case RGUI_SETTINGS_AUDIO_OPTIONS:
case RGUI_SETTINGS_DISK_OPTIONS:
case RGUI_SETTINGS_SAVE_CONFIG:
#ifdef HAVE_SHADER_MANAGER
case RGUI_SETTINGS_SHADER_OPTIONS:
case RGUI_SETTINGS_SHADER_PRESET:
@ -1109,6 +1125,10 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r
return -1;
}
break;
case RGUI_SETTINGS_SAVE_CONFIG:
if (action == RGUI_ACTION_OK)
menu_save_new_config();
break;
#ifdef HAVE_OVERLAY
case RGUI_SETTINGS_OVERLAY_PRESET:
switch (action)
@ -1413,6 +1433,10 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r
*rgui->libretro_dir = '\0';
break;
#endif
case RGUI_CONFIG_DIR_PATH:
if (action == RGUI_ACTION_START)
*g_settings.rgui_config_directory = '\0';
break;
case RGUI_SHADER_DIR_PATH:
if (action == RGUI_ACTION_START)
*g_settings.video.shader_dir = '\0';
@ -1490,6 +1514,8 @@ static void rgui_settings_populate_entries(rgui_handle_t *rgui)
#ifndef HAVE_DYNAMIC
rgui_list_push(rgui->selection_buf, "Restart RetroArch", RGUI_SETTINGS_RESTART_EMULATOR, 0);
#endif
rgui_list_push(rgui->selection_buf, "RetroArch Config", RGUI_SETTINGS_CONFIG, 0);
rgui_list_push(rgui->selection_buf, "Save New Config", RGUI_SETTINGS_SAVE_CONFIG, 0);
rgui_list_push(rgui->selection_buf, "Quit RetroArch", RGUI_SETTINGS_QUIT_RARCH, 0);
}
@ -1672,7 +1698,7 @@ static int shader_manager_toggle_setting(rgui_handle_t *rgui, unsigned setting,
if (rgui->shader.passes && type != RARCH_SHADER_NONE)
{
const char *conf_path = type == RARCH_SHADER_GLSL ? "rgui.glslp" : "rgui.cgp";
const char *conf_path = type == RARCH_SHADER_GLSL ? rgui->default_glslp : rgui->default_cgp;
char cgp_path[PATH_MAX];
const char *shader_dir = *g_settings.video.shader_dir ?
@ -2127,6 +2153,7 @@ static void rgui_settings_path_populate_entries(rgui_handle_t *rgui)
{
rgui_list_clear(rgui->selection_buf);
rgui_list_push(rgui->selection_buf, "Browser Directory", RGUI_BROWSER_DIR_PATH, 0);
rgui_list_push(rgui->selection_buf, "Config Directory", RGUI_CONFIG_DIR_PATH, 0);
#ifdef HAVE_DYNAMIC
rgui_list_push(rgui->selection_buf, "Core Directory", RGUI_LIBRETRO_DIR_PATH, 0);
#endif
@ -2365,6 +2392,8 @@ static int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
label = ""; // Shouldn't happen ...
#endif
}
else if (type == RGUI_SETTINGS_CONFIG)
label = g_settings.rgui_config_directory;
else if (type == RGUI_SETTINGS_DISK_APPEND)
label = rgui->base_path;
@ -2415,7 +2444,7 @@ static int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
rgui->selection_ptr = 0;
rgui->need_refresh = true;
}
else if ((menu_type_is_settings(type) || type == RGUI_SETTINGS_CORE || type == RGUI_SETTINGS_DISK_APPEND) && action == RGUI_ACTION_OK)
else if ((menu_type_is_settings(type) || type == RGUI_SETTINGS_CORE || type == RGUI_SETTINGS_CONFIG || type == RGUI_SETTINGS_DISK_APPEND) && action == RGUI_ACTION_OK)
{
rgui_list_push(rgui->menu_stack, label, type, rgui->selection_ptr);
rgui->selection_ptr = 0;
@ -2467,7 +2496,9 @@ static int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
#ifdef HAVE_OVERLAY
menu_type == RGUI_SETTINGS_OVERLAY_PRESET ||
#endif
menu_type == RGUI_SETTINGS_CORE || menu_type == RGUI_SETTINGS_DISK_APPEND ||
menu_type == RGUI_SETTINGS_CORE ||
menu_type == RGUI_SETTINGS_CONFIG ||
menu_type == RGUI_SETTINGS_DISK_APPEND ||
menu_type == RGUI_SETTINGS_OPEN_HISTORY))
{
rgui->need_refresh = false;
@ -2580,6 +2611,8 @@ static bool directory_parse(rgui_handle_t *rgui, const char *directory, unsigned
char ext_buf[1024];
if (menu_type == RGUI_SETTINGS_CORE)
exts = EXT_EXECUTABLES;
else if (menu_type == RGUI_SETTINGS_CONFIG)
exts = "cfg";
#ifdef HAVE_SHADER_MANAGER
else if (menu_type == RGUI_SETTINGS_SHADER_PRESET)
exts = "cgp|glslp";
@ -2727,6 +2760,7 @@ static int rgui_iterate(void *data, unsigned action)
type == RGUI_SETTINGS_OVERLAY_PRESET ||
#endif
type == RGUI_SETTINGS_CORE ||
type == RGUI_SETTINGS_CONFIG ||
type == RGUI_SETTINGS_DISK_APPEND ||
type == RGUI_FILE_DIRECTORY)
{
@ -2792,6 +2826,18 @@ static int rgui_iterate(void *data, unsigned action)
rgui_flush_menu_stack(rgui);
}
else if (menu_type == RGUI_SETTINGS_CONFIG)
{
char config[PATH_MAX];
fill_pathname_join(config, dir, path, sizeof(config));
rgui_flush_menu_stack(rgui);
rgui->msg_force = true;
if (menu_replace_config(config))
{
rgui->selection_ptr = 0; // Menu can shrink.
ret = -1;
}
}
#ifdef HAVE_OVERLAY
else if (menu_type == RGUI_SETTINGS_OVERLAY_PRESET)
{
@ -2856,7 +2902,12 @@ static int rgui_iterate(void *data, unsigned action)
#ifdef HAVE_DYNAMIC
else if (menu_type == RGUI_LIBRETRO_DIR_PATH)
{
strlcpy(rgui->libretro_dir, dir, sizeof(g_extern.savestate_dir));
strlcpy(rgui->libretro_dir, dir, sizeof(rgui->libretro_dir));
rgui_flush_menu_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS);
}
else if (menu_type == RGUI_CONFIG_DIR_PATH)
{
strlcpy(g_settings.rgui_config_directory, dir, sizeof(g_settings.rgui_config_directory));
rgui_flush_menu_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS);
}
#endif
@ -2908,6 +2959,7 @@ static int rgui_iterate(void *data, unsigned action)
menu_type == RGUI_SETTINGS_OVERLAY_PRESET ||
#endif
menu_type == RGUI_SETTINGS_CORE ||
menu_type == RGUI_SETTINGS_CONFIG ||
menu_type == RGUI_SETTINGS_OPEN_HISTORY ||
menu_type == RGUI_SETTINGS_DISK_APPEND))
{

View File

@ -286,6 +286,7 @@ struct settings
#if defined(HAVE_RGUI) || defined(HAVE_RMENU)
char rgui_browser_directory[PATH_MAX];
char rgui_config_directory[PATH_MAX];
#endif
};

View File

@ -43,6 +43,9 @@
# Sets start directory for RGUI ROM browser.
# rgui_browser_directory =
# Sets start directory for RGUI config browser.
# rgui_config_directory =
# Flushes config to disk on exit. Useful for RGUI as settings can be modified.
# Overwrites the config. #include's and comments are not preserved.
# config_save_on_exit = false

View File

@ -244,6 +244,7 @@ void config_set_defaults(void)
g_settings.input.autoconf_binds[i][j].joyaxis = AXIS_NONE;
}
}
memset(g_settings.input.autoconfigured, 0, sizeof(g_settings.input.autoconfigured));
// Verify that binds are in proper order.
for (int i = 0; i < MAX_PLAYERS; i++)
@ -275,6 +276,24 @@ void config_set_defaults(void)
g_extern.console.screen.viewports.custom_vp.x = 0;
g_extern.console.screen.viewports.custom_vp.y = 0;
// Make sure settings from other configs carry over into defaults for another config.
if (!g_extern.has_set_save_path)
*g_extern.savefile_dir = '\0';
if (!g_extern.has_set_state_path)
*g_extern.savestate_dir = '\0';
*g_settings.core_options_path = '\0';
*g_settings.game_history_path = '\0';
*g_settings.cheat_database = '\0';
*g_settings.cheat_settings_path = '\0';
*g_settings.screenshot_directory = '\0';
*g_settings.system_directory = '\0';
*g_settings.input.autoconfig_dir = '\0';
*g_settings.input.overlay = '\0';
#if defined(HAVE_RGUI) || defined(HAVE_RMENU)
*g_settings.rgui_browser_directory = '\0';
*g_settings.rgui_config_directory = '\0';
#endif
#ifdef RARCH_CONSOLE
g_extern.lifecycle_mode_state |= ((1ULL << MODE_INFO_DRAW) | (1ULL << MODE_MENU));
@ -684,6 +703,9 @@ bool config_load_file(const char *path)
CONFIG_GET_PATH(rgui_browser_directory, "rgui_browser_directory");
if (!strcmp(g_settings.rgui_browser_directory, "default"))
*g_settings.rgui_browser_directory = '\0';
CONFIG_GET_PATH(rgui_config_directory, "rgui_config_directory");
if (!strcmp(g_settings.rgui_config_directory, "default"))
*g_settings.rgui_config_directory = '\0';
#endif
#ifdef HAVE_OVERLAY
@ -1001,6 +1023,7 @@ bool config_save_file(const char *path)
config_set_bool(conf, "video_scale_integer", g_settings.video.scale_integer);
config_set_bool(conf, "video_smooth", g_settings.video.smooth);
config_set_float(conf, "video_refresh_rate", g_settings.video.refresh_rate);
config_set_string(conf, "video_driver", g_settings.video.driver);
config_set_bool(conf, "video_vsync", g_settings.video.vsync);
config_set_bool(conf, "video_hard_sync", g_settings.video.hard_sync);
config_set_int(conf, "video_hard_sync_frames", g_settings.video.hard_sync_frames);
@ -1013,40 +1036,26 @@ bool config_save_file(const char *path)
config_set_string(conf, "audio_device", g_settings.audio.device);
config_set_bool(conf, "audio_rate_control", g_settings.audio.rate_control);
config_set_float(conf, "audio_rate_control_delta", g_settings.audio.rate_control_delta);
config_set_string(conf, "audio_driver", g_settings.audio.driver);
config_set_string(conf, "audio_device", g_settings.audio.device);
config_set_int(conf, "audio_out_rate", g_settings.audio.out_rate);
if (*g_settings.system_directory)
config_set_string(conf, "system_directory", g_settings.system_directory);
else
config_set_string(conf, "system_directory", "default");
if (*g_extern.savefile_dir)
config_set_string(conf, "savefile_directory", g_extern.savefile_dir);
else
config_set_string(conf, "savefile_directory", "default");
if (*g_extern.savestate_dir)
config_set_string(conf, "savestate_directory", g_extern.savestate_dir);
else
config_set_string(conf, "savestate_directory", "default");
if (*g_settings.video.shader_dir)
config_set_string(conf, "video_shader_dir", g_settings.video.shader_dir);
else
config_set_string(conf, "video_shader_dir", "default");
config_set_string(conf, "system_directory", *g_settings.system_directory ? g_settings.system_directory : "default");
config_set_string(conf, "savefile_directory", *g_extern.savefile_dir ? g_extern.savefile_dir : "default");
config_set_string(conf, "savestate_directory", *g_extern.savestate_dir ? g_extern.savestate_dir : "default");
config_set_string(conf, "video_shader_dir", *g_settings.video.shader_dir ? g_settings.video.shader_dir : "default");
#if defined(HAVE_RGUI) || defined(HAVE_RMENU)
if (*g_settings.rgui_browser_directory)
config_set_string(conf, "rgui_browser_directory", g_settings.rgui_browser_directory);
else
config_set_string(conf, "rgui_browser_directory", "default");
config_set_string(conf, "rgui_browser_directory", *g_settings.rgui_browser_directory ? g_settings.rgui_browser_directory : "default");
config_set_string(conf, "rgui_config_directory", *g_settings.rgui_config_directory ? g_settings.rgui_config_directory : "default");
#endif
config_set_string(conf, "game_history_path", g_settings.game_history_path);
config_set_int(conf, "game_history_size", g_settings.game_history_size);
config_set_string(conf, "joypad_autoconfig_dir", g_settings.input.autoconfig_dir);
#ifdef HAVE_OVERLAY
if (*g_extern.overlay_dir)
config_set_string(conf, "overlay_directory", g_extern.overlay_dir);
else
config_set_string(conf, "overlay_directory", "default");
config_set_string(conf, "overlay_directory", *g_extern.overlay_dir ? g_extern.overlay_dir : "default");
config_set_string(conf, "input_overlay", g_settings.input.overlay);
config_set_float(conf, "input_overlay_opacity", g_settings.input.overlay_opacity);
config_set_float(conf, "input_overlay_scale", g_settings.input.overlay_scale);
@ -1064,25 +1073,10 @@ bool config_save_file(const char *path)
#ifdef _XBOX1
config_set_int(conf, "sound_volume_level", g_extern.console.sound.volume_level);
#endif
if (g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE))
config_set_bool(conf, "triple_buffering_enable", true);
else
config_set_bool(conf, "triple_buffering_enable", false);
if (g_extern.lifecycle_mode_state & (1ULL << MODE_INFO_DRAW))
config_set_bool(conf, "info_msg_enable", true);
else
config_set_bool(conf, "info_msg_enable", false);
if (g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_SOFT_FILTER_ENABLE))
config_set_bool(conf, "soft_filter_enable", true);
else
config_set_bool(conf, "soft_filter_enable", false);
if (g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_FLICKER_FILTER_ENABLE))
config_set_bool(conf, "flicker_filter_enable", true);
else
config_set_bool(conf, "flicker_filter_enable", false);
config_set_bool(conf, "triple_buffering_enable", g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE));
config_set_bool(conf, "info_msg_enable", g_extern.lifecycle_mode_state & (1ULL << MODE_INFO_DRAW));
config_set_bool(conf, "soft_filter_enable", g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_SOFT_FILTER_ENABLE));
config_set_bool(conf, "flicker_filter_enable", g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_FLICKER_FILTER_ENABLE));
config_set_int(conf, "flicker_filter_index", g_extern.console.screen.flicker_filter_index);
config_set_int(conf, "soft_filter_index", g_extern.console.screen.soft_filter_index);
@ -1101,12 +1095,10 @@ bool config_save_file(const char *path)
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);
config_set_bool(conf, "custom_bgm_enable", g_extern.lifecycle_mode_state & (1ULL << MODE_AUDIO_CUSTOM_BGM_ENABLE));
if (g_extern.lifecycle_mode_state & (1ULL << MODE_AUDIO_CUSTOM_BGM_ENABLE))
config_set_bool(conf, "custom_bgm_enable", true);
else
config_set_bool(conf, "custom_bgm_enable", false);
config_set_string(conf, "input_driver", g_settings.input.driver);
config_set_string(conf, "input_joypad_driver", g_settings.input.joypad_driver);
for (unsigned i = 0; i < MAX_PLAYERS; i++)
{
char cfg[64];
@ -1120,10 +1112,9 @@ bool config_save_file(const char *path)
config_set_int(conf, cfg, g_settings.input.libretro_device[i]);
}
config_file_write(conf, path);
bool ret = config_file_write(conf, path);
config_file_free(conf);
return true;
return ret;
}
bool config_save_keybinds(const char *path)