diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 416914df35..c10162f806 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1830,6 +1830,56 @@ void handle_dbscan_finished(retro_task_t *task, void *task_data, void *user_data, const char *err); #endif +static void menu_driver_set_last_start_content(struct menu_state *menu_st, const char *start_content_path) +{ + char archive_path[PATH_MAX_LENGTH]; + menu_handle_t *menu = menu_st->driver_data; + settings_t *settings = config_get_ptr(); + bool use_last = settings->bools.use_last_start_directory; + const char *archive_delim = NULL; + const char *file_name = NULL; + + 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 */ + if ((archive_delim = path_get_archive_delim(start_content_path))) + { + /* 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 = (size_t)(1 + archive_delim - start_content_path); + if (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_nocompression(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)); +} + + static int file_load_with_detect_core_wrapper( enum msg_hash_enums enum_label_idx, size_t idx, size_t entry_idx, @@ -1837,7 +1887,8 @@ static int file_load_with_detect_core_wrapper( unsigned type, bool is_carchive) { int ret = 0; - menu_handle_t *menu = menu_state_get_ptr()->driver_data; + struct menu_state *menu_st = menu_state_get_ptr(); + menu_handle_t *menu = menu_st->driver_data; if (!menu) return -1; @@ -1906,7 +1957,7 @@ static int file_load_with_detect_core_wrapper( NULL, NULL)) return -1; - menu_driver_set_last_start_content(def_info.s); + menu_driver_set_last_start_content(menu_st, def_info.s); ret = 0; break; @@ -2295,6 +2346,7 @@ static int generic_action_ok(const char *path, static int default_action_ok_load_content_with_core_from_menu(const char *_path, unsigned _type) { content_ctx_info_t content_info; + struct menu_state *menu_st = menu_state_get_ptr(); content_info.argc = 0; content_info.argv = NULL; content_info.args = NULL; @@ -2303,7 +2355,7 @@ static int default_action_ok_load_content_with_core_from_menu(const char *_path, _path, &content_info, (enum rarch_core_type)_type, NULL, NULL)) return -1; - menu_driver_set_last_start_content(_path); + menu_driver_set_last_start_content(menu_st, _path); return 0; } @@ -3952,7 +4004,8 @@ static int action_ok_load_core_deferred(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { content_ctx_info_t content_info; - menu_handle_t *menu = menu_state_get_ptr()->driver_data; + struct menu_state *menu_st = menu_state_get_ptr(); + menu_handle_t *menu = menu_st->driver_data; content_info.argc = 0; content_info.argv = NULL; @@ -3968,7 +4021,7 @@ static int action_ok_load_core_deferred(const char *path, CORE_TYPE_PLAIN, NULL, NULL)) return -1; - menu_driver_set_last_start_content(path); + menu_driver_set_last_start_content(menu_st, path); return 0; } @@ -4459,7 +4512,8 @@ static int action_ok_file_load_detect_core(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { content_ctx_info_t content_info; - menu_handle_t *menu = menu_state_get_ptr()->driver_data; + struct menu_state *menu_st = menu_state_get_ptr(); + menu_handle_t *menu = menu_st->driver_data; if (!menu) return -1; @@ -4475,7 +4529,7 @@ static int action_ok_file_load_detect_core(const char *path, CORE_TYPE_PLAIN, NULL, NULL)) return -1; - menu_driver_set_last_start_content(menu->detect_content_path); + menu_driver_set_last_start_content(menu_st, menu->detect_content_path); return 0; } @@ -7156,7 +7210,7 @@ static int action_ok_load_archive_detect_core(const char *path, NULL, NULL)) ret = -1; else - menu_driver_set_last_start_content(def_info.s); + menu_driver_set_last_start_content(menu_st, def_info.s); } break; case 0: diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 1d3a4d879a..4883848791 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -3929,11 +3929,6 @@ static enum menu_driver_id_type menu_driver_set_id( return MENU_DRIVER_ID_UNKNOWN; } -const char *config_get_menu_driver_options(void) -{ - return char_list_new_special(STRING_LIST_MENU_DRIVERS, NULL); -} - static bool menu_entries_search_push(const char *search_term) { size_t i; @@ -4204,57 +4199,7 @@ end: menu_input_dialog_end(); } -void menu_driver_set_last_start_content(const char *start_content_path) -{ - char archive_path[PATH_MAX_LENGTH]; - menu_handle_t *menu = menu_driver_state.driver_data; - settings_t *settings = config_get_ptr(); - bool use_last = settings->bools.use_last_start_directory; - const char *archive_delim = NULL; - const char *file_name = NULL; - - 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 */ - if ((archive_delim = path_get_archive_delim(start_content_path))) - { - /* 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 = (size_t)(1 + archive_delim - start_content_path); - if (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_nocompression(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)); -} - -int menu_entry_action( - menu_entry_t *entry, size_t i, enum menu_action action) +int menu_entry_action(menu_entry_t *entry, size_t i, enum menu_action action) { struct menu_state *menu_st = &menu_driver_state; if ( menu_st->driver_ctx @@ -4739,7 +4684,12 @@ const char *menu_input_dialog_get_buffer(void) return *menu_st->input_dialog_keyboard_buffer; } -void menu_input_key_event(bool down, unsigned keycode, +/* This callback gets triggered by the keyboard whenever + * we press or release a keyboard key. When a keyboard + * key is being pressed down, 'down' will be true. If it + * is being released, 'down' will be false. + */ +static void menu_input_key_event(bool down, unsigned keycode, uint32_t character, uint16_t mod) { struct menu_state *menu_st = &menu_driver_state; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index e13ece1b2b..6b6375b25a 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -610,17 +610,6 @@ typedef struct menu_ctx_bind unsigned type; } menu_ctx_bind_t; -/** - * config_get_menu_driver_options: - * - * Get an enumerated list of all menu driver names, - * separated by '|'. - * - * Returns: string listing of all menu driver names, - * separated by '|'. - **/ -const char* config_get_menu_driver_options(void); - const char *menu_driver_ident(void); bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data); @@ -713,7 +702,6 @@ void menu_driver_get_last_shader_pass_path( const char **directory, const char **file_name); #endif -void menu_driver_set_last_start_content(const char *start_content_path); void menu_driver_set_pending_selection(const char *pending_selection); struct menu_state *menu_state_get_ptr(void); @@ -738,17 +726,6 @@ void menu_entries_build_scroll_indices( void get_current_menu_value(struct menu_state *menu_st, char *s, size_t len); -/** - * config_get_menu_driver_options: - * - * Get an enumerated list of all menu driver names, - * separated by '|'. - * - * Returns: string listing of all menu driver names, - * separated by '|'. - **/ -const char *config_get_menu_driver_options(void); - /* Teardown function for the menu driver. */ void menu_driver_destroy( struct menu_state *menu_st); @@ -760,14 +737,6 @@ extern menu_ctx_driver_t menu_ctx_mui; extern menu_ctx_driver_t menu_ctx_xmb; extern menu_ctx_driver_t menu_ctx_stripes; -/* This callback gets triggered by the keyboard whenever - * we press or release a keyboard key. When a keyboard - * key is being pressed down, 'down' will be true. If it - * is being released, 'down' will be false. - */ -void menu_input_key_event(bool down, unsigned keycode, - uint32_t character, uint16_t mod); - const menu_ctx_driver_t *menu_driver_find_driver( settings_t *settings, const char *prefix, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 7881eab2fc..9aa6c4e499 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -9255,6 +9255,21 @@ static int directory_action_start_generic(rarch_setting_t *setting) return 0; } +/** + * config_get_menu_driver_options: + * + * Get an enumerated list of all menu driver names, + * separated by '|'. + * + * Returns: string listing of all menu driver names, + * separated by '|'. + **/ +static const char *config_get_menu_driver_options(void) +{ + return char_list_new_special(STRING_LIST_MENU_DRIVERS, NULL); +} + + static bool setting_append_list( settings_t *settings, global_t *global,