From d88d0d52195452b879affb0efacd6b48a6a7882f Mon Sep 17 00:00:00 2001 From: zoltanvb <101990835+zoltanvb@users.noreply.github.com> Date: Sun, 4 Feb 2024 20:58:16 +0100 Subject: [PATCH] Option for disabling initial disc change (#16197) Loading the last used disc for multi-disc content was automatic. However, in some cases it is not wanted, as described in #16018 Option is added for controlling the function. Disabling the option will also implicitly disable index saving. --- config.def.h | 1 + configuration.c | 1 + configuration.h | 1 + disk_control_interface.c | 14 ++++++++++---- disk_control_interface.h | 3 ++- intl/msg_hash_lbl.h | 4 ++++ intl/msg_hash_us.h | 10 +++++++++- menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/drivers/ozone.c | 1 + menu/drivers/xmb.c | 1 + menu/menu_displaylist.c | 13 +++++++------ menu/menu_setting.c | 9 ++++++++- msg_hash.h | 1 + runloop.c | 17 ++++++++++------- 14 files changed, 60 insertions(+), 20 deletions(-) diff --git a/config.def.h b/config.def.h index 449a5b603a..755bfebf36 100644 --- a/config.def.h +++ b/config.def.h @@ -848,6 +848,7 @@ #define DEFAULT_GAME_SPECIFIC_OPTIONS true #define DEFAULT_AUTO_OVERRIDES_ENABLE true #define DEFAULT_AUTO_REMAPS_ENABLE true +#define DEFAULT_INITIAL_DISK_CHANGE_ENABLE true #define DEFAULT_GLOBAL_CORE_OPTIONS false #define DEFAULT_AUTO_SHADERS_ENABLE true diff --git a/configuration.c b/configuration.c index 15c163bdc1..5845eda067 100644 --- a/configuration.c +++ b/configuration.c @@ -1719,6 +1719,7 @@ static struct config_bool_setting *populate_settings_bool( SETTING_BOOL("game_specific_options", &settings->bools.game_specific_options, true, DEFAULT_GAME_SPECIFIC_OPTIONS, false); SETTING_BOOL("auto_overrides_enable", &settings->bools.auto_overrides_enable, true, DEFAULT_AUTO_OVERRIDES_ENABLE, false); SETTING_BOOL("auto_remaps_enable", &settings->bools.auto_remaps_enable, true, DEFAULT_AUTO_REMAPS_ENABLE, false); + SETTING_BOOL("initial_disk_change_enable", &settings->bools.initial_disk_change_enable, true, DEFAULT_INITIAL_DISK_CHANGE_ENABLE, false); SETTING_BOOL("global_core_options", &settings->bools.global_core_options, true, DEFAULT_GLOBAL_CORE_OPTIONS, false); SETTING_BOOL("auto_shaders_enable", &settings->bools.auto_shaders_enable, true, DEFAULT_AUTO_SHADERS_ENABLE, false); SETTING_BOOL("scan_without_core_match", &settings->bools.scan_without_core_match, true, DEFAULT_SCAN_WITHOUT_CORE_MATCH, false); diff --git a/configuration.h b/configuration.h index 2ecc2556f0..4f7fbbf1de 100644 --- a/configuration.h +++ b/configuration.h @@ -976,6 +976,7 @@ typedef struct settings bool game_specific_options; bool auto_overrides_enable; bool auto_remaps_enable; + bool initial_disk_change_enable; bool global_core_options; bool auto_shaders_enable; diff --git a/disk_control_interface.c b/disk_control_interface.c index e0304f48e5..2a3169afdd 100644 --- a/disk_control_interface.c +++ b/disk_control_interface.c @@ -754,7 +754,8 @@ error: **/ bool disk_control_verify_initial_index( disk_control_interface_t *disk_control, - bool verbosity) + bool verbosity, + bool enabled) { bool success = false; unsigned image_index = 0; @@ -766,7 +767,7 @@ bool disk_control_verify_initial_index( return false; /* If index record is disabled, can return immediately */ - if (!disk_control->record_enabled) + if (!disk_control->record_enabled && enabled) return false; /* Check that 'initial index' functionality is enabled */ @@ -803,10 +804,10 @@ bool disk_control_verify_initial_index( } /* If current disk is incorrect, notify user */ - if (!success) + if (!success && enabled) { RARCH_ERR( - "[Disc]: Failed to set initial disk index:\n> Expected" + "[Disc]: Failed to set initial disc index:\n> Expected" " [%u] %s\n> Detected [%u] %s\n", disk_control->index_record.image_index + 1, disk_control->index_record.image_path, @@ -830,6 +831,11 @@ bool disk_control_verify_initial_index( disk_index_file_set(&disk_control->index_record, 0, NULL); disk_index_file_save(&disk_control->index_record); } + else if (!enabled) + { + RARCH_LOG("[Disc]: Initial disc index setting disabled."); + } + /* If current disk is correct and recorded image * path is empty (i.e. first run), need to register * current image path */ diff --git a/disk_control_interface.h b/disk_control_interface.h index 641332f2c4..1efb364d65 100644 --- a/disk_control_interface.h +++ b/disk_control_interface.h @@ -241,7 +241,8 @@ bool disk_control_set_initial_index( **/ bool disk_control_verify_initial_index( disk_control_interface_t *disk_control, - bool verbosity); + bool verbosity, + bool enabled); /** * disk_control_save_image_index: diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 364eda6228..b8345c5085 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -401,6 +401,10 @@ MSG_HASH( MENU_ENUM_LABEL_AUTO_REMAPS_ENABLE, "auto_remaps_enable" ) +MSG_HASH( + MENU_ENUM_LABEL_INITIAL_DISK_CHANGE_ENABLE, + "initial_disk_change_enable" + ) MSG_HASH( MENU_ENUM_LABEL_GLOBAL_CORE_OPTIONS, "global_core_options" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index e7237165ca..80c53efe3b 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -4456,6 +4456,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_AUTO_REMAPS_ENABLE, "Load customized controls at startup." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_INITIAL_DISK_CHANGE_ENABLE, + "Load Initial Disc Index Files Automatically" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_INITIAL_DISK_CHANGE_ENABLE, + "Change to last used disc when starting multi-disc content." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_AUTO_SHADERS_ENABLE, "Load Shader Presets Automatically" @@ -15063,7 +15071,7 @@ MSG_HASH( ) MSG_HASH( MSG_FAILED_TO_SET_INITIAL_DISK, - "Failed to set last used disc..." + "Failed to set last used disc." ) MSG_HASH( MSG_FAILED_TO_CONNECT_TO_CLIENT, diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index dd5d680545..040de1d5f7 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -958,6 +958,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_menu_filebrowser_settings, DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_menu_filebrowser_open_uwp_permissions, MENU_ENUM_SUBLABEL_FILE_BROWSER_OPEN_UWP_PERMISSIONS) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_menu_filebrowser_open_picker, MENU_ENUM_SUBLABEL_FILE_BROWSER_OPEN_PICKER) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_auto_remaps_enable, MENU_ENUM_SUBLABEL_AUTO_REMAPS_ENABLE) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_initial_disk_change_enable, MENU_ENUM_SUBLABEL_INITIAL_DISK_CHANGE_ENABLE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_auto_overrides_enable, MENU_ENUM_SUBLABEL_AUTO_OVERRIDES_ENABLE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_game_specific_options, MENU_ENUM_SUBLABEL_GAME_SPECIFIC_OPTIONS) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_global_core_options, MENU_ENUM_SUBLABEL_GLOBAL_CORE_OPTIONS) @@ -3440,6 +3441,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_AUTO_REMAPS_ENABLE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_auto_remaps_enable); break; + case MENU_ENUM_LABEL_INITIAL_DISK_CHANGE_ENABLE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_initial_disk_change_enable); + break; case MENU_ENUM_LABEL_MENU_FILE_BROWSER_SETTINGS: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_filebrowser_settings); break; diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index 6abb251ab0..63bdaa22e9 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -2144,6 +2144,7 @@ static uintptr_t ozone_entries_icon_get_texture( case MENU_ENUM_LABEL_OVERRIDE_FILE_LOAD: case MENU_ENUM_LABEL_AUTO_OVERRIDES_ENABLE: case MENU_ENUM_LABEL_AUTO_REMAPS_ENABLE: + case MENU_ENUM_LABEL_INITIAL_DISK_CHANGE_ENABLE: case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PREPEND: case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_APPEND: diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 0fd3622e98..2a0e09669a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2960,6 +2960,7 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, case MENU_ENUM_LABEL_OVERRIDE_FILE_LOAD: case MENU_ENUM_LABEL_AUTO_OVERRIDES_ENABLE: case MENU_ENUM_LABEL_AUTO_REMAPS_ENABLE: + case MENU_ENUM_LABEL_INITIAL_DISK_CHANGE_ENABLE: case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET: case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_PREPEND: case MENU_ENUM_LABEL_VIDEO_SHADER_PRESET_APPEND: diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 15ae63f13e..e931c3238d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -10785,12 +10785,13 @@ unsigned menu_displaylist_build_list( case DISPLAYLIST_CONFIGURATION_SETTINGS_LIST: { menu_displaylist_build_info_t build_list[] = { - {MENU_ENUM_LABEL_CONFIG_SAVE_ON_EXIT, PARSE_ONLY_BOOL}, - {MENU_ENUM_LABEL_REMAP_SAVE_ON_EXIT, PARSE_ONLY_BOOL}, - {MENU_ENUM_LABEL_GAME_SPECIFIC_OPTIONS, PARSE_ONLY_BOOL}, - {MENU_ENUM_LABEL_AUTO_OVERRIDES_ENABLE, PARSE_ONLY_BOOL}, - {MENU_ENUM_LABEL_AUTO_REMAPS_ENABLE, PARSE_ONLY_BOOL}, - {MENU_ENUM_LABEL_GLOBAL_CORE_OPTIONS, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_CONFIG_SAVE_ON_EXIT, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_REMAP_SAVE_ON_EXIT, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_GAME_SPECIFIC_OPTIONS, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_AUTO_OVERRIDES_ENABLE, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_AUTO_REMAPS_ENABLE, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_INITIAL_DISK_CHANGE_ENABLE, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_GLOBAL_CORE_OPTIONS, PARSE_ONLY_BOOL}, }; for (i = 0; i < ARRAY_SIZE(build_list); i++) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 407ffccbbf..a07ff1f037 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -10859,7 +10859,7 @@ static bool setting_append_list( case SETTINGS_LIST_CONFIGURATION: { uint8_t i, listing = 0; - struct bool_entry bool_entries[8]; + struct bool_entry bool_entries[9]; START_GROUP(list, list_info, &group_info, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONFIGURATION_SETTINGS), parent_group); @@ -10903,6 +10903,13 @@ static bool setting_append_list( bool_entries[listing].flags = SD_FLAG_ADVANCED; listing++; + bool_entries[listing].target = &settings->bools.initial_disk_change_enable; + bool_entries[listing].name_enum_idx = MENU_ENUM_LABEL_INITIAL_DISK_CHANGE_ENABLE; + bool_entries[listing].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_INITIAL_DISK_CHANGE_ENABLE; + bool_entries[listing].default_value = DEFAULT_INITIAL_DISK_CHANGE_ENABLE; + bool_entries[listing].flags = SD_FLAG_ADVANCED; + listing++; + bool_entries[listing].target = &settings->bools.auto_shaders_enable; bool_entries[listing].name_enum_idx = MENU_ENUM_LABEL_AUTO_SHADERS_ENABLE; bool_entries[listing].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_AUTO_SHADERS_ENABLE; diff --git a/msg_hash.h b/msg_hash.h index b56852f322..17f51e5998 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2284,6 +2284,7 @@ enum msg_hash_enums MENU_LABEL(AUTO_OVERRIDES_ENABLE), MENU_LABEL(AUTO_REMAPS_ENABLE), + MENU_LABEL(INITIAL_DISK_CHANGE_ENABLE), MENU_LABEL(GLOBAL_CORE_OPTIONS), MENU_LABEL(AUTO_SHADERS_ENABLE), MENU_LABEL(RGUI_SHOW_START_SCREEN), diff --git a/runloop.c b/runloop.c index 938323ba3d..23ed4a33f3 100644 --- a/runloop.c +++ b/runloop.c @@ -4634,6 +4634,7 @@ bool runloop_event_init_core( bool auto_remaps_enable = false; const char *dir_input_remapping = NULL; #endif + bool initial_disk_change_enable = true; bool show_set_initial_disk_msg = false; unsigned poll_type_behavior = 0; float fastforward_ratio = 0.0f; @@ -4705,12 +4706,13 @@ bool runloop_event_init_core( /* Cannot access these settings-related parameters * until *after* config overrides have been loaded */ #ifdef HAVE_CONFIGFILE - auto_remaps_enable = settings->bools.auto_remaps_enable; - dir_input_remapping = settings->paths.directory_input_remapping; + auto_remaps_enable = settings->bools.auto_remaps_enable; + dir_input_remapping = settings->paths.directory_input_remapping; #endif - show_set_initial_disk_msg = settings->bools.notification_show_set_initial_disk; - poll_type_behavior = settings->uints.input_poll_type_behavior; - fastforward_ratio = runloop_get_fastforward_ratio( + initial_disk_change_enable = settings->bools.initial_disk_change_enable; + show_set_initial_disk_msg = settings->bools.notification_show_set_initial_disk; + poll_type_behavior = settings->uints.input_poll_type_behavior; + fastforward_ratio = runloop_get_fastforward_ratio( settings, &runloop_st->fastmotion_override.current); #ifdef HAVE_CHEEVOS @@ -4754,7 +4756,8 @@ bool runloop_event_init_core( runloop_st->current_core.flags |= RETRO_CORE_FLAG_INITED; /* Attempt to set initial disk index */ - disk_control_set_initial_index( + if (initial_disk_change_enable) + disk_control_set_initial_index( &sys_info->disk_control, path_get(RARCH_PATH_CONTENT), runloop_st->savefile_dir); @@ -4767,7 +4770,7 @@ bool runloop_event_init_core( /* Verify that initial disk index was set correctly */ disk_control_verify_initial_index(&sys_info->disk_control, - show_set_initial_disk_msg); + show_set_initial_disk_msg, initial_disk_change_enable); if (!runloop_event_load_core(runloop_st, poll_type_behavior)) return false;