diff --git a/config.def.h b/config.def.h index b743428fda..6c787d1dd1 100644 --- a/config.def.h +++ b/config.def.h @@ -388,6 +388,9 @@ #define DEFAULT_SHOW_HIDDEN_FILES false +/* Initialise file browser with the last used start directory */ +#define DEFAULT_USE_LAST_START_DIRECTORY false + #define DEFAULT_OVERLAY_HIDE_IN_MENU true /* Automatically disable overlays when a diff --git a/configuration.c b/configuration.c index e213f636ed..d2161da424 100644 --- a/configuration.c +++ b/configuration.c @@ -1717,6 +1717,7 @@ static struct config_bool_setting *populate_settings_bool( SETTING_BOOL("sort_screenshots_by_content_enable", &settings->bools.sort_screenshots_by_content_enable, true, default_sort_screenshots_by_content_enable, false); SETTING_BOOL("config_save_on_exit", &settings->bools.config_save_on_exit, true, DEFAULT_CONFIG_SAVE_ON_EXIT, false); SETTING_BOOL("show_hidden_files", &settings->bools.show_hidden_files, true, DEFAULT_SHOW_HIDDEN_FILES, false); + SETTING_BOOL("use_last_start_directory", &settings->bools.use_last_start_directory, true, DEFAULT_USE_LAST_START_DIRECTORY, false); SETTING_BOOL("input_autodetect_enable", &settings->bools.input_autodetect_enable, true, input_autodetect_enable, false); #if defined(HAVE_DINPUT) || defined(HAVE_WINRAWINPUT) SETTING_BOOL("input_nowinkey_enable", &settings->bools.input_nowinkey_enable, true, false, false); diff --git a/configuration.h b/configuration.h index 43bf3e6374..d8f416c5fc 100644 --- a/configuration.h +++ b/configuration.h @@ -768,6 +768,7 @@ typedef struct settings bool sort_screenshots_by_content_enable; bool config_save_on_exit; bool show_hidden_files; + bool use_last_start_directory; bool savefiles_in_content_dir; bool savestates_in_content_dir; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index cc8ebafeee..f69db146bc 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -2704,6 +2704,10 @@ MSG_HASH( MENU_ENUM_LABEL_SHOW_HIDDEN_FILES, "show_hidden_files" ) +MSG_HASH( + MENU_ENUM_LABEL_USE_LAST_START_DIRECTORY, + "use_last_start_directory" + ) MSG_HASH( MENU_ENUM_LABEL_SHUTDOWN, "shutdown" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 1fdd85b892..352fa9a81d 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3138,6 +3138,14 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_FILTER_BY_CURRENT_CORE, "Filter by Current Core" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_USE_LAST_START_DIRECTORY, + "Remember Last Used Start Directory" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_USE_LAST_START_DIRECTORY, + "Open the file browser at the last used location when loading content from the Start Directory. Note: Location will be reset to default upon restarting RetroArch." + ) /* Settings > Frame Throttle */ diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 265a15b4df..b4551f5ab7 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -1063,6 +1063,7 @@ static int menu_cbs_init_bind_left_compare_type(menu_file_list_cbs_t *cbs, case FILE_TYPE_FONT: case MENU_SETTING_GROUP: case MENU_SETTINGS_CORE_INFO_NONE: + case MENU_SETTING_ACTION_FAVORITES_DIR: if ( string_ends_with_size(menu_label, "_tab", strlen(menu_label), STRLEN_CONST("_tab")) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 7e1b3fc126..58d5834a68 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -219,7 +219,6 @@ static int (funcname)(const char *path, const char *label, unsigned type, size_t return generic_action_ok_displaylist_push(path, _path, label, type, idx, entry_idx, _id); \ } - #define DEFAULT_ACTION_OK_HELP(funcname, _id, _id2) \ static int (funcname)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ { \ @@ -834,6 +833,16 @@ int generic_action_ok_displaylist_push(const char *path, info_path = new_path; info_label = label; dl_type = DISPLAYLIST_GENERIC; + + /* If this is the 'Start Directory' content + * list, use last selected directory/file */ + if ((type == MENU_SETTING_ACTION_FAVORITES_DIR) && + settings->bools.use_last_start_directory) + { + info_path = menu_driver_get_last_start_directory(); + menu_driver_set_pending_selection(menu_driver_get_last_start_file_name()); + } + break; case ACTION_OK_DL_SCAN_DIR_LIST: filebrowser_set_type(FILEBROWSER_SCAN_DIR); @@ -1533,6 +1542,7 @@ static int file_load_with_detect_core_wrapper( return -1; content_add_to_playlist(def_info.s); + menu_driver_set_last_start_content(def_info.s); ret = 0; break; @@ -1917,6 +1927,7 @@ static int default_action_ok_load_content_with_core_from_menu(const char *_path, (enum rarch_core_type)_type, NULL, NULL)) return -1; content_add_to_playlist(_path); + menu_driver_set_last_start_content(_path); return 0; } @@ -3505,6 +3516,7 @@ static int action_ok_load_core_deferred(const char *path, NULL, NULL)) return -1; content_add_to_playlist(path); + menu_driver_set_last_start_content(path); return 0; } @@ -4012,6 +4024,7 @@ static int action_ok_file_load_detect_core(const char *path, NULL, NULL)) return -1; content_add_to_playlist(menu->detect_content_path); + menu_driver_set_last_start_content(menu->detect_content_path); return 0; } @@ -5411,7 +5424,7 @@ static int action_ok_open_picker(const char *path, ret = generic_action_ok_displaylist_push(path, new_path, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES), - type, idx, + MENU_SETTING_ACTION_FAVORITES_DIR, idx, entry_idx, ACTION_OK_DL_CONTENT_LIST); free(new_path); @@ -6400,6 +6413,8 @@ static int action_ok_load_archive_detect_core(const char *path, CORE_TYPE_PLAIN, NULL, NULL)) ret = -1; + else + menu_driver_set_last_start_content(def_info.s); } break; case 0: diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index fd5fd82e10..f1c9c4fe59 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -908,6 +908,7 @@ static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs, case FILE_TYPE_FONT: case MENU_SETTING_GROUP: case MENU_SETTINGS_CORE_INFO_NONE: + case MENU_SETTING_ACTION_FAVORITES_DIR: if ( string_ends_with_size(menu_label, "_tab", strlen(menu_label), STRLEN_CONST("_tab")) diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 6f22975d58..dff79eb683 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -653,6 +653,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_playlist_entry_rename, DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_playlist_entry_remove, MENU_ENUM_SUBLABEL_PLAYLIST_ENTRY_REMOVE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_system_directory, MENU_ENUM_SUBLABEL_SYSTEM_DIRECTORY) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_rgui_browser_directory, MENU_ENUM_SUBLABEL_RGUI_BROWSER_DIRECTORY) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_use_last_start_directory, MENU_ENUM_SUBLABEL_USE_LAST_START_DIRECTORY) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_content_dir, MENU_ENUM_SUBLABEL_CONTENT_DIR) DEFAULT_SUBLABEL_MACRO(action_bind_dynamic_wallpapers_directory, MENU_ENUM_SUBLABEL_DYNAMIC_WALLPAPERS_DIRECTORY) DEFAULT_SUBLABEL_MACRO(action_bind_thumbnails_directory, MENU_ENUM_SUBLABEL_THUMBNAILS_DIRECTORY) @@ -3480,6 +3481,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_SHOW_HIDDEN_FILES: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_show_hidden_files); break; + case MENU_ENUM_LABEL_USE_LAST_START_DIRECTORY: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_use_last_start_directory); + break; case MENU_ENUM_LABEL_INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_toggle_gamepad_combo); break; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index b857c6152f..ce731bf5bf 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -638,6 +638,7 @@ DEFAULT_FILL_TITLE_MACRO(action_get_title_autoconfig_directory, MENU_ENUM_LABEL DEFAULT_FILL_TITLE_MACRO(action_get_title_playlist_directory, MENU_ENUM_LABEL_VALUE_PLAYLIST_DIRECTORY) DEFAULT_FILL_TITLE_MACRO(action_get_title_runtime_log_directory, MENU_ENUM_LABEL_VALUE_RUNTIME_LOG_DIRECTORY) DEFAULT_FILL_TITLE_MACRO(action_get_title_browser_directory, MENU_ENUM_LABEL_VALUE_RGUI_BROWSER_DIRECTORY) +DEFAULT_FILL_TITLE_MACRO(action_get_title_use_last_start_directory, MENU_ENUM_LABEL_VALUE_USE_LAST_START_DIRECTORY) DEFAULT_FILL_TITLE_MACRO(action_get_title_content_directory, MENU_ENUM_LABEL_VALUE_CONTENT_DIR) DEFAULT_FILL_TITLE_MACRO(action_get_title_screenshot_directory, MENU_ENUM_LABEL_VALUE_SCREENSHOT_DIRECTORY) DEFAULT_FILL_TITLE_MACRO(action_get_title_cursor_directory, MENU_ENUM_LABEL_VALUE_CURSOR_DIRECTORY) @@ -973,6 +974,8 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, #endif {MENU_ENUM_LABEL_RGUI_BROWSER_DIRECTORY, action_get_title_browser_directory}, + {MENU_ENUM_LABEL_USE_LAST_START_DIRECTORY, + action_get_title_use_last_start_directory}, {MENU_ENUM_LABEL_PLAYLIST_DIRECTORY, action_get_title_playlist_directory}, {MENU_ENUM_LABEL_RUNTIME_LOG_DIRECTORY, @@ -1238,6 +1241,9 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_RGUI_BROWSER_DIRECTORY: BIND_ACTION_GET_TITLE(cbs, action_get_title_browser_directory); break; + case MENU_ENUM_LABEL_USE_LAST_START_DIRECTORY: + BIND_ACTION_GET_TITLE(cbs, action_get_title_use_last_start_directory); + break; case MENU_ENUM_LABEL_PLAYLIST_DIRECTORY: BIND_ACTION_GET_TITLE(cbs, action_get_title_playlist_directory); break; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index fd7d51ff17..0a23e8ed18 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -8868,7 +8868,7 @@ static int materialui_list_push(void *data, void *userdata, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES), msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES), MENU_ENUM_LABEL_FAVORITES, - MENU_SETTING_ACTION, 0, 0); + MENU_SETTING_ACTION_FAVORITES_DIR, 0, 0); core_info_get_list(&list); if (core_info_list_num_info_files(list)) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index f381ee9a20..12dcfc33da 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -1442,7 +1442,7 @@ static int ozone_list_push(void *data, void *userdata, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES), msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES), MENU_ENUM_LABEL_FAVORITES, - MENU_SETTING_ACTION, 0, 0); + MENU_SETTING_ACTION_FAVORITES_DIR, 0, 0); core_info_get_list(&list); if (core_info_list_num_info_files(list)) diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index d1355bbe62..c300edc972 100644 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -4152,7 +4152,7 @@ static int stripes_list_push(void *data, void *userdata, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES), msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES), MENU_ENUM_LABEL_FAVORITES, - MENU_SETTING_ACTION, 0, 0); + MENU_SETTING_ACTION_FAVORITES_DIR, 0, 0); core_info_get_list(&list); if (core_info_list_num_info_files(list)) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index ddc09d8a2e..c0e8d8e946 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -6702,7 +6702,7 @@ static int xmb_list_push(void *data, void *userdata, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES), msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES), MENU_ENUM_LABEL_FAVORITES, - MENU_SETTING_ACTION, 0, 0); + MENU_SETTING_ACTION_FAVORITES_DIR, 0, 0); core_info_get_list(&list); if (core_info_list_num_info_files(list)) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index e8273d5f43..12ed9d0b46 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5851,7 +5851,7 @@ unsigned menu_displaylist_build_list( msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FAVORITES), msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES), MENU_ENUM_LABEL_FAVORITES, - MENU_SETTING_ACTION, 0, 0)) + MENU_SETTING_ACTION_FAVORITES_DIR, 0, 0)) count++; #if defined(HAVE_LIBRETRODB) @@ -7589,6 +7589,7 @@ unsigned menu_displaylist_build_list( {MENU_ENUM_LABEL_USE_BUILTIN_PLAYER, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_USE_BUILTIN_IMAGE_VIEWER, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_FILTER_BY_CURRENT_CORE, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_USE_LAST_START_DIRECTORY, PARSE_ONLY_BOOL}, }; for (i = 0; i < ARRAY_SIZE(build_list); i++) @@ -12970,6 +12971,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, else { settings_t *settings = config_get_ptr(); + const char *pending_selection = menu_driver_get_pending_selection(); bool show_hidden_files = settings->bools.show_hidden_files; bool multimedia_builtin_mediaplayer_enable = settings->bools.multimedia_builtin_mediaplayer_enable; bool multimedia_builtin_imageviewer_enable = settings->bools.multimedia_builtin_imageviewer_enable; @@ -12981,6 +12983,22 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, multimedia_builtin_imageviewer_enable, menu_navigation_browser_filter_supported_extensions_enable ); + + /* Apply pending selection */ + if (!string_is_empty(pending_selection)) + { + size_t selection_idx = 0; + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + + if (selection_buf && + file_list_search(selection_buf, pending_selection, &selection_idx)) + { + menu_navigation_set_selection(selection_idx); + menu_driver_navigation_set(true); + } + + menu_driver_set_pending_selection(NULL); + } } info->need_refresh = true; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 405b299b5a..b658cb9645 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -114,6 +114,7 @@ enum menu_settings_type MENU_SETTING_ACTION_RESET, MENU_SETTING_ACTION_CORE_LOCK, MENU_SETTING_ACTION_CORE_DELETE, + MENU_SETTING_ACTION_FAVORITES_DIR, /* "Start Directory" */ MENU_SETTING_STRING_OPTIONS, MENU_SETTING_GROUP, MENU_SETTING_SUBGROUP, @@ -346,6 +347,14 @@ typedef struct char pass_dir[PATH_MAX_LENGTH]; } last_shader_selection; + /* Used to cache the last start content + * loaded via the menu file browser */ + struct + { + char directory[PATH_MAX_LENGTH]; + char file_name[PATH_MAX_LENGTH]; + } last_start_content; + char menu_state_msg[8192]; /* Scratchpad variables. These are used for instance * by the filebrowser when having to store intermediary @@ -525,6 +534,12 @@ const char *menu_driver_get_last_shader_preset_dir(void); const char *menu_driver_get_last_shader_pass_dir(void); #endif +const char *menu_driver_get_last_start_directory(void); +const char *menu_driver_get_last_start_file_name(void); +void menu_driver_set_last_start_content(const char *start_content_path); +const char *menu_driver_get_pending_selection(); +void menu_driver_set_pending_selection(const char *pending_selection); + menu_handle_t *menu_driver_get_ptr(void); enum action_iterate_type diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 8997fcee44..44e248ff49 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -15664,6 +15664,21 @@ static bool setting_append_list( general_read_handler, SD_FLAG_NONE); + CONFIG_BOOL( + list, list_info, + &settings->bools.use_last_start_directory, + MENU_ENUM_LABEL_USE_LAST_START_DIRECTORY, + MENU_ENUM_LABEL_VALUE_USE_LAST_START_DIRECTORY, + false, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); + END_SUB_GROUP(list, list_info, parent_group); END_GROUP(list, list_info, parent_group); break; diff --git a/msg_hash.h b/msg_hash.h index 73b7952459..daaf3241f8 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1859,6 +1859,7 @@ enum msg_hash_enums MENU_LABEL(CONFIGURATION_LIST), MENU_LABEL(CONFIRM_ON_EXIT), MENU_LABEL(SHOW_HIDDEN_FILES), + MENU_LABEL(USE_LAST_START_DIRECTORY), /* Driver settings */ diff --git a/retroarch.c b/retroarch.c index 57f0cdd267..6a8629f56f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -4532,7 +4532,6 @@ static const char *menu_driver_get_last_shader_dir_int( return shader_dir; } - const char *menu_driver_get_last_shader_preset_dir(void) { struct rarch_state *p_rarch = &rarch_st; @@ -4567,6 +4566,118 @@ const char *menu_driver_get_last_shader_pass_dir(void) #endif +const char *menu_driver_get_last_start_directory(void) +{ + struct rarch_state *p_rarch = &rarch_st; + menu_handle_t *menu = p_rarch->menu_driver_data; + settings_t *settings = p_rarch->configuration_settings; + bool use_last = settings->bools.use_last_start_directory; + const char *default_directory = settings->paths.directory_menu_content; + + /* Return default directory if there is no + * last directory or it's invalid */ + if (!menu || + !use_last || + string_is_empty(menu->last_start_content.directory) || + !path_is_directory(menu->last_start_content.directory)) + return default_directory; + + return menu->last_start_content.directory; +} + +const char *menu_driver_get_last_start_file_name(void) +{ + struct rarch_state *p_rarch = &rarch_st; + menu_handle_t *menu = p_rarch->menu_driver_data; + settings_t *settings = p_rarch->configuration_settings; + bool use_last = settings->bools.use_last_start_directory; + + /* Return NULL if there is no last 'file name' */ + if (!menu || + !use_last || + string_is_empty(menu->last_start_content.file_name)) + return NULL; + + return menu->last_start_content.file_name; +} + +void menu_driver_set_last_start_content(const char *start_content_path) +{ + struct rarch_state *p_rarch = &rarch_st; + menu_handle_t *menu = p_rarch->menu_driver_data; + settings_t *settings = p_rarch->configuration_settings; + bool use_last = settings->bools.use_last_start_directory; + const char *archive_delim = NULL; + const char *file_name = NULL; + char archive_path[PATH_MAX_LENGTH]; + + if (!menu) + return; + + /* Reset existing cache */ + menu->last_start_content.directory[0] = '\0'; + menu->last_start_content.file_name[0] = '\0'; + + /* If 'use_last_start_directory' is disabled or + * path is empty, do nothing */ + if (!use_last || + string_is_empty(start_content_path)) + return; + + /* Cache directory */ + fill_pathname_parent_dir(menu->last_start_content.directory, + start_content_path, sizeof(menu->last_start_content.directory)); + + /* Cache file name */ + archive_delim = path_get_archive_delim(start_content_path); + if (archive_delim) + { + /* If path references a file inside an + * archive, must extract the string segment + * before the archive delimiter (i.e. path of + * 'parent' archive file) */ + size_t len; + + archive_path[0] = '\0'; + len = (size_t)(1 + archive_delim - start_content_path); + len = (len < PATH_MAX_LENGTH) ? len : PATH_MAX_LENGTH; + + strlcpy(archive_path, start_content_path, len * sizeof(char)); + + file_name = path_basename(archive_path); + } + else + file_name = path_basename(start_content_path); + + if (!string_is_empty(file_name)) + strlcpy(menu->last_start_content.file_name, file_name, + sizeof(menu->last_start_content.file_name)); +} + +const char *menu_driver_get_pending_selection() +{ + struct rarch_state *p_rarch = &rarch_st; + struct menu_state *menu_st = &p_rarch->menu_driver_state; + return menu_st->pending_selection; +} + +void menu_driver_set_pending_selection(const char *pending_selection) +{ + struct rarch_state *p_rarch = &rarch_st; + struct menu_state *menu_st = &p_rarch->menu_driver_state; + char *selection = menu_st->pending_selection; + + /* Reset existing cache */ + selection[0] = '\0'; + + /* If path is empty, do nothing */ + if (string_is_empty(pending_selection)) + return; + + strlcpy(selection, pending_selection, + sizeof(menu_st->pending_selection)); +} + bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) { struct rarch_state *p_rarch = &rarch_st; diff --git a/retroarch_data.h b/retroarch_data.h index f8d6850fcf..4e90eb5318 100644 --- a/retroarch_data.h +++ b/retroarch_data.h @@ -1591,6 +1591,11 @@ struct menu_state * representation string */ char datetime_cache[255]; + /* When generating a menu list in menu_displaylist_build_list(), + * the entry with a label matching 'pending_selection' will + * be selected automatically */ + char pending_selection[PATH_MAX_LENGTH]; + /* when enabled, on next iteration the 'Quick Menu' list will * be pushed onto the stack */ bool pending_quick_menu;