From 0f3ea88f86f5ed906ff1806511fa6fcf72bdb6ca Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 25 Aug 2016 00:33:23 -0500 Subject: [PATCH 01/17] (ovr) allow loading settings in an alternate variable --- configuration.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/configuration.c b/configuration.c index 2dd44d40db..ec2436c674 100644 --- a/configuration.c +++ b/configuration.c @@ -1283,7 +1283,8 @@ static void config_get_hex_base(config_file_t *conf, const char *key, unsigned * * Loads a config file and reads all the values into memory. * */ -static bool config_load_file(const char *path, bool set_defaults) +static bool config_load_file(const char *path, bool set_defaults, + settings_t *settings) { unsigned i; bool tmp_bool = false; @@ -1293,7 +1294,8 @@ static bool config_load_file(const char *path, bool set_defaults) char tmp_append_path[PATH_MAX_LENGTH] = {0}; /* Don't destroy append_config_path. */ unsigned msg_color = 0; config_file_t *conf = NULL; - settings_t *settings = config_get_ptr(); + if (!settings) + settings = config_get_ptr(); global_t *global = global_get_ptr(); struct config_bool_setting_ptr bool_settings[] = { @@ -2208,7 +2210,7 @@ bool config_load_override(void) retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH); retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH); - if (!config_load_file(global->path.config, false)) + if (!config_load_file(global->path.config, false, config_get_ptr())) return false; /* Restore the libretro_path we're using @@ -2244,7 +2246,7 @@ bool config_unload_override(void) retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH); retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH); - if (config_load_file(global->path.config, false)) + if (config_load_file(global->path.config, false, config_get_ptr())) { RARCH_LOG("Overrides: configuration overrides unloaded, original configuration restored.\n"); @@ -2498,7 +2500,7 @@ static void parse_config_file(void) { global_t *global = global_get_ptr(); bool ret = config_load_file((*global->path.config) - ? global->path.config : NULL, false); + ? global->path.config : NULL, false, config_get_ptr()); if (!string_is_empty(global->path.config)) { From 1fbeebf8a9d18c0d416262a5af7e8b2c83733aa4 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 25 Aug 2016 00:54:39 -0500 Subject: [PATCH 02/17] (ovr) add menu items --- command.c | 10 ++++++++-- command.h | 1 + intl/msg_hash_us.c | 4 ++++ menu/menu_displaylist.c | 3 +++ menu/menu_setting.c | 10 ++++++++++ msg_hash.h | 2 ++ 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/command.c b/command.c index 7989a0c466..e859ff59f2 100644 --- a/command.c +++ b/command.c @@ -1567,8 +1567,11 @@ static bool command_event_save_core_config(void) * Saves current configuration file to disk, and (optionally) * autosave state. **/ -void command_event_save_current_config(void) +void command_event_save_current_config(bool overrides) { + if (overrides) + return; + settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); @@ -2304,7 +2307,10 @@ bool command_event(enum event_command cmd, void *data) return false; break; case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG: - command_event_save_current_config(); + command_event_save_current_config(false); + break; + case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE: + command_event_save_current_config(true); break; case CMD_EVENT_MENU_SAVE_CONFIG: if (!command_event_save_core_config()) diff --git a/command.h b/command.h index 5e64daa059..5e90d7f5fb 100644 --- a/command.h +++ b/command.h @@ -141,6 +141,7 @@ enum event_command CMD_EVENT_PAUSE, CMD_EVENT_PAUSE_CHECKS, CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, + CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE, CMD_EVENT_MENU_SAVE_CONFIG, CMD_EVENT_MENU_PAUSE_LIBRETRO, /* Toggles menu on/off. */ diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index b033b77eea..9727242ee8 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -2064,6 +2064,8 @@ static const char *menu_hash_to_str_us_label_enum(enum msg_hash_enums msg) return "input_small_keyboard_enable"; case MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG: return "save_current_config"; + case MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE: + return "save_current_config_override"; case MENU_ENUM_LABEL_STATE_SLOT: return "state_slot"; case MENU_ENUM_LABEL_CHEEVOS_USERNAME: @@ -3439,6 +3441,8 @@ const char *msg_hash_to_str_us(enum msg_hash_enums msg) return "Keyboard Gamepad Mapping Type"; case MENU_ENUM_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE: return "Small Keyboard Enable"; + case MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE: + return "Save Core Overrides"; case MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG: return "Save Current Config"; case MENU_ENUM_LABEL_VALUE_STATE_SLOT: diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 44694a3f77..8334080ae4 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4373,6 +4373,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG, PARSE_ACTION, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE, + PARSE_ACTION, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_SAVE_NEW_CONFIG, PARSE_ACTION, false); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 8a00217868..d20c54608f 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4163,6 +4163,16 @@ static bool setting_append_list( menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_MENU_SAVE_CONFIG); menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_SAVE_NEW_CONFIG); + CONFIG_ACTION( + list, list_info, + msg_hash_to_str(MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE), + &group_info, + &subgroup_info, + parent_group); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE); + menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE); + CONFIG_ACTION( list, list_info, msg_hash_to_str(MENU_ENUM_LABEL_HELP_LIST), diff --git a/msg_hash.h b/msg_hash.h index 68d3a669e9..4c0dbf3e7d 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1773,7 +1773,9 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_HELP_SCANNING_CONTENT_DESC, MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG, + MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE, MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG, + MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE, MENU_ENUM_LABEL_VALUE_THUMBNAIL_MODE_SCREENSHOTS, MENU_ENUM_LABEL_VALUE_THUMBNAIL_MODE_TITLE_SCREENS, From c6c054bad128ed8ae34f96974189853d5340a1a0 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 25 Aug 2016 01:34:51 -0500 Subject: [PATCH 03/17] (ovr) start implementing diff function --- command.c | 69 ++++++++++++++++++++++++++++--------------------- configuration.c | 32 +++++++++++++++++++++-- configuration.h | 10 +++++++ 3 files changed, 79 insertions(+), 32 deletions(-) diff --git a/command.c b/command.c index e859ff59f2..e2029b5c6c 100644 --- a/command.c +++ b/command.c @@ -1569,43 +1569,52 @@ static bool command_event_save_core_config(void) **/ void command_event_save_current_config(bool overrides) { - if (overrides) - return; - settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - if (settings->config_save_on_exit && !string_is_empty(global->path.config)) + if (!overrides) + { + + if (settings->config_save_on_exit && !string_is_empty(global->path.config)) + { + bool ret = false; + char msg[128] = {0}; + const char *config_path = config_get_active_path(); + + /* Save last core-specific config to the default config location, + * needed on consoles for core switching and reusing last good + * config for new cores. + */ + + /* Flush out the core specific config. */ + if (config_path) + ret = config_save_file(config_path); + + if (ret) + { + snprintf(msg, sizeof(msg), "%s \"%s\".", + msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO), + global->path.config); + RARCH_LOG("%s\n", msg); + } + else + { + snprintf(msg, sizeof(msg), "%s \"%s\".", + msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO), + global->path.config); + RARCH_ERR("%s\n", msg); + } + + runloop_msg_queue_push(msg, 1, 180, true); + } + } + else { bool ret = false; char msg[128] = {0}; - const char *config_path = config_get_active_path(); - /* Save last core-specific config to the default config location, - * needed on consoles for core switching and reusing last good - * config for new cores. - */ - - /* Flush out the core specific config. */ - if (config_path) - ret = config_save_file(config_path); - - if (ret) - { - snprintf(msg, sizeof(msg), "%s \"%s\".", - msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO), - global->path.config); - RARCH_LOG("%s\n", msg); - } - else - { - snprintf(msg, sizeof(msg), "%s \"%s\".", - msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO), - global->path.config); - RARCH_ERR("%s\n", msg); - } - - runloop_msg_queue_push(msg, 1, 180, true); + ret = config_save_file_diff(); + return; } } diff --git a/configuration.c b/configuration.c index ec2436c674..bc88ab4648 100644 --- a/configuration.c +++ b/configuration.c @@ -1294,9 +1294,10 @@ static bool config_load_file(const char *path, bool set_defaults, char tmp_append_path[PATH_MAX_LENGTH] = {0}; /* Don't destroy append_config_path. */ unsigned msg_color = 0; config_file_t *conf = NULL; + global_t *global = global_get_ptr(); + if (!settings) settings = config_get_ptr(); - global_t *global = global_get_ptr(); struct config_bool_setting_ptr bool_settings[] = { { "video_windowed_fullscreen", &settings->video.windowed_fullscreen}, @@ -2221,7 +2222,7 @@ bool config_load_override(void) /* Reset save paths. */ retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH); retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH); - + global->path.append_config[0] = '\0'; return true; } @@ -3314,6 +3315,33 @@ bool config_save_file(const char *path) return ret; } +/** + * config_save_file: + * @path : Path that shall be written to. + * + * Writes a config file to disk. + * + * Returns: true (1) on success, otherwise returns false (0). + **/ +bool config_save_file_diff() +{ + unsigned i = 0; + bool ret = false; + settings_t *settings = config_get_ptr(); + settings_t *orig = (settings_t*)calloc(1, sizeof(settings_t)); + global_t *global = global_get_ptr(); + + /* Load the original config file in memory */ + config_load_file(global->path.config, false, orig); + + /* Test to compare with a well known setting */ + /*RARCH_LOG ("Rewind: %d %d\n", settings->rewind_enable, orig->rewind_enable); + RARCH_LOG ("DBG: %d %d\n", settings->debug_panel_enable, orig->cheevos.enable); + RARCH_LOG ("FPS: %d %d\n", settings->fps_show, orig->fps_show); + RARCH_LOG ("FPS: %s %s\n", settings->username, orig->username);*/ + return false; +} + /* Replaces currently loaded configuration file with * another one. Will load a dummy core to flush state * properly. */ diff --git a/configuration.h b/configuration.h index b75c773f6e..8ef4948ce1 100644 --- a/configuration.h +++ b/configuration.h @@ -653,6 +653,16 @@ bool config_save_autoconf_profile(const char *path, unsigned user); **/ bool config_save_file(const char *path); +/** + * config_save_file_diff: + * @path : Path that shall be written to. + * + * Writes a config file override to disk. + * + * Returns: true (1) on success, otherwise returns false (0). + **/ +bool config_save_file_diff(); + /* Replaces currently loaded configuration file with * another one. Will load a dummy core to flush state * properly. */ From 3cbb03349f774588a4f3a8a4bc69068532927634 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 25 Aug 2016 10:30:30 -0500 Subject: [PATCH 04/17] (ovr) implement bool settings --- configuration.c | 247 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 242 insertions(+), 5 deletions(-) diff --git a/configuration.c b/configuration.c index bc88ab4648..5573e6191e 100644 --- a/configuration.c +++ b/configuration.c @@ -3334,11 +3334,248 @@ bool config_save_file_diff() /* Load the original config file in memory */ config_load_file(global->path.config, false, orig); - /* Test to compare with a well known setting */ - /*RARCH_LOG ("Rewind: %d %d\n", settings->rewind_enable, orig->rewind_enable); - RARCH_LOG ("DBG: %d %d\n", settings->debug_panel_enable, orig->cheevos.enable); - RARCH_LOG ("FPS: %d %d\n", settings->fps_show, orig->fps_show); - RARCH_LOG ("FPS: %s %s\n", settings->username, orig->username);*/ + struct config_bool_setting bool_settings[] = { + { "ui_companion_start_on_boot", settings->ui.companion_start_on_boot}, + { "ui_companion_enable", settings->ui.companion_enable}, + { "video_gpu_record", settings->video.gpu_record}, + { "input_remap_binds_enable", settings->input.remap_binds_enable}, + { "back_as_menu_toggle_enable", settings->input.back_as_menu_toggle_enable}, + { "netplay_client_swap_input", settings->input.netplay_client_swap_input}, + { "input_descriptor_label_show", settings->input.input_descriptor_label_show}, + { "input_descriptor_hide_unbound",settings->input.input_descriptor_hide_unbound}, + { "load_dummy_on_core_shutdown", settings->load_dummy_on_core_shutdown}, + { "builtin_mediaplayer_enable", settings->multimedia.builtin_mediaplayer_enable}, + { "builtin_imageviewer_enable", settings->multimedia.builtin_imageviewer_enable}, + { "fps_show", settings->fps_show}, + { "ui_menubar_enable", settings->ui.menubar_enable}, + { "suspend_screensaver_enable", settings->ui.suspend_screensaver_enable}, + { "rewind_enable", settings->rewind_enable}, + { "audio_sync", settings->audio.sync}, + { "video_shader_enable", settings->video.shader_enable}, + { "video_aspect_ratio_auto", settings->video.aspect_ratio_auto}, + { "video_windowed_fullscreen", settings->video.windowed_fullscreen}, + { "video_crop_overscan", settings->video.crop_overscan}, + { "video_scale_integer", settings->video.scale_integer}, + { "video_smooth", settings->video.smooth}, + { "video_threaded", settings->video.threaded}, + { "video_shared_context", settings->video.shared_context}, + { "custom_bgm_enable", global->console.sound.system_bgm_enable}, + { "auto_screenshot_filename", settings->auto_screenshot_filename}, + { "video_force_srgb_disable", settings->video.force_srgb_disable}, + { "video_fullscreen", settings->video.fullscreen}, + { "bundle_assets_extract_enable", settings->bundle_assets_extract_enable}, + { "video_vsync", settings->video.vsync}, + { "video_hard_sync", settings->video.hard_sync}, + { "video_black_frame_insertion", settings->video.black_frame_insertion}, + { "video_disable_composition", settings->video.disable_composition}, + { "pause_nonactive", settings->pause_nonactive}, + { "video_gpu_screenshot", settings->video.gpu_screenshot}, + { "keyboard_gamepad_enable", settings->input.keyboard_gamepad_enable}, + { "core_set_supports_no_game_enable", settings->set_supports_no_game_enable}, + { "audio_enable", settings->audio.enable}, + { "audio_mute_enable", settings->audio.mute_enable}, + { "location_allow", settings->location.allow}, + { "video_font_enable", settings->video.font_enable}, + { "core_updater_auto_extract_archive", settings->network.buildbot_auto_extract_archive}, + { "camera_allow", settings->camera.allow}, +#if TARGET_OS_IPHONE + { "small_keyboard_enable", settings->input.small_keyboard_enable}, +#endif +#ifdef GEKKO + { "video_vfilter", settings->video.vfilter}, +#endif +#ifdef HAVE_MENU +#ifdef HAVE_THREADS + { "threaded_data_runloop_enable", settings->threaded_data_runloop_enable}, +#endif + { "menu_throttle_framerate", settings->menu.throttle_framerate}, + { "menu_linear_filter", settings->menu.linear_filter}, + { "dpi_override_enable", settings->menu.dpi.override_enable}, + { "menu_pause_libretro", settings->menu.pause_libretro}, + { "menu_mouse_enable", settings->menu.mouse.enable}, + { "menu_pointer_enable", settings->menu.pointer.enable}, + { "menu_timedate_enable", settings->menu.timedate_enable}, + { "menu_core_enable", settings->menu.core_enable}, + { "menu_dynamic_wallpaper_enable",settings->menu.dynamic_wallpaper_enable}, + { "xmb_shadows_enable", settings->menu.xmb.shadows_enable}, + { "xmb_show_settings", settings->menu.xmb.show_settings}, +#ifdef HAVE_IMAGEVIEWER + { "xmb_show_images", settings->menu.xmb.show_images}, +#endif +#ifdef HAVE_FFMPEG + { "xmb_show_music", settings->menu.xmb.show_music}, + { "xmb_show_video", settings->menu.xmb.show_video}, +#endif + { "xmb_show_history", settings->menu.xmb.show_history}, + { "rgui_show_start_screen", settings->menu_show_start_screen}, + { "menu_navigation_wraparound_enable", settings->menu.navigation.wraparound.enable}, + { "menu_navigation_browser_filter_supported_extensions_enable", + settings->menu.navigation.browser.filter.supported_extensions_enable}, + { "menu_show_advanced_settings", settings->menu.show_advanced_settings}, +#endif +#ifdef HAVE_CHEEVOS + { "cheevos_enable", settings->cheevos.enable}, + { "cheevos_test_unofficial", settings->cheevos.test_unofficial}, + { "cheevos_hardcore_mode_enable", settings->cheevos.hardcore_mode_enable}, +#endif +#ifdef HAVE_OVERLAY + { "input_overlay_enable", settings->input.overlay_enable}, + { "input_overlay_enable_autopreferred", settings->input.overlay_enable_autopreferred}, + { "input_overlay_hide_in_menu", settings->input.overlay_hide_in_menu}, + { "input_osk_overlay_enable", settings->osk.enable}, +#endif +#ifdef HAVE_COMMAND + { "network_cmd_enable", settings->network_cmd_enable}, + { "stdin_cmd_enable", settings->stdin_cmd_enable}, +#endif +#ifdef HAVE_NETWORKGAMEPAD + { "network_remote_enable", settings->network_remote_enable}, +#endif +#ifdef HAVE_NETPLAY + { "netplay_spectator_mode_enable",global->netplay.is_spectate}, + { "netplay_mode", global->netplay.is_client}, +#endif + { "block_sram_overwrite", settings->block_sram_overwrite}, + { "savestate_auto_index", settings->savestate_auto_index}, + { "savestate_auto_save", settings->savestate_auto_save}, + { "savestate_auto_load", settings->savestate_auto_load}, + { "history_list_enable", settings->history_list_enable}, + { "game_specific_options", settings->game_specific_options}, + { "auto_overrides_enable", settings->auto_overrides_enable}, + { "auto_remaps_enable", settings->auto_remaps_enable}, + { "auto_shaders_enable", settings->auto_shaders_enable}, + { "sort_savefiles_enable", settings->sort_savefiles_enable}, + { "sort_savestates_enable", settings->sort_savestates_enable}, + { "config_save_on_exit", settings->config_save_on_exit}, + { "input_autodetect_enable", settings->input.autodetect_enable}, + { "audio_rate_control", settings->audio.rate_control} + }; + + struct config_bool_setting bool_overrides[] = { + { "ui_companion_start_on_boot", orig->ui.companion_start_on_boot}, + { "ui_companion_enable", orig->ui.companion_enable}, + { "video_gpu_record", orig->video.gpu_record}, + { "input_remap_binds_enable", orig->input.remap_binds_enable}, + { "back_as_menu_toggle_enable", orig->input.back_as_menu_toggle_enable}, + { "netplay_client_swap_input", orig->input.netplay_client_swap_input}, + { "input_descriptor_label_show", orig->input.input_descriptor_label_show}, + { "input_descriptor_hide_unbound",orig->input.input_descriptor_hide_unbound}, + { "load_dummy_on_core_shutdown", orig->load_dummy_on_core_shutdown}, + { "builtin_mediaplayer_enable", orig->multimedia.builtin_mediaplayer_enable}, + { "builtin_imageviewer_enable", orig->multimedia.builtin_imageviewer_enable}, + { "fps_show", orig->fps_show}, + { "ui_menubar_enable", orig->ui.menubar_enable}, + { "suspend_screensaver_enable", orig->ui.suspend_screensaver_enable}, + { "rewind_enable", orig->rewind_enable}, + { "audio_sync", orig->audio.sync}, + { "video_shader_enable", orig->video.shader_enable}, + { "video_aspect_ratio_auto", orig->video.aspect_ratio_auto}, + { "video_windowed_fullscreen", orig->video.windowed_fullscreen}, + { "video_crop_overscan", orig->video.crop_overscan}, + { "video_scale_integer", orig->video.scale_integer}, + { "video_smooth", orig->video.smooth}, + { "video_threaded", orig->video.threaded}, + { "video_shared_context", orig->video.shared_context}, + { "custom_bgm_enable", global->console.sound.system_bgm_enable}, + { "auto_screenshot_filename", orig->auto_screenshot_filename}, + { "video_force_srgb_disable", orig->video.force_srgb_disable}, + { "video_fullscreen", orig->video.fullscreen}, + { "bundle_assets_extract_enable", orig->bundle_assets_extract_enable}, + { "video_vsync", orig->video.vsync}, + { "video_hard_sync", orig->video.hard_sync}, + { "video_black_frame_insertion", orig->video.black_frame_insertion}, + { "video_disable_composition", orig->video.disable_composition}, + { "pause_nonactive", orig->pause_nonactive}, + { "video_gpu_screenshot", orig->video.gpu_screenshot}, + { "keyboard_gamepad_enable", orig->input.keyboard_gamepad_enable}, + { "core_set_supports_no_game_enable", orig->set_supports_no_game_enable}, + { "audio_enable", orig->audio.enable}, + { "audio_mute_enable", orig->audio.mute_enable}, + { "location_allow", orig->location.allow}, + { "video_font_enable", orig->video.font_enable}, + { "core_updater_auto_extract_archive", orig->network.buildbot_auto_extract_archive}, + { "camera_allow", orig->camera.allow}, +#if TARGET_OS_IPHONE + { "small_keyboard_enable", orig->input.small_keyboard_enable}, +#endif +#ifdef GEKKO + { "video_vfilter", orig->video.vfilter}, +#endif +#ifdef HAVE_MENU +#ifdef HAVE_THREADS + { "threaded_data_runloop_enable", orig->threaded_data_runloop_enable}, +#endif + { "menu_throttle_framerate", orig->menu.throttle_framerate}, + { "menu_linear_filter", orig->menu.linear_filter}, + { "dpi_override_enable", orig->menu.dpi.override_enable}, + { "menu_pause_libretro", orig->menu.pause_libretro}, + { "menu_mouse_enable", orig->menu.mouse.enable}, + { "menu_pointer_enable", orig->menu.pointer.enable}, + { "menu_timedate_enable", orig->menu.timedate_enable}, + { "menu_core_enable", orig->menu.core_enable}, + { "menu_dynamic_wallpaper_enable",orig->menu.dynamic_wallpaper_enable}, + { "xmb_shadows_enable", orig->menu.xmb.shadows_enable}, + { "xmb_show_settings", orig->menu.xmb.show_settings}, +#ifdef HAVE_IMAGEVIEWER + { "xmb_show_images", orig->menu.xmb.show_images}, +#endif +#ifdef HAVE_FFMPEG + { "xmb_show_music", orig->menu.xmb.show_music}, + { "xmb_show_video", orig->menu.xmb.show_video}, +#endif + { "xmb_show_history", orig->menu.xmb.show_history}, + { "rgui_show_start_screen", orig->menu_show_start_screen}, + { "menu_navigation_wraparound_enable", orig->menu.navigation.wraparound.enable}, + { "menu_navigation_browser_filter_supported_extensions_enable", + orig->menu.navigation.browser.filter.supported_extensions_enable}, + { "menu_show_advanced_settings", orig->menu.show_advanced_settings}, +#endif +#ifdef HAVE_CHEEVOS + { "cheevos_enable", orig->cheevos.enable}, + { "cheevos_test_unofficial", orig->cheevos.test_unofficial}, + { "cheevos_hardcore_mode_enable", orig->cheevos.hardcore_mode_enable}, +#endif +#ifdef HAVE_OVERLAY + { "input_overlay_enable", orig->input.overlay_enable}, + { "input_overlay_enable_autopreferred", orig->input.overlay_enable_autopreferred}, + { "input_overlay_hide_in_menu", orig->input.overlay_hide_in_menu}, + { "input_osk_overlay_enable", orig->osk.enable}, +#endif +#ifdef HAVE_COMMAND + { "network_cmd_enable", orig->network_cmd_enable}, + { "stdin_cmd_enable", orig->stdin_cmd_enable}, +#endif +#ifdef HAVE_NETWORKGAMEPAD + { "network_remote_enable", orig->network_remote_enable}, +#endif +#ifdef HAVE_NETPLAY + { "netplay_spectator_mode_enable",global->netplay.is_spectate}, + { "netplay_mode", global->netplay.is_client}, +#endif + { "block_sram_overwrite", orig->block_sram_overwrite}, + { "savestate_auto_index", orig->savestate_auto_index}, + { "savestate_auto_save", orig->savestate_auto_save}, + { "savestate_auto_load", orig->savestate_auto_load}, + { "history_list_enable", orig->history_list_enable}, + { "game_specific_options", orig->game_specific_options}, + { "auto_overrides_enable", orig->auto_overrides_enable}, + { "auto_remaps_enable", orig->auto_remaps_enable}, + { "auto_shaders_enable", orig->auto_shaders_enable}, + { "sort_savefiles_enable", orig->sort_savefiles_enable}, + { "sort_savestates_enable", orig->sort_savestates_enable}, + { "config_save_on_exit", orig->config_save_on_exit}, + { "input_autodetect_enable", orig->input.autodetect_enable}, + { "audio_rate_control", orig->audio.rate_control} + }; + + for (i = 0; i < ARRAY_SIZE(bool_settings); i++) + { + if (bool_settings[i].value != bool_overrides[i].value) + RARCH_LOG("Oerrides:\n Original value: %s=%d\n Override value: %s=%d\n", + bool_settings[i].ident, bool_settings[i].value, + bool_overrides[i].ident, bool_overrides[i].value); + } + return false; } From 1a933bf7d33d44fd26a07338520727f473e517ea Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 25 Aug 2016 19:00:06 -0500 Subject: [PATCH 05/17] (ovr) reimplement bool_settings --- configuration.c | 309 ++++++++---------------------------------------- 1 file changed, 51 insertions(+), 258 deletions(-) diff --git a/configuration.c b/configuration.c index 5573e6191e..7260cc0fb6 100644 --- a/configuration.c +++ b/configuration.c @@ -2805,24 +2805,10 @@ bool config_save_autoconf_profile(const char *path, unsigned user) return ret; } - -/** - * config_save_file: - * @path : Path that shall be written to. - * - * Writes a config file to disk. - * - * Returns: true (1) on success, otherwise returns false (0). - **/ -bool config_save_file(const char *path) +int populate_settings_bool(settings_t *settings, struct config_bool_setting *out) { - float msg_color; - unsigned i = 0; - bool ret = false; - config_file_t *conf = config_file_new(path); - settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - struct config_bool_setting bool_settings[] = { + struct config_bool_setting tmp[] = { { "ui_companion_start_on_boot", settings->ui.companion_start_on_boot}, { "ui_companion_enable", settings->ui.companion_enable}, { "video_gpu_record", settings->video.gpu_record}, @@ -2936,8 +2922,35 @@ bool config_save_file(const char *path) { "sort_savestates_enable", settings->sort_savestates_enable}, { "config_save_on_exit", settings->config_save_on_exit}, { "input_autodetect_enable", settings->input.autodetect_enable}, - { "audio_rate_control", settings->audio.rate_control}, + { "audio_rate_control", settings->audio.rate_control} }; + + memcpy(out, tmp, sizeof(tmp)); + return ARRAY_SIZE(tmp); +} + +/** + * config_save_file: + * @path : Path that shall be written to. + * + * Writes a config file to disk. + * + * Returns: true (1) on success, otherwise returns false (0). + **/ +bool config_save_file(const char *path) +{ + float msg_color; + unsigned i = 0; + bool ret = false; + config_file_t *conf = config_file_new(path); + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + struct config_bool_setting *bool_settings = + (struct config_bool_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_bool_setting)); + int bool_settings_size = 0; + + bool_settings_size = populate_settings_bool (settings, bool_settings); + struct config_int_setting int_settings[] = { { "input_bind_timeout", settings->input.bind_timeout}, { "input_turbo_period", settings->input.turbo_period}, @@ -3246,7 +3259,7 @@ bool config_save_file(const char *path) * */ - for (i = 0; i < ARRAY_SIZE(bool_settings); i++) + for (i = 0; i < bool_settings_size; i++) { config_set_bool(conf, bool_settings[i].ident, bool_settings[i].value); @@ -3312,6 +3325,8 @@ bool config_save_file(const char *path) ret = config_file_write(conf, path); config_file_free(conf); + + free (bool_settings); return ret; } @@ -3327,253 +3342,31 @@ bool config_save_file_diff() { unsigned i = 0; bool ret = false; - settings_t *settings = config_get_ptr(); - settings_t *orig = (settings_t*)calloc(1, sizeof(settings_t)); global_t *global = global_get_ptr(); + settings_t *overrides = config_get_ptr(); + settings_t *settings = (settings_t*)calloc(1, sizeof(settings_t)); + + struct config_bool_setting *bool_settings = (struct config_bool_setting*)malloc (255*sizeof(struct config_bool_setting));; + struct config_bool_setting *bool_overrides = (struct config_bool_setting*)malloc (255*sizeof(struct config_bool_setting));; + int bool_settings_size = 0; + /* Load the original config file in memory */ - config_load_file(global->path.config, false, orig); + config_load_file(global->path.config, false, settings); - struct config_bool_setting bool_settings[] = { - { "ui_companion_start_on_boot", settings->ui.companion_start_on_boot}, - { "ui_companion_enable", settings->ui.companion_enable}, - { "video_gpu_record", settings->video.gpu_record}, - { "input_remap_binds_enable", settings->input.remap_binds_enable}, - { "back_as_menu_toggle_enable", settings->input.back_as_menu_toggle_enable}, - { "netplay_client_swap_input", settings->input.netplay_client_swap_input}, - { "input_descriptor_label_show", settings->input.input_descriptor_label_show}, - { "input_descriptor_hide_unbound",settings->input.input_descriptor_hide_unbound}, - { "load_dummy_on_core_shutdown", settings->load_dummy_on_core_shutdown}, - { "builtin_mediaplayer_enable", settings->multimedia.builtin_mediaplayer_enable}, - { "builtin_imageviewer_enable", settings->multimedia.builtin_imageviewer_enable}, - { "fps_show", settings->fps_show}, - { "ui_menubar_enable", settings->ui.menubar_enable}, - { "suspend_screensaver_enable", settings->ui.suspend_screensaver_enable}, - { "rewind_enable", settings->rewind_enable}, - { "audio_sync", settings->audio.sync}, - { "video_shader_enable", settings->video.shader_enable}, - { "video_aspect_ratio_auto", settings->video.aspect_ratio_auto}, - { "video_windowed_fullscreen", settings->video.windowed_fullscreen}, - { "video_crop_overscan", settings->video.crop_overscan}, - { "video_scale_integer", settings->video.scale_integer}, - { "video_smooth", settings->video.smooth}, - { "video_threaded", settings->video.threaded}, - { "video_shared_context", settings->video.shared_context}, - { "custom_bgm_enable", global->console.sound.system_bgm_enable}, - { "auto_screenshot_filename", settings->auto_screenshot_filename}, - { "video_force_srgb_disable", settings->video.force_srgb_disable}, - { "video_fullscreen", settings->video.fullscreen}, - { "bundle_assets_extract_enable", settings->bundle_assets_extract_enable}, - { "video_vsync", settings->video.vsync}, - { "video_hard_sync", settings->video.hard_sync}, - { "video_black_frame_insertion", settings->video.black_frame_insertion}, - { "video_disable_composition", settings->video.disable_composition}, - { "pause_nonactive", settings->pause_nonactive}, - { "video_gpu_screenshot", settings->video.gpu_screenshot}, - { "keyboard_gamepad_enable", settings->input.keyboard_gamepad_enable}, - { "core_set_supports_no_game_enable", settings->set_supports_no_game_enable}, - { "audio_enable", settings->audio.enable}, - { "audio_mute_enable", settings->audio.mute_enable}, - { "location_allow", settings->location.allow}, - { "video_font_enable", settings->video.font_enable}, - { "core_updater_auto_extract_archive", settings->network.buildbot_auto_extract_archive}, - { "camera_allow", settings->camera.allow}, -#if TARGET_OS_IPHONE - { "small_keyboard_enable", settings->input.small_keyboard_enable}, -#endif -#ifdef GEKKO - { "video_vfilter", settings->video.vfilter}, -#endif -#ifdef HAVE_MENU -#ifdef HAVE_THREADS - { "threaded_data_runloop_enable", settings->threaded_data_runloop_enable}, -#endif - { "menu_throttle_framerate", settings->menu.throttle_framerate}, - { "menu_linear_filter", settings->menu.linear_filter}, - { "dpi_override_enable", settings->menu.dpi.override_enable}, - { "menu_pause_libretro", settings->menu.pause_libretro}, - { "menu_mouse_enable", settings->menu.mouse.enable}, - { "menu_pointer_enable", settings->menu.pointer.enable}, - { "menu_timedate_enable", settings->menu.timedate_enable}, - { "menu_core_enable", settings->menu.core_enable}, - { "menu_dynamic_wallpaper_enable",settings->menu.dynamic_wallpaper_enable}, - { "xmb_shadows_enable", settings->menu.xmb.shadows_enable}, - { "xmb_show_settings", settings->menu.xmb.show_settings}, -#ifdef HAVE_IMAGEVIEWER - { "xmb_show_images", settings->menu.xmb.show_images}, -#endif -#ifdef HAVE_FFMPEG - { "xmb_show_music", settings->menu.xmb.show_music}, - { "xmb_show_video", settings->menu.xmb.show_video}, -#endif - { "xmb_show_history", settings->menu.xmb.show_history}, - { "rgui_show_start_screen", settings->menu_show_start_screen}, - { "menu_navigation_wraparound_enable", settings->menu.navigation.wraparound.enable}, - { "menu_navigation_browser_filter_supported_extensions_enable", - settings->menu.navigation.browser.filter.supported_extensions_enable}, - { "menu_show_advanced_settings", settings->menu.show_advanced_settings}, -#endif -#ifdef HAVE_CHEEVOS - { "cheevos_enable", settings->cheevos.enable}, - { "cheevos_test_unofficial", settings->cheevos.test_unofficial}, - { "cheevos_hardcore_mode_enable", settings->cheevos.hardcore_mode_enable}, -#endif -#ifdef HAVE_OVERLAY - { "input_overlay_enable", settings->input.overlay_enable}, - { "input_overlay_enable_autopreferred", settings->input.overlay_enable_autopreferred}, - { "input_overlay_hide_in_menu", settings->input.overlay_hide_in_menu}, - { "input_osk_overlay_enable", settings->osk.enable}, -#endif -#ifdef HAVE_COMMAND - { "network_cmd_enable", settings->network_cmd_enable}, - { "stdin_cmd_enable", settings->stdin_cmd_enable}, -#endif -#ifdef HAVE_NETWORKGAMEPAD - { "network_remote_enable", settings->network_remote_enable}, -#endif -#ifdef HAVE_NETPLAY - { "netplay_spectator_mode_enable",global->netplay.is_spectate}, - { "netplay_mode", global->netplay.is_client}, -#endif - { "block_sram_overwrite", settings->block_sram_overwrite}, - { "savestate_auto_index", settings->savestate_auto_index}, - { "savestate_auto_save", settings->savestate_auto_save}, - { "savestate_auto_load", settings->savestate_auto_load}, - { "history_list_enable", settings->history_list_enable}, - { "game_specific_options", settings->game_specific_options}, - { "auto_overrides_enable", settings->auto_overrides_enable}, - { "auto_remaps_enable", settings->auto_remaps_enable}, - { "auto_shaders_enable", settings->auto_shaders_enable}, - { "sort_savefiles_enable", settings->sort_savefiles_enable}, - { "sort_savestates_enable", settings->sort_savestates_enable}, - { "config_save_on_exit", settings->config_save_on_exit}, - { "input_autodetect_enable", settings->input.autodetect_enable}, - { "audio_rate_control", settings->audio.rate_control} - }; + bool_settings_size = populate_settings_bool (settings, bool_settings); + populate_settings_bool (overrides, bool_overrides); - struct config_bool_setting bool_overrides[] = { - { "ui_companion_start_on_boot", orig->ui.companion_start_on_boot}, - { "ui_companion_enable", orig->ui.companion_enable}, - { "video_gpu_record", orig->video.gpu_record}, - { "input_remap_binds_enable", orig->input.remap_binds_enable}, - { "back_as_menu_toggle_enable", orig->input.back_as_menu_toggle_enable}, - { "netplay_client_swap_input", orig->input.netplay_client_swap_input}, - { "input_descriptor_label_show", orig->input.input_descriptor_label_show}, - { "input_descriptor_hide_unbound",orig->input.input_descriptor_hide_unbound}, - { "load_dummy_on_core_shutdown", orig->load_dummy_on_core_shutdown}, - { "builtin_mediaplayer_enable", orig->multimedia.builtin_mediaplayer_enable}, - { "builtin_imageviewer_enable", orig->multimedia.builtin_imageviewer_enable}, - { "fps_show", orig->fps_show}, - { "ui_menubar_enable", orig->ui.menubar_enable}, - { "suspend_screensaver_enable", orig->ui.suspend_screensaver_enable}, - { "rewind_enable", orig->rewind_enable}, - { "audio_sync", orig->audio.sync}, - { "video_shader_enable", orig->video.shader_enable}, - { "video_aspect_ratio_auto", orig->video.aspect_ratio_auto}, - { "video_windowed_fullscreen", orig->video.windowed_fullscreen}, - { "video_crop_overscan", orig->video.crop_overscan}, - { "video_scale_integer", orig->video.scale_integer}, - { "video_smooth", orig->video.smooth}, - { "video_threaded", orig->video.threaded}, - { "video_shared_context", orig->video.shared_context}, - { "custom_bgm_enable", global->console.sound.system_bgm_enable}, - { "auto_screenshot_filename", orig->auto_screenshot_filename}, - { "video_force_srgb_disable", orig->video.force_srgb_disable}, - { "video_fullscreen", orig->video.fullscreen}, - { "bundle_assets_extract_enable", orig->bundle_assets_extract_enable}, - { "video_vsync", orig->video.vsync}, - { "video_hard_sync", orig->video.hard_sync}, - { "video_black_frame_insertion", orig->video.black_frame_insertion}, - { "video_disable_composition", orig->video.disable_composition}, - { "pause_nonactive", orig->pause_nonactive}, - { "video_gpu_screenshot", orig->video.gpu_screenshot}, - { "keyboard_gamepad_enable", orig->input.keyboard_gamepad_enable}, - { "core_set_supports_no_game_enable", orig->set_supports_no_game_enable}, - { "audio_enable", orig->audio.enable}, - { "audio_mute_enable", orig->audio.mute_enable}, - { "location_allow", orig->location.allow}, - { "video_font_enable", orig->video.font_enable}, - { "core_updater_auto_extract_archive", orig->network.buildbot_auto_extract_archive}, - { "camera_allow", orig->camera.allow}, -#if TARGET_OS_IPHONE - { "small_keyboard_enable", orig->input.small_keyboard_enable}, -#endif -#ifdef GEKKO - { "video_vfilter", orig->video.vfilter}, -#endif -#ifdef HAVE_MENU -#ifdef HAVE_THREADS - { "threaded_data_runloop_enable", orig->threaded_data_runloop_enable}, -#endif - { "menu_throttle_framerate", orig->menu.throttle_framerate}, - { "menu_linear_filter", orig->menu.linear_filter}, - { "dpi_override_enable", orig->menu.dpi.override_enable}, - { "menu_pause_libretro", orig->menu.pause_libretro}, - { "menu_mouse_enable", orig->menu.mouse.enable}, - { "menu_pointer_enable", orig->menu.pointer.enable}, - { "menu_timedate_enable", orig->menu.timedate_enable}, - { "menu_core_enable", orig->menu.core_enable}, - { "menu_dynamic_wallpaper_enable",orig->menu.dynamic_wallpaper_enable}, - { "xmb_shadows_enable", orig->menu.xmb.shadows_enable}, - { "xmb_show_settings", orig->menu.xmb.show_settings}, -#ifdef HAVE_IMAGEVIEWER - { "xmb_show_images", orig->menu.xmb.show_images}, -#endif -#ifdef HAVE_FFMPEG - { "xmb_show_music", orig->menu.xmb.show_music}, - { "xmb_show_video", orig->menu.xmb.show_video}, -#endif - { "xmb_show_history", orig->menu.xmb.show_history}, - { "rgui_show_start_screen", orig->menu_show_start_screen}, - { "menu_navigation_wraparound_enable", orig->menu.navigation.wraparound.enable}, - { "menu_navigation_browser_filter_supported_extensions_enable", - orig->menu.navigation.browser.filter.supported_extensions_enable}, - { "menu_show_advanced_settings", orig->menu.show_advanced_settings}, -#endif -#ifdef HAVE_CHEEVOS - { "cheevos_enable", orig->cheevos.enable}, - { "cheevos_test_unofficial", orig->cheevos.test_unofficial}, - { "cheevos_hardcore_mode_enable", orig->cheevos.hardcore_mode_enable}, -#endif -#ifdef HAVE_OVERLAY - { "input_overlay_enable", orig->input.overlay_enable}, - { "input_overlay_enable_autopreferred", orig->input.overlay_enable_autopreferred}, - { "input_overlay_hide_in_menu", orig->input.overlay_hide_in_menu}, - { "input_osk_overlay_enable", orig->osk.enable}, -#endif -#ifdef HAVE_COMMAND - { "network_cmd_enable", orig->network_cmd_enable}, - { "stdin_cmd_enable", orig->stdin_cmd_enable}, -#endif -#ifdef HAVE_NETWORKGAMEPAD - { "network_remote_enable", orig->network_remote_enable}, -#endif -#ifdef HAVE_NETPLAY - { "netplay_spectator_mode_enable",global->netplay.is_spectate}, - { "netplay_mode", global->netplay.is_client}, -#endif - { "block_sram_overwrite", orig->block_sram_overwrite}, - { "savestate_auto_index", orig->savestate_auto_index}, - { "savestate_auto_save", orig->savestate_auto_save}, - { "savestate_auto_load", orig->savestate_auto_load}, - { "history_list_enable", orig->history_list_enable}, - { "game_specific_options", orig->game_specific_options}, - { "auto_overrides_enable", orig->auto_overrides_enable}, - { "auto_remaps_enable", orig->auto_remaps_enable}, - { "auto_shaders_enable", orig->auto_shaders_enable}, - { "sort_savefiles_enable", orig->sort_savefiles_enable}, - { "sort_savestates_enable", orig->sort_savestates_enable}, - { "config_save_on_exit", orig->config_save_on_exit}, - { "input_autodetect_enable", orig->input.autodetect_enable}, - { "audio_rate_control", orig->audio.rate_control} - }; - - for (i = 0; i < ARRAY_SIZE(bool_settings); i++) + RARCH_LOG("Overrides:\n"); + for (i = 0; i < bool_settings_size; i++) { if (bool_settings[i].value != bool_overrides[i].value) - RARCH_LOG("Oerrides:\n Original value: %s=%d\n Override value: %s=%d\n", - bool_settings[i].ident, bool_settings[i].value, - bool_overrides[i].ident, bool_overrides[i].value); + { + RARCH_LOG(" original: %s=%d\n", + bool_settings[i].ident, bool_settings[i].value); + RARCH_LOG(" override: %s=%d\n", + bool_overrides[i].ident, bool_overrides[i].value); + } } return false; From 1bcaf884db461de5dee049f9db8aad517dc41423 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 25 Aug 2016 19:14:10 -0500 Subject: [PATCH 06/17] (ovr) reimplement int_settings --- configuration.c | 92 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 27 deletions(-) diff --git a/configuration.c b/configuration.c index 7260cc0fb6..a44dd4bf0f 100644 --- a/configuration.c +++ b/configuration.c @@ -2929,29 +2929,10 @@ int populate_settings_bool(settings_t *settings, struct config_bool_setting *out return ARRAY_SIZE(tmp); } -/** - * config_save_file: - * @path : Path that shall be written to. - * - * Writes a config file to disk. - * - * Returns: true (1) on success, otherwise returns false (0). - **/ -bool config_save_file(const char *path) +int populate_settings_int(settings_t *settings, struct config_int_setting *out) { - float msg_color; - unsigned i = 0; - bool ret = false; - config_file_t *conf = config_file_new(path); - settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - struct config_bool_setting *bool_settings = - (struct config_bool_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_bool_setting)); - int bool_settings_size = 0; - - bool_settings_size = populate_settings_bool (settings, bool_settings); - - struct config_int_setting int_settings[] = { + struct config_int_setting tmp[] = { { "input_bind_timeout", settings->input.bind_timeout}, { "input_turbo_period", settings->input.turbo_period}, { "input_duty_cycle", settings->input.turbo_duty_cycle}, @@ -3022,6 +3003,38 @@ bool config_save_file(const char *path) { "bundle_assets_extract_version_current", settings->bundle_assets_extract_version_current}, { "bundle_assets_extract_last_version", settings->bundle_assets_extract_last_version} }; + + memcpy(out, tmp, sizeof(tmp)); + return ARRAY_SIZE(tmp); +} + +/** + * config_save_file: + * @path : Path that shall be written to. + * + * Writes a config file to disk. + * + * Returns: true (1) on success, otherwise returns false (0). + **/ +bool config_save_file(const char *path) +{ + float msg_color; + unsigned i = 0; + bool ret = false; + config_file_t *conf = config_file_new(path); + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + struct config_bool_setting *bool_settings = + (struct config_bool_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_bool_setting)); + int bool_settings_size = 0; + + struct config_int_setting *int_settings = + (struct config_int_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_int_setting)); + int int_settings_size = 0; + + bool_settings_size = populate_settings_bool (settings, bool_settings); + int_settings_size = populate_settings_int (settings, int_settings); + struct config_float_setting float_settings[] = { { "video_aspect_ratio", settings->video.aspect_ratio}, { "video_scale", settings->video.scale}, @@ -3080,7 +3093,6 @@ bool config_save_file(const char *path) { "bundle_assets_src_path", settings->path.bundle_assets_src}, { "bundle_assets_dst_path", settings->path.bundle_assets_dst} }; - struct config_path_setting path_settings[] = { { "recording_output_directory", false, global->record.output_dir}, @@ -3234,7 +3246,7 @@ bool config_save_file(const char *path) * */ - for (i = 0; i < ARRAY_SIZE(int_settings); i++) + for (i = 0; i < int_settings_size; i++) { config_set_int(conf, int_settings[i].ident, int_settings[i].value); @@ -3327,6 +3339,7 @@ bool config_save_file(const char *path) config_file_free(conf); free (bool_settings); + free (int_settings); return ret; } @@ -3346,17 +3359,28 @@ bool config_save_file_diff() settings_t *overrides = config_get_ptr(); settings_t *settings = (settings_t*)calloc(1, sizeof(settings_t)); - struct config_bool_setting *bool_settings = (struct config_bool_setting*)malloc (255*sizeof(struct config_bool_setting));; - struct config_bool_setting *bool_overrides = (struct config_bool_setting*)malloc (255*sizeof(struct config_bool_setting));; - int bool_settings_size = 0; + struct config_bool_setting *bool_settings = + (struct config_bool_setting*) malloc(PATH_MAX_LENGTH *sizeof(struct config_bool_setting)); + struct config_bool_setting *bool_overrides = + (struct config_bool_setting*) malloc(PATH_MAX_LENGTH *sizeof(struct config_bool_setting)); + struct config_int_setting *int_settings = + (struct config_int_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_int_setting)); + struct config_int_setting *int_overrides = + (struct config_int_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_int_setting)); + + int bool_settings_size = 0; + int int_settings_size = 0; /* Load the original config file in memory */ config_load_file(global->path.config, false, settings); - bool_settings_size = populate_settings_bool (settings, bool_settings); + bool_settings_size = populate_settings_bool(settings, bool_settings); populate_settings_bool (overrides, bool_overrides); + int_settings_size = populate_settings_int(settings, int_settings); + populate_settings_int (overrides, int_overrides); + RARCH_LOG("Overrides:\n"); for (i = 0; i < bool_settings_size; i++) { @@ -3368,7 +3392,21 @@ bool config_save_file_diff() bool_overrides[i].ident, bool_overrides[i].value); } } + for (i = 0; i < int_settings_size; i++) + { + if (int_settings[i].value != int_overrides[i].value) + { + RARCH_LOG(" original: %s=%d\n", + int_settings[i].ident, int_settings[i].value); + RARCH_LOG(" override: %s=%d\n", + int_overrides[i].ident, int_overrides[i].value); + } + } + free(bool_settings); + free(bool_overrides); + free(int_settings); + free(int_overrides); return false; } From 256670e7d3d92c4e364a628530b83d9cb0b50d54 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 25 Aug 2016 19:30:10 -0500 Subject: [PATCH 07/17] (ovr) reimplement float_settings --- configuration.c | 83 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 26 deletions(-) diff --git a/configuration.c b/configuration.c index a44dd4bf0f..8f25e5ce75 100644 --- a/configuration.c +++ b/configuration.c @@ -3008,6 +3008,37 @@ int populate_settings_int(settings_t *settings, struct config_int_setting *out) return ARRAY_SIZE(tmp); } +int populate_settings_float(settings_t *settings, struct config_float_setting *out) +{ + global_t *global = global_get_ptr(); + struct config_float_setting tmp[] = { + { "video_aspect_ratio", settings->video.aspect_ratio}, + { "video_scale", settings->video.scale}, + { "video_refresh_rate", settings->video.refresh_rate}, + { "audio_rate_control_delta", settings->audio.rate_control_delta}, + { "audio_max_timing_skew", settings->audio.max_timing_skew}, + { "audio_volume", settings->audio.volume}, +#ifdef HAVE_OVERLAY + { "input_overlay_opacity", settings->input.overlay_opacity}, + { "input_overlay_scale", settings->input.overlay_scale}, +#endif +#ifdef HAVE_MENU + { "menu_wallpaper_opacity", settings->menu.wallpaper.opacity}, + { "menu_footer_opacity", settings->menu.footer.opacity}, + { "menu_header_opacity", settings->menu.header.opacity}, +#endif + { "video_message_pos_x", settings->video.msg_pos_x}, + { "video_message_pos_y", settings->video.msg_pos_y}, + { "video_font_size", settings->video.font_size}, + { "fastforward_ratio", settings->fastforward_ratio}, + { "slowmotion_ratio", settings->slowmotion_ratio}, + { "input_axis_threshold", settings->input.axis_threshold}, + }; + + memcpy(out, tmp, sizeof(tmp)); + return ARRAY_SIZE(tmp); +} + /** * config_save_file: * @path : Path that shall be written to. @@ -3032,32 +3063,13 @@ bool config_save_file(const char *path) (struct config_int_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_int_setting)); int int_settings_size = 0; - bool_settings_size = populate_settings_bool (settings, bool_settings); - int_settings_size = populate_settings_int (settings, int_settings); + struct config_float_setting *float_settings = + (struct config_float_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting)); + int float_settings_size = 0; - struct config_float_setting float_settings[] = { - { "video_aspect_ratio", settings->video.aspect_ratio}, - { "video_scale", settings->video.scale}, - { "video_refresh_rate", settings->video.refresh_rate}, - { "audio_rate_control_delta", settings->audio.rate_control_delta}, - { "audio_max_timing_skew", settings->audio.max_timing_skew}, - { "audio_volume", settings->audio.volume}, -#ifdef HAVE_OVERLAY - { "input_overlay_opacity", settings->input.overlay_opacity}, - { "input_overlay_scale", settings->input.overlay_scale}, -#endif -#ifdef HAVE_MENU - { "menu_wallpaper_opacity", settings->menu.wallpaper.opacity}, - { "menu_footer_opacity", settings->menu.footer.opacity}, - { "menu_header_opacity", settings->menu.header.opacity}, -#endif - { "video_message_pos_x", settings->video.msg_pos_x}, - { "video_message_pos_y", settings->video.msg_pos_y}, - { "video_font_size", settings->video.font_size}, - { "fastforward_ratio", settings->fastforward_ratio}, - { "slowmotion_ratio", settings->slowmotion_ratio}, - { "input_axis_threshold", settings->input.axis_threshold}, - }; + bool_settings_size = populate_settings_bool (settings, bool_settings); + int_settings_size = populate_settings_int (settings, int_settings); + float_settings_size = populate_settings_float (settings, float_settings); struct config_string_setting string_settings[] = { { "bundle_assets_dst_path_subdir", settings->path.bundle_assets_dst_subdir}, @@ -3235,7 +3247,7 @@ bool config_save_file(const char *path) * */ - for (i = 0; i < ARRAY_SIZE(float_settings); i++) + for (i = 0; i < float_settings_size; i++) { config_set_float(conf, float_settings[i].ident, float_settings[i].value); @@ -3369,8 +3381,14 @@ bool config_save_file_diff() struct config_int_setting *int_overrides = (struct config_int_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_int_setting)); + struct config_float_setting *float_settings = + (struct config_float_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting)); + struct config_float_setting *float_overrides = + (struct config_float_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting)); + int bool_settings_size = 0; int int_settings_size = 0; + int float_settings_size = 0; /* Load the original config file in memory */ config_load_file(global->path.config, false, settings); @@ -3380,6 +3398,9 @@ bool config_save_file_diff() int_settings_size = populate_settings_int(settings, int_settings); populate_settings_int (overrides, int_overrides); + + float_settings_size = populate_settings_float (settings, float_settings); + populate_settings_float (overrides, float_overrides); RARCH_LOG("Overrides:\n"); for (i = 0; i < bool_settings_size; i++) @@ -3402,6 +3423,16 @@ bool config_save_file_diff() int_overrides[i].ident, int_overrides[i].value); } } + for (i = 0; i < float_settings_size; i++) + { + if (float_settings[i].value != float_overrides[i].value) + { + RARCH_LOG(" original: %s=%f\n", + float_settings[i].ident, float_settings[i].value); + RARCH_LOG(" override: %s=%f\n", + float_overrides[i].ident, float_overrides[i].value); + } + } free(bool_settings); free(bool_overrides); From 97a5c3a118207171120a1d25d2022ca4bd32797d Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 25 Aug 2016 19:49:31 -0500 Subject: [PATCH 08/17] (ovr) reimplement string_settings --- configuration.c | 108 +++++++++++++++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 37 deletions(-) diff --git a/configuration.c b/configuration.c index 8f25e5ce75..8322b009ff 100644 --- a/configuration.c +++ b/configuration.c @@ -3039,39 +3039,10 @@ int populate_settings_float(settings_t *settings, struct config_float_setting *o return ARRAY_SIZE(tmp); } -/** - * config_save_file: - * @path : Path that shall be written to. - * - * Writes a config file to disk. - * - * Returns: true (1) on success, otherwise returns false (0). - **/ -bool config_save_file(const char *path) +int populate_settings_string(settings_t *settings, struct config_string_setting *out) { - float msg_color; - unsigned i = 0; - bool ret = false; - config_file_t *conf = config_file_new(path); - settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - struct config_bool_setting *bool_settings = - (struct config_bool_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_bool_setting)); - int bool_settings_size = 0; - - struct config_int_setting *int_settings = - (struct config_int_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_int_setting)); - int int_settings_size = 0; - - struct config_float_setting *float_settings = - (struct config_float_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting)); - int float_settings_size = 0; - - bool_settings_size = populate_settings_bool (settings, bool_settings); - int_settings_size = populate_settings_int (settings, int_settings); - float_settings_size = populate_settings_float (settings, float_settings); - - struct config_string_setting string_settings[] = { + struct config_string_setting tmp[] = { { "bundle_assets_dst_path_subdir", settings->path.bundle_assets_dst_subdir}, { "video_filter", settings->path.softfilter_plugin}, { "audio_dsp_plugin", settings->path.audio_dsp_plugin}, @@ -3105,6 +3076,49 @@ bool config_save_file(const char *path) { "bundle_assets_src_path", settings->path.bundle_assets_src}, { "bundle_assets_dst_path", settings->path.bundle_assets_dst} }; + + memcpy(out, tmp, sizeof(tmp)); + return ARRAY_SIZE(tmp); +} + + +/** + * config_save_file: + * @path : Path that shall be written to. + * + * Writes a config file to disk. + * + * Returns: true (1) on success, otherwise returns false (0). + **/ +bool config_save_file(const char *path) +{ + float msg_color; + unsigned i = 0; + bool ret = false; + config_file_t *conf = config_file_new(path); + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + struct config_bool_setting *bool_settings = + (struct config_bool_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_bool_setting)); + int bool_settings_size = 0; + + struct config_int_setting *int_settings = + (struct config_int_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_int_setting)); + int int_settings_size = 0; + + struct config_float_setting *float_settings = + (struct config_float_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting)); + int float_settings_size = 0; + + struct config_string_setting *string_settings = + (struct config_string_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_string_setting)); + int string_settings_size = 0; + + bool_settings_size = populate_settings_bool (settings, bool_settings); + int_settings_size = populate_settings_int (settings, int_settings); + float_settings_size = populate_settings_float (settings, float_settings); + string_settings_size = populate_settings_string(settings, string_settings); + struct config_path_setting path_settings[] = { { "recording_output_directory", false, global->record.output_dir}, @@ -3236,7 +3250,7 @@ bool config_save_file(const char *path) * */ - for (i = 0; i < ARRAY_SIZE(string_settings); i++) + for (i = 0; i < string_settings_size; i++) { config_set_string(conf, string_settings[i].ident, string_settings[i].value); @@ -3386,9 +3400,16 @@ bool config_save_file_diff() struct config_float_setting *float_overrides = (struct config_float_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting)); - int bool_settings_size = 0; - int int_settings_size = 0; - int float_settings_size = 0; + struct config_string_setting *string_settings = + (struct config_string_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_string_setting)); + struct config_string_setting *string_overrides = + (struct config_string_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_string_setting)); + + + int bool_settings_size = 0; + int int_settings_size = 0; + int float_settings_size = 0; + int string_settings_size = 0; /* Load the original config file in memory */ config_load_file(global->path.config, false, settings); @@ -3398,10 +3419,13 @@ bool config_save_file_diff() int_settings_size = populate_settings_int(settings, int_settings); populate_settings_int (overrides, int_overrides); - - float_settings_size = populate_settings_float (settings, float_settings); + + float_settings_size = populate_settings_float(settings, float_settings); populate_settings_float (overrides, float_overrides); + string_settings_size = populate_settings_string(settings, string_settings); + populate_settings_string (overrides, string_overrides); + RARCH_LOG("Overrides:\n"); for (i = 0; i < bool_settings_size; i++) { @@ -3433,6 +3457,16 @@ bool config_save_file_diff() float_overrides[i].ident, float_overrides[i].value); } } + for (i = 0; i < string_settings_size; i++) + { + if (strcmp(string_settings[i].value, string_overrides[i].value)) + { + RARCH_LOG(" original: %s=%s\n", + string_settings[i].ident, string_settings[i].value); + RARCH_LOG(" override: %s=%s\n", + string_overrides[i].ident, string_overrides[i].value); + } + } free(bool_settings); free(bool_overrides); From 89d59c5b36796f9a4551c854c041d2bcc99a081d Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 25 Aug 2016 19:51:47 -0500 Subject: [PATCH 09/17] (ovr) free these buffers --- configuration.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/configuration.c b/configuration.c index 8322b009ff..c545980981 100644 --- a/configuration.c +++ b/configuration.c @@ -3364,8 +3364,10 @@ bool config_save_file(const char *path) ret = config_file_write(conf, path); config_file_free(conf); - free (bool_settings); - free (int_settings); + free(bool_settings); + free(int_settings); + free(float_settings); + free(string_settings); return ret; } @@ -3472,6 +3474,10 @@ bool config_save_file_diff() free(bool_overrides); free(int_settings); free(int_overrides); + free(float_settings); + free(float_overrides); + free(string_settings); + free(string_overrides); return false; } From 02d164b9e4b09d1255db4140ac268ae8a33952f9 Mon Sep 17 00:00:00 2001 From: radius Date: Thu, 25 Aug 2016 20:10:01 -0500 Subject: [PATCH 10/17] (ovr) reimplement path_settings --- configuration.c | 110 +++++++++++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 38 deletions(-) diff --git a/configuration.c b/configuration.c index c545980981..a0473a4919 100644 --- a/configuration.c +++ b/configuration.c @@ -3081,45 +3081,10 @@ int populate_settings_string(settings_t *settings, struct config_string_setting return ARRAY_SIZE(tmp); } - -/** - * config_save_file: - * @path : Path that shall be written to. - * - * Writes a config file to disk. - * - * Returns: true (1) on success, otherwise returns false (0). - **/ -bool config_save_file(const char *path) +int populate_settings_path(settings_t *settings, struct config_path_setting *out) { - float msg_color; - unsigned i = 0; - bool ret = false; - config_file_t *conf = config_file_new(path); - settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - struct config_bool_setting *bool_settings = - (struct config_bool_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_bool_setting)); - int bool_settings_size = 0; - - struct config_int_setting *int_settings = - (struct config_int_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_int_setting)); - int int_settings_size = 0; - - struct config_float_setting *float_settings = - (struct config_float_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting)); - int float_settings_size = 0; - - struct config_string_setting *string_settings = - (struct config_string_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_string_setting)); - int string_settings_size = 0; - - bool_settings_size = populate_settings_bool (settings, bool_settings); - int_settings_size = populate_settings_int (settings, int_settings); - float_settings_size = populate_settings_float (settings, float_settings); - string_settings_size = populate_settings_string(settings, string_settings); - - struct config_path_setting path_settings[] = { + struct config_path_setting tmp[] = { { "recording_output_directory", false, global->record.output_dir}, { "recording_config_directory", false, @@ -3214,6 +3179,54 @@ bool config_save_file(const char *path) settings->directory.screenshot} }; + memcpy(out, tmp, sizeof(tmp)); + return ARRAY_SIZE(tmp); +} + +/** + * config_save_file: + * @path : Path that shall be written to. + * + * Writes a config file to disk. + * + * Returns: true (1) on success, otherwise returns false (0). + **/ +bool config_save_file(const char *path) +{ + float msg_color; + unsigned i = 0; + bool ret = false; + config_file_t *conf = config_file_new(path); + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + struct config_bool_setting *bool_settings = + (struct config_bool_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_bool_setting)); + int bool_settings_size = 0; + + struct config_int_setting *int_settings = + (struct config_int_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_int_setting)); + int int_settings_size = 0; + + struct config_float_setting *float_settings = + (struct config_float_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_float_setting)); + int float_settings_size = 0; + + struct config_string_setting *string_settings = + (struct config_string_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_string_setting)); + int string_settings_size = 0; + + struct config_path_setting *path_settings = + (struct config_path_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_path_setting)); + int path_settings_size = 0; + + bool_settings_size = populate_settings_bool (settings, bool_settings); + int_settings_size = populate_settings_int (settings, int_settings); + float_settings_size = populate_settings_float (settings, float_settings); + string_settings_size = populate_settings_string(settings, string_settings); + path_settings_size = populate_settings_path (settings, path_settings); + + + if (!conf) conf = config_file_new(NULL); @@ -3229,7 +3242,7 @@ bool config_save_file(const char *path) * */ - for (i = 0; i < ARRAY_SIZE(path_settings); i++) + for (i = 0; i < path_settings_size; i++) { if (path_settings[i].defaults) config_set_path(conf, path_settings[i].ident, @@ -3368,6 +3381,7 @@ bool config_save_file(const char *path) free(int_settings); free(float_settings); free(string_settings); + free(path_settings); return ret; } @@ -3407,11 +3421,16 @@ bool config_save_file_diff() struct config_string_setting *string_overrides = (struct config_string_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_string_setting)); + struct config_path_setting *path_settings = + (struct config_path_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_path_setting)); + struct config_path_setting *path_overrides = + (struct config_path_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_path_setting)); int bool_settings_size = 0; int int_settings_size = 0; int float_settings_size = 0; int string_settings_size = 0; + int path_settings_size = 0; /* Load the original config file in memory */ config_load_file(global->path.config, false, settings); @@ -3428,6 +3447,9 @@ bool config_save_file_diff() string_settings_size = populate_settings_string(settings, string_settings); populate_settings_string (overrides, string_overrides); + path_settings_size = populate_settings_path(settings, path_settings); + populate_settings_path (overrides, path_overrides); + RARCH_LOG("Overrides:\n"); for (i = 0; i < bool_settings_size; i++) { @@ -3469,6 +3491,16 @@ bool config_save_file_diff() string_overrides[i].ident, string_overrides[i].value); } } + for (i = 0; i < path_settings_size; i++) + { + if (strcmp(path_settings[i].value, path_overrides[i].value)) + { + RARCH_LOG(" original: %s=%s\n", + path_settings[i].ident, path_settings[i].value); + RARCH_LOG(" override: %s=%s\n", + path_overrides[i].ident, path_overrides[i].value); + } + } free(bool_settings); free(bool_overrides); @@ -3478,6 +3510,8 @@ bool config_save_file_diff() free(float_overrides); free(string_settings); free(string_overrides); + free(path_settings); + free(path_overrides); return false; } From 45ca269573b3bfe99515931c1725893f9a748e03 Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 26 Aug 2016 00:44:05 -0500 Subject: [PATCH 11/17] (ovr) define paths for override files --- command.c | 10 +++++----- configuration.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++- configuration.h | 6 +++++- 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/command.c b/command.c index e2029b5c6c..1a5283f1c9 100644 --- a/command.c +++ b/command.c @@ -1567,12 +1567,12 @@ static bool command_event_save_core_config(void) * Saves current configuration file to disk, and (optionally) * autosave state. **/ -void command_event_save_current_config(bool overrides) +void command_event_save_current_config(int override_type) { settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - if (!overrides) + if (!override_type) { if (settings->config_save_on_exit && !string_is_empty(global->path.config)) @@ -1613,7 +1613,7 @@ void command_event_save_current_config(bool overrides) bool ret = false; char msg[128] = {0}; - ret = config_save_file_diff(); + ret = config_save_file_diff(override_type); return; } } @@ -2316,10 +2316,10 @@ bool command_event(enum event_command cmd, void *data) return false; break; case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG: - command_event_save_current_config(false); + command_event_save_current_config(OVERRIDE_NONE); break; case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE: - command_event_save_current_config(true); + command_event_save_current_config(OVERRIDE_CORE); break; case CMD_EVENT_MENU_SAVE_CONFIG: if (!command_event_save_core_config()) diff --git a/configuration.c b/configuration.c index a0473a4919..f4221d657d 100644 --- a/configuration.c +++ b/configuration.c @@ -3393,13 +3393,22 @@ bool config_save_file(const char *path) * * Returns: true (1) on success, otherwise returns false (0). **/ -bool config_save_file_diff() +bool config_save_file_diff(int override_type) { unsigned i = 0; bool ret = false; + char buf[PATH_MAX_LENGTH] = {0}; + char config_directory[PATH_MAX_LENGTH] = {0}; + char core_path[PATH_MAX_LENGTH] = {0}; + char game_path[PATH_MAX_LENGTH] = {0}; + const char *core_name = NULL; + const char *game_name = NULL; + config_file_t *new_conf = NULL; + global_t *global = global_get_ptr(); settings_t *overrides = config_get_ptr(); settings_t *settings = (settings_t*)calloc(1, sizeof(settings_t)); + rarch_system_info_t *system = NULL; struct config_bool_setting *bool_settings = (struct config_bool_setting*) malloc(PATH_MAX_LENGTH *sizeof(struct config_bool_setting)); @@ -3432,6 +3441,47 @@ bool config_save_file_diff() int string_settings_size = 0; int path_settings_size = 0; + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + + if (system) + core_name = system->info.library_name; + if (global) + game_name = path_basename(global->name.base); + + if (string_is_empty(core_name) || string_is_empty(game_name)) + return false; + + fill_pathname_application_special(config_directory, sizeof(config_directory), + APPLICATION_SPECIAL_DIRECTORY_CONFIG); + + /* Concatenate strings into full paths for core_path, game_path */ + fill_pathname_join_special_ext(game_path, + config_directory, core_name, + game_name, + file_path_str(FILE_PATH_CONFIG_EXTENSION), + sizeof(game_path)); + + fill_pathname_join_special_ext(core_path, + config_directory, core_name, + core_name, + file_path_str(FILE_PATH_CONFIG_EXTENSION), + sizeof(core_path)); + + if (override_type == OVERRIDE_CORE) + { + RARCH_LOG ("Overrides: path %s\n", core_path); + /* Create a new config file from core_path */ + new_conf = config_file_new(core_path); + } + else if(override_type == OVERRIDE_GAME) + { + RARCH_LOG ("Overrides: path %s\n", game_path); + /* Create a new config file from core_path */ + new_conf = config_file_new(game_path); + } + else + return false; + /* Load the original config file in memory */ config_load_file(global->path.config, false, settings); @@ -3512,6 +3562,7 @@ bool config_save_file_diff() free(string_overrides); free(path_settings); free(path_overrides); + free(settings); return false; } diff --git a/configuration.h b/configuration.h index 8ef4948ce1..e07771d38f 100644 --- a/configuration.h +++ b/configuration.h @@ -25,6 +25,10 @@ #include "gfx/video_driver.h" #include "driver.h" +#define OVERRIDE_NONE 0 +#define OVERRIDE_CORE 1 +#define OVERRIDE_GAME 2 + #ifndef MAX_USERS #define MAX_USERS 16 #endif @@ -661,7 +665,7 @@ bool config_save_file(const char *path); * * Returns: true (1) on success, otherwise returns false (0). **/ -bool config_save_file_diff(); +bool config_save_file_diff(int override_type); /* Replaces currently loaded configuration file with * another one. Will load a dummy core to flush state From 7c78f52e6b6974d780eafc46957c423d5ec3a4fd Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 26 Aug 2016 00:46:49 -0500 Subject: [PATCH 12/17] (ovr) change a few log messages --- configuration.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/configuration.c b/configuration.c index f4221d657d..a698665aec 100644 --- a/configuration.c +++ b/configuration.c @@ -2161,13 +2161,13 @@ bool config_load_override(void) { config_file_free(new_conf); - RARCH_LOG("Overrides: core-specific overrides found at %s.\n", core_path); + RARCH_LOG("[overrides] core-specific overrides found at %s.\n", core_path); strlcpy(global->path.append_config, core_path, sizeof(global->path.append_config)); should_append = true; } else - RARCH_LOG("Overrides: no core-specific overrides found at %s.\n", core_path); + RARCH_LOG("[overrides] no core-specific overrides found at %s.\n", core_path); /* Create a new config file from game_path */ new_conf = config_file_new(game_path); @@ -2177,7 +2177,7 @@ bool config_load_override(void) { config_file_free(new_conf); - RARCH_LOG("Overrides: game-specific overrides found at %s.\n", game_path); + RARCH_LOG("[overrides] game-specific overrides found at %s.\n", game_path); if (should_append) { strlcat(global->path.append_config, "|", sizeof(global->path.append_config)); @@ -2189,7 +2189,7 @@ bool config_load_override(void) should_append = true; } else - RARCH_LOG("Overrides: no game-specific overrides found at %s.\n", game_path); + RARCH_LOG("[overrides] no game-specific overrides found at %s.\n", game_path); if (!should_append) return false; @@ -2198,7 +2198,7 @@ bool config_load_override(void) #ifdef HAVE_NETPLAY if (global->netplay.enable) { - RARCH_WARN("Overrides: can't use overrides in conjunction with netplay, disabling overrides.\n"); + RARCH_WARN("[overrides] can't use overrides in conjunction with netplay, disabling overrides.\n"); return false; } #endif @@ -2249,7 +2249,7 @@ bool config_unload_override(void) if (config_load_file(global->path.config, false, config_get_ptr())) { - RARCH_LOG("Overrides: configuration overrides unloaded, original configuration restored.\n"); + RARCH_LOG("[overrides] configuration overrides unloaded, original configuration restored.\n"); /* Reset save paths */ retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH); @@ -3469,13 +3469,13 @@ bool config_save_file_diff(int override_type) if (override_type == OVERRIDE_CORE) { - RARCH_LOG ("Overrides: path %s\n", core_path); + RARCH_LOG ("[overrides] path %s\n", core_path); /* Create a new config file from core_path */ new_conf = config_file_new(core_path); } else if(override_type == OVERRIDE_GAME) { - RARCH_LOG ("Overrides: path %s\n", game_path); + RARCH_LOG ("[overrides] path %s\n", game_path); /* Create a new config file from core_path */ new_conf = config_file_new(game_path); } @@ -3500,7 +3500,7 @@ bool config_save_file_diff(int override_type) path_settings_size = populate_settings_path(settings, path_settings); populate_settings_path (overrides, path_overrides); - RARCH_LOG("Overrides:\n"); + RARCH_LOG("[overrides]: looking for changed settings\n"); for (i = 0; i < bool_settings_size; i++) { if (bool_settings[i].value != bool_overrides[i].value) From 1b9120200467188fa17a98312a2413eb8707b69c Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 26 Aug 2016 01:06:15 -0500 Subject: [PATCH 13/17] (ovr) allow overwriting existing overrides, still have to make dirs for new overrides --- Makefile | 3 --- configuration.c | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 003deea2d7..be113b823e 100644 --- a/Makefile +++ b/Makefile @@ -55,9 +55,6 @@ ifeq ($(DEBUG), 1) OPTIMIZE_FLAG = -O0 -g else OPTIMIZE_FLAG = -O3 -ffast-math - ifneq ($(findstring Win32,$(OS)),) - LDFLAGS += -mwindows - endif endif CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) $(DEBUG_FLAG) -I. diff --git a/configuration.c b/configuration.c index a698665aec..0cd1ac88f6 100644 --- a/configuration.c +++ b/configuration.c @@ -3403,7 +3403,7 @@ bool config_save_file_diff(int override_type) char game_path[PATH_MAX_LENGTH] = {0}; const char *core_name = NULL; const char *game_name = NULL; - config_file_t *new_conf = NULL; + config_file_t *conf = NULL; global_t *global = global_get_ptr(); settings_t *overrides = config_get_ptr(); @@ -3471,13 +3471,13 @@ bool config_save_file_diff(int override_type) { RARCH_LOG ("[overrides] path %s\n", core_path); /* Create a new config file from core_path */ - new_conf = config_file_new(core_path); + conf = config_file_new(core_path); } else if(override_type == OVERRIDE_GAME) { RARCH_LOG ("[overrides] path %s\n", game_path); /* Create a new config file from core_path */ - new_conf = config_file_new(game_path); + conf = config_file_new(game_path); } else return false; @@ -3500,7 +3500,7 @@ bool config_save_file_diff(int override_type) path_settings_size = populate_settings_path(settings, path_settings); populate_settings_path (overrides, path_overrides); - RARCH_LOG("[overrides]: looking for changed settings\n"); + RARCH_LOG("[overrides] looking for changed settings\n"); for (i = 0; i < bool_settings_size; i++) { if (bool_settings[i].value != bool_overrides[i].value) @@ -3509,6 +3509,8 @@ bool config_save_file_diff(int override_type) bool_settings[i].ident, bool_settings[i].value); RARCH_LOG(" override: %s=%d\n", bool_overrides[i].ident, bool_overrides[i].value); + config_set_bool(conf, bool_overrides[i].ident, + bool_overrides[i].value); } } for (i = 0; i < int_settings_size; i++) @@ -3519,6 +3521,8 @@ bool config_save_file_diff(int override_type) int_settings[i].ident, int_settings[i].value); RARCH_LOG(" override: %s=%d\n", int_overrides[i].ident, int_overrides[i].value); + config_set_int(conf, int_overrides[i].ident, + int_overrides[i].value); } } for (i = 0; i < float_settings_size; i++) @@ -3529,6 +3533,8 @@ bool config_save_file_diff(int override_type) float_settings[i].ident, float_settings[i].value); RARCH_LOG(" override: %s=%f\n", float_overrides[i].ident, float_overrides[i].value); + config_set_float(conf, float_overrides[i].ident, + float_overrides[i].value); } } for (i = 0; i < string_settings_size; i++) @@ -3539,6 +3545,8 @@ bool config_save_file_diff(int override_type) string_settings[i].ident, string_settings[i].value); RARCH_LOG(" override: %s=%s\n", string_overrides[i].ident, string_overrides[i].value); + config_set_string(conf, string_overrides[i].ident, + string_overrides[i].value); } } for (i = 0; i < path_settings_size; i++) @@ -3549,9 +3557,29 @@ bool config_save_file_diff(int override_type) path_settings[i].ident, path_settings[i].value); RARCH_LOG(" override: %s=%s\n", path_overrides[i].ident, path_overrides[i].value); + config_set_path(conf, path_overrides[i].ident, + path_overrides[i].value); } } + if (override_type == OVERRIDE_CORE) + { + RARCH_LOG ("[overrides] path %s\n", core_path); + /* Create a new config file from core_path */ + ret = config_file_write(conf, core_path); + config_file_free(conf); + } + else if(override_type == OVERRIDE_GAME) + { + RARCH_LOG ("[overrides] path %s\n", game_path); + /* Create a new config file from core_path */ + ret = config_file_write(conf, game_path); + config_file_free(conf); + } + else + return false; + + free(bool_settings); free(bool_overrides); free(int_settings); @@ -3563,7 +3591,8 @@ bool config_save_file_diff(int override_type) free(path_settings); free(path_overrides); free(settings); - return false; + + return ret; } /* Replaces currently loaded configuration file with From 671aa0f59c4e344af5f7d73c420cca5dbd27a3dd Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 26 Aug 2016 09:43:29 -0500 Subject: [PATCH 14/17] (ovr) add game overrides too --- command.c | 7 ++++-- command.h | 3 ++- configuration.c | 48 ++++++++++++++++------------------------- configuration.h | 4 ++-- intl/msg_hash_us.c | 10 ++++++--- menu/menu_displaylist.c | 5 ++++- menu/menu_setting.c | 18 ++++++++++++---- msg_hash.h | 6 ++++-- 8 files changed, 57 insertions(+), 44 deletions(-) diff --git a/command.c b/command.c index 1a5283f1c9..a2d5a0bec3 100644 --- a/command.c +++ b/command.c @@ -1613,7 +1613,7 @@ void command_event_save_current_config(int override_type) bool ret = false; char msg[128] = {0}; - ret = config_save_file_diff(override_type); + ret = config_save_overrides(override_type); return; } } @@ -2318,9 +2318,12 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG: command_event_save_current_config(OVERRIDE_NONE); break; - case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE: + case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_CORE: command_event_save_current_config(OVERRIDE_CORE); break; + case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_GAME: + command_event_save_current_config(OVERRIDE_GAME); + break; case CMD_EVENT_MENU_SAVE_CONFIG: if (!command_event_save_core_config()) return false; diff --git a/command.h b/command.h index 5e90d7f5fb..0771f4fc33 100644 --- a/command.h +++ b/command.h @@ -141,7 +141,8 @@ enum event_command CMD_EVENT_PAUSE, CMD_EVENT_PAUSE_CHECKS, CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, - CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE, + CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_CORE, + CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_GAME, CMD_EVENT_MENU_SAVE_CONFIG, CMD_EVENT_MENU_PAUSE_LIBRETRO, /* Toggles menu on/off. */ diff --git a/configuration.c b/configuration.c index 0cd1ac88f6..41e171981c 100644 --- a/configuration.c +++ b/configuration.c @@ -3386,24 +3386,25 @@ bool config_save_file(const char *path) } /** - * config_save_file: + * config_save_overrides: * @path : Path that shall be written to. * - * Writes a config file to disk. + * Writes a config file override to disk. * * Returns: true (1) on success, otherwise returns false (0). **/ -bool config_save_file_diff(int override_type) +bool config_save_overrides(int override_type) { unsigned i = 0; bool ret = false; - char buf[PATH_MAX_LENGTH] = {0}; - char config_directory[PATH_MAX_LENGTH] = {0}; - char core_path[PATH_MAX_LENGTH] = {0}; - char game_path[PATH_MAX_LENGTH] = {0}; - const char *core_name = NULL; - const char *game_name = NULL; - config_file_t *conf = NULL; + char buf[PATH_MAX_LENGTH] = {0}; + char config_directory[PATH_MAX_LENGTH] = {0}; + char override_directory[PATH_MAX_LENGTH] = {0}; + char core_path[PATH_MAX_LENGTH] = {0}; + char game_path[PATH_MAX_LENGTH] = {0}; + const char *core_name = NULL; + const char *game_name = NULL; + config_file_t *conf = NULL; global_t *global = global_get_ptr(); settings_t *overrides = config_get_ptr(); @@ -3454,6 +3455,12 @@ bool config_save_file_diff(int override_type) fill_pathname_application_special(config_directory, sizeof(config_directory), APPLICATION_SPECIAL_DIRECTORY_CONFIG); + fill_pathname_join(override_directory, config_directory, core_name, + sizeof(override_directory)); + + if(!path_file_exists(override_directory)) + path_mkdir(override_directory); + /* Concatenate strings into full paths for core_path, game_path */ fill_pathname_join_special_ext(game_path, config_directory, core_name, @@ -3467,36 +3474,20 @@ bool config_save_file_diff(int override_type) file_path_str(FILE_PATH_CONFIG_EXTENSION), sizeof(core_path)); - if (override_type == OVERRIDE_CORE) - { - RARCH_LOG ("[overrides] path %s\n", core_path); - /* Create a new config file from core_path */ - conf = config_file_new(core_path); - } - else if(override_type == OVERRIDE_GAME) - { - RARCH_LOG ("[overrides] path %s\n", game_path); - /* Create a new config file from core_path */ - conf = config_file_new(game_path); - } - else - return false; + if (!conf) + conf = config_file_new(NULL); /* Load the original config file in memory */ config_load_file(global->path.config, false, settings); bool_settings_size = populate_settings_bool(settings, bool_settings); populate_settings_bool (overrides, bool_overrides); - int_settings_size = populate_settings_int(settings, int_settings); populate_settings_int (overrides, int_overrides); - float_settings_size = populate_settings_float(settings, float_settings); populate_settings_float (overrides, float_overrides); - string_settings_size = populate_settings_string(settings, string_settings); populate_settings_string (overrides, string_overrides); - path_settings_size = populate_settings_path(settings, path_settings); populate_settings_path (overrides, path_overrides); @@ -3579,7 +3570,6 @@ bool config_save_file_diff(int override_type) else return false; - free(bool_settings); free(bool_overrides); free(int_settings); diff --git a/configuration.h b/configuration.h index e07771d38f..a8729f807f 100644 --- a/configuration.h +++ b/configuration.h @@ -658,14 +658,14 @@ bool config_save_autoconf_profile(const char *path, unsigned user); bool config_save_file(const char *path); /** - * config_save_file_diff: + * config_save_overrides: * @path : Path that shall be written to. * * Writes a config file override to disk. * * Returns: true (1) on success, otherwise returns false (0). **/ -bool config_save_file_diff(int override_type); +bool config_save_overrides(int override_type); /* Replaces currently loaded configuration file with * another one. Will load a dummy core to flush state diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index 9727242ee8..6bcfadc6c3 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -2064,8 +2064,10 @@ static const char *menu_hash_to_str_us_label_enum(enum msg_hash_enums msg) return "input_small_keyboard_enable"; case MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG: return "save_current_config"; - case MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE: - return "save_current_config_override"; + case MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_CORE: + return "save_current_config_override_core"; + case MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_GAME: + return "save_current_config_override_game"; case MENU_ENUM_LABEL_STATE_SLOT: return "state_slot"; case MENU_ENUM_LABEL_CHEEVOS_USERNAME: @@ -3441,8 +3443,10 @@ const char *msg_hash_to_str_us(enum msg_hash_enums msg) return "Keyboard Gamepad Mapping Type"; case MENU_ENUM_LABEL_VALUE_INPUT_SMALL_KEYBOARD_ENABLE: return "Small Keyboard Enable"; - case MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE: + case MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE_CORE: return "Save Core Overrides"; + case MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE_GAME: + return "Save Game Overrides"; case MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG: return "Save Current Config"; case MENU_ENUM_LABEL_VALUE_STATE_SLOT: diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 8334080ae4..e37375de44 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4374,7 +4374,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG, PARSE_ACTION, false); menu_displaylist_parse_settings_enum(menu, info, - MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE, + MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_CORE, + PARSE_ACTION, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_GAME, PARSE_ACTION, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_SAVE_NEW_CONFIG, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index d20c54608f..658077118d 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4165,13 +4165,23 @@ static bool setting_append_list( CONFIG_ACTION( list, list_info, - msg_hash_to_str(MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE), + msg_hash_to_str(MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_CORE), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE_CORE), &group_info, &subgroup_info, parent_group); - menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE); - menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_CORE); + menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_CORE); + + CONFIG_ACTION( + list, list_info, + msg_hash_to_str(MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_GAME), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE_GAME), + &group_info, + &subgroup_info, + parent_group); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE_GAME); + menu_settings_list_current_add_enum_idx(list, list_info, MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_GAME); CONFIG_ACTION( list, list_info, diff --git a/msg_hash.h b/msg_hash.h index 4c0dbf3e7d..204476de23 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1773,9 +1773,11 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_HELP_SCANNING_CONTENT_DESC, MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG, - MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE, + MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_CORE, + MENU_ENUM_LABEL_SAVE_CURRENT_CONFIG_OVERRIDE_GAME, MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG, - MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE, + MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE_CORE, + MENU_ENUM_LABEL_VALUE_SAVE_CURRENT_CONFIG_OVERRIDE_GAME, MENU_ENUM_LABEL_VALUE_THUMBNAIL_MODE_SCREENSHOTS, MENU_ENUM_LABEL_VALUE_THUMBNAIL_MODE_TITLE_SCREENS, From 725e41b20b17c779eff8e955f59e89b28c4272a8 Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 26 Aug 2016 09:54:15 -0500 Subject: [PATCH 15/17] (ovr) add osd messages --- command.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/command.c b/command.c index a2d5a0bec3..476d1c1760 100644 --- a/command.c +++ b/command.c @@ -1614,6 +1614,19 @@ void command_event_save_current_config(int override_type) char msg[128] = {0}; ret = config_save_overrides(override_type); + + if (ret) + { + snprintf(msg, sizeof(msg), "Overrides saved successfully"); + RARCH_LOG("[overrides] %s\n", msg); + } + else + { + snprintf(msg, sizeof(msg), "Error saving overrides"); + RARCH_ERR("[overrides] %s\n", msg); + } + + runloop_msg_queue_push(msg, 1, 180, true); return; } } From c9a6a8f14853e2bcadcb6353c6ac4cddac7a6b55 Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 26 Aug 2016 09:55:10 -0500 Subject: [PATCH 16/17] revert this makefile change --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index be113b823e..003deea2d7 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,9 @@ ifeq ($(DEBUG), 1) OPTIMIZE_FLAG = -O0 -g else OPTIMIZE_FLAG = -O3 -ffast-math + ifneq ($(findstring Win32,$(OS)),) + LDFLAGS += -mwindows + endif endif CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) $(DEBUG_FLAG) -I. From 50e80216735fbc81e6c17a4d7aa953d0856f91a7 Mon Sep 17 00:00:00 2001 From: radius Date: Fri, 26 Aug 2016 11:26:24 -0500 Subject: [PATCH 17/17] (ovr) fix potential leaks --- configuration.c | 50 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/configuration.c b/configuration.c index 41e171981c..291f21766f 100644 --- a/configuration.c +++ b/configuration.c @@ -3199,6 +3199,17 @@ bool config_save_file(const char *path) config_file_t *conf = config_file_new(path); settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); + + if (!conf) + conf = config_file_new(NULL); + + if (!conf || runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL)) + { + if (conf) + config_file_free(conf); + return false; + } + struct config_bool_setting *bool_settings = (struct config_bool_setting*) malloc(PATH_MAX_LENGTH * sizeof(struct config_bool_setting)); int bool_settings_size = 0; @@ -3225,18 +3236,6 @@ bool config_save_file(const char *path) string_settings_size = populate_settings_string(settings, string_settings); path_settings_size = populate_settings_path (settings, path_settings); - - - if (!conf) - conf = config_file_new(NULL); - - if (!conf || runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL)) - { - if (conf) - config_file_free(conf); - return false; - } - /* * Path settings * @@ -3382,6 +3381,7 @@ bool config_save_file(const char *path) free(float_settings); free(string_settings); free(path_settings); + return ret; } @@ -3408,9 +3408,21 @@ bool config_save_overrides(int override_type) global_t *global = global_get_ptr(); settings_t *overrides = config_get_ptr(); - settings_t *settings = (settings_t*)calloc(1, sizeof(settings_t)); + rarch_system_info_t *system = NULL; + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + + if (system) + core_name = system->info.library_name; + if (global) + game_name = path_basename(global->name.base); + + if (string_is_empty(core_name) || string_is_empty(game_name)) + return false; + + settings_t *settings = (settings_t*)calloc(1, sizeof(settings_t)); + struct config_bool_setting *bool_settings = (struct config_bool_setting*) malloc(PATH_MAX_LENGTH *sizeof(struct config_bool_setting)); struct config_bool_setting *bool_overrides = @@ -3442,16 +3454,6 @@ bool config_save_overrides(int override_type) int string_settings_size = 0; int path_settings_size = 0; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); - - if (system) - core_name = system->info.library_name; - if (global) - game_name = path_basename(global->name.base); - - if (string_is_empty(core_name) || string_is_empty(game_name)) - return false; - fill_pathname_application_special(config_directory, sizeof(config_directory), APPLICATION_SPECIAL_DIRECTORY_CONFIG); @@ -3568,7 +3570,7 @@ bool config_save_overrides(int override_type) config_file_free(conf); } else - return false; + ret = false; free(bool_settings); free(bool_overrides);