diff --git a/menu/menu_entries_cbs_ok.c b/menu/menu_entries_cbs_ok.c index 8bff5ed8a6..d4c9bba5b4 100644 --- a/menu/menu_entries_cbs_ok.c +++ b/menu/menu_entries_cbs_ok.c @@ -39,9 +39,9 @@ static int menu_action_setting_set_current_string_path( return menu_setting_generic(setting); } -static int action_ok_rdb_playlist_entry(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_rdb_playlist_entry(menu_displaylist_info_t *info) { + (void)info; menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) return -1; @@ -51,8 +51,7 @@ static int action_ok_rdb_playlist_entry(const char *path, return -1; } -static int action_ok_playlist_entry(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_playlist_entry(menu_displaylist_info_t *info) { menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) @@ -64,10 +63,7 @@ static int action_ok_playlist_entry(const char *path, return -1; } - - -static int action_ok_cheat_apply_changes(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_cheat_apply_changes(menu_displaylist_info_t *info) { global_t *global = global_get_ptr(); cheat_manager_t *cheat = global->cheat; @@ -81,8 +77,7 @@ static int action_ok_cheat_apply_changes(const char *path, } -static int action_ok_shader_pass_load(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_shader_pass_load(menu_displaylist_info_t *info) { const char *menu_path = NULL; menu_handle_t *menu = menu_driver_get_ptr(); @@ -96,7 +91,7 @@ static int action_ok_shader_pass_load(const char *path, NULL); fill_pathname_join(menu->shader->pass[hack_shader_pass].source.path, - menu_path, path, + menu_path, info->path, sizeof(menu->shader->pass[hack_shader_pass].source.path)); /* This will reset any changed parameters. */ @@ -112,223 +107,130 @@ static int action_ok_shader_pass_load(const char *path, extern size_t hack_shader_pass; #endif -static int action_ok_shader_pass(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_shader_pass(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; - hack_shader_pass = type - MENU_SETTINGS_SHADER_PASS_0; - menu_handle_t *menu = menu_driver_get_ptr(); + hack_shader_pass = info->type - MENU_SETTINGS_SHADER_PASS_0; settings_t *settings = config_get_ptr(); - if (!menu) - return -1; + if (settings) + strlcpy(info->path, settings->video.shader_dir, sizeof(info->path)); - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; - strlcpy(info.path, settings->video.shader_dir, sizeof(info.path)); - strlcpy(info.label, label, sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_shader_parameters(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_shader_parameters(menu_displaylist_info_t *info) +{ + info->type = MENU_SETTING_ACTION; + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); +} + +static int action_ok_push_generic_list(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) return -1; - info.list = menu->menu_list->menu_stack; - info.type = MENU_SETTING_ACTION; - info.directory_ptr = idx; - strlcpy(info.label, label, sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); -} - -static int action_ok_push_generic_list(const char *path, - const char *label, unsigned type, size_t idx) -{ - menu_displaylist_info_t info = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); - if (!menu) - return -1; - - if (path) - strlcpy(menu->deferred_path, path, + if (info->path) + strlcpy(menu->deferred_path, info->path, sizeof(menu->deferred_path)); - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; - strlcpy(info.label, label, sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_push_default(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_push_default(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); - if (!menu) - return -1; - - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; - strlcpy(info.path, label, sizeof(info.path)); - strlcpy(info.label, label, sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_shader_preset(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_shader_preset(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); - if (!menu) - return -1; + if (settings) + strlcpy(info->path, settings->video.shader_dir, sizeof(info->path)); - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; - strlcpy(info.path, settings->video.shader_dir, sizeof(info.path)); - strlcpy(info.label, label, sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_push_content_list(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_push_content_list(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); - if (!menu) - return -1; + info->type = MENU_FILE_DIRECTORY; + if (settings) + strlcpy(info->path, settings->menu_content_directory, sizeof(info->path)); - info.list = menu->menu_list->menu_stack; - info.type = MENU_FILE_DIRECTORY; - info.directory_ptr = idx; - strlcpy(info.path, settings->menu_content_directory, sizeof(info.path)); - strlcpy(info.label, label, sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_disk_image_append_list(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_disk_image_append_list(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); - if (!menu) - return -1; + if (settings) + strlcpy(info->path, settings->menu_content_directory, sizeof(info->path)); - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; - strlcpy(info.path, settings->menu_content_directory, sizeof(info.path)); - strlcpy(info.label, label, sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_configurations_list(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_configurations_list(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; settings_t *settings = config_get_ptr(); - menu_handle_t *menu = menu_driver_get_ptr(); - const char *dir = settings->menu_config_directory; - if (!menu) - return -1; + const char *dir = settings ? settings->menu_config_directory : NULL; - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; if (dir) - strlcpy(info.path, dir, sizeof(info.path)); + strlcpy(info->path, dir, sizeof(info->path)); else - strlcpy(info.path, label, sizeof(info.path)); - strlcpy(info.label, label, sizeof(info.label)); + strlcpy(info->path, info->label, sizeof(info->path)); - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_cheat_file(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_cheat_file(menu_displaylist_info_t *info) +{ + settings_t *settings = config_get_ptr(); + + if (settings) + strlcpy(info->path, settings->cheat_database, sizeof(info->path)); + + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); +} + +static int action_ok_audio_dsp_plugin(menu_displaylist_info_t *info) +{ + settings_t *settings = config_get_ptr(); + + info->type = 0; + if (settings) + strlcpy(info->path, settings->audio.filter_dir, sizeof(info->path)); + strlcpy(info->label, "audio_dsp_plugin", sizeof(info->label)); + + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); +} + +static int action_ok_video_filter(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); if (!menu) return -1; - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; - strlcpy(info.path, settings->cheat_database, sizeof(info.path)); - strlcpy(info.label, label, sizeof(info.label)); + info->type = 0; + strlcpy(info->path, settings->video.filter_dir, sizeof(info->path)); + strlcpy(info->label, "deferred_video_filter", sizeof(info->label)); - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_audio_dsp_plugin(const char *path, - const char *label, unsigned type, size_t idx) -{ - menu_displaylist_info_t info = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); - settings_t *settings = config_get_ptr(); - if (!menu) - return -1; - - info.list = menu->menu_list->menu_stack; - info.type = 0; - info.directory_ptr = idx; - strlcpy(info.path, settings->audio.filter_dir, sizeof(info.path)); - strlcpy(info.label, "audio_dsp_plugin", sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); -} - -static int action_ok_video_filter(const char *path, - const char *label, unsigned type, size_t idx) -{ - menu_displaylist_info_t info = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); - settings_t *settings = config_get_ptr(); - if (!menu) - return -1; - - info.list = menu->menu_list->menu_stack; - info.type = 0; - info.directory_ptr = idx; - strlcpy(info.path, settings->video.filter_dir, sizeof(info.path)); - strlcpy(info.label, "deferred_video_filter", sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); -} - -static int action_ok_core_updater_list(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_core_updater_list(menu_displaylist_info_t *info) { char url_path[PATH_MAX_LENGTH]; - menu_displaylist_info_t info = {0}; menu_handle_t *menu = menu_driver_get_ptr(); driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); if (!menu) return -1; - driver->menu->nonblocking_refresh = true; + menu->nonblocking_refresh = true; (void)url_path; @@ -345,73 +247,43 @@ static int action_ok_core_updater_list(const char *path, true); #endif - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; - strlcpy(info.path, path, sizeof(info.path)); - strlcpy(info.label, "deferred_core_updater_list", sizeof(info.label)); + strlcpy(info->label, "deferred_core_updater_list", sizeof(info->label)); - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_remap_file(const char *path, - const char *label, unsigned type, size_t idx) + +static int action_ok_remap_file(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); - if (!menu) - return -1; + if (settings) + strlcpy(info->path, + settings->input_remapping_directory, sizeof(info->path)); - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; - strlcpy(info.path, settings->input_remapping_directory, sizeof(info.path)); - strlcpy(info.label, label, sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_record_configfile(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_record_configfile(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); global_t *global = global_get_ptr(); - if (!menu) - return -1; + if (global) + strlcpy(info->path, global->record.config_dir, sizeof(info->path)); - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; - strlcpy(info.path, global->record.config_dir, sizeof(info.path)); - strlcpy(info.label, label, sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_core_list(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_core_list(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; - menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); - if (!menu) - return -1; + if (settings) + strlcpy(info->path, settings->libretro_directory, sizeof(info->path)); - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; - strlcpy(info.path, settings->libretro_directory, sizeof(info.path)); - strlcpy(info.label, label, sizeof(info.label)); - - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_record_configfile_load(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_record_configfile_load(menu_displaylist_info_t *info) { const char *menu_path = NULL; global_t *global = global_get_ptr(); @@ -422,14 +294,14 @@ static int action_ok_record_configfile_load(const char *path, menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); - fill_pathname_join(global->record.config, menu_path, path, sizeof(global->record.config)); + fill_pathname_join(global->record.config, + menu_path, info->path, sizeof(global->record.config)); menu_list_flush_stack_by_needle(menu->menu_list, "Recording Settings"); return 0; } -static int action_ok_remap_file_load(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_remap_file_load(menu_displaylist_info_t *info) { const char *menu_path = NULL; char remap_path[PATH_MAX_LENGTH]; @@ -443,7 +315,7 @@ static int action_ok_remap_file_load(const char *path, menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); - fill_pathname_join(remap_path, menu_path, path, sizeof(remap_path)); + fill_pathname_join(remap_path, menu_path, info->path, sizeof(remap_path)); input_remapping_load_file(remap_path); menu_list_flush_stack_by_needle(menu->menu_list, "core_input_remapping_options"); @@ -451,8 +323,7 @@ static int action_ok_remap_file_load(const char *path, return 0; } -static int action_ok_video_filter_file_load(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_video_filter_file_load(menu_displaylist_info_t *info) { char filter_path[PATH_MAX_LENGTH]; const char *menu_path = NULL; @@ -468,7 +339,8 @@ static int action_ok_video_filter_file_load(const char *path, menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); - fill_pathname_join(filter_path, menu_path, path, sizeof(filter_path)); + fill_pathname_join(filter_path, + menu_path, info->path, sizeof(filter_path)); strlcpy(settings->video.softfilter_plugin, filter_path, sizeof(settings->video.softfilter_plugin)); @@ -480,8 +352,7 @@ static int action_ok_video_filter_file_load(const char *path, return 0; } -static int action_ok_cheat_file_load(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_cheat_file_load(menu_displaylist_info_t *info) { const char *menu_path = NULL; char cheat_path[PATH_MAX_LENGTH]; @@ -495,7 +366,7 @@ static int action_ok_cheat_file_load(const char *path, menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); - fill_pathname_join(cheat_path, menu_path, path, sizeof(cheat_path)); + fill_pathname_join(cheat_path, menu_path, info->path, sizeof(cheat_path)); if (global->cheat) cheat_manager_free(global->cheat); @@ -510,8 +381,7 @@ static int action_ok_cheat_file_load(const char *path, return 0; } -static int action_ok_menu_wallpaper_load(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_menu_wallpaper_load(menu_displaylist_info_t *info) { char wallpaper_path[PATH_MAX_LENGTH]; const char *menu_label = NULL; @@ -522,15 +392,15 @@ static int action_ok_menu_wallpaper_load(const char *path, if (!menu) return -1; - menu_list_get_last_stack(menu->menu_list, &menu_path, &menu_label, - NULL); + menu_list_get_last_stack(menu->menu_list, + &menu_path, &menu_label, NULL); setting = menu_setting_find(menu_label); if (!setting) return -1; - fill_pathname_join(wallpaper_path, menu_path, path, sizeof(wallpaper_path)); + fill_pathname_join(wallpaper_path, menu_path, info->path, sizeof(wallpaper_path)); if (path_file_exists(wallpaper_path)) { @@ -545,8 +415,7 @@ static int action_ok_menu_wallpaper_load(const char *path, return 0; } -static int action_ok_shader_preset_load(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_shader_preset_load(menu_displaylist_info_t *info) { const char *menu_path = NULL; char shader_path[PATH_MAX_LENGTH]; @@ -560,7 +429,7 @@ static int action_ok_shader_preset_load(const char *path, menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); - fill_pathname_join(shader_path, menu_path, path, sizeof(shader_path)); + fill_pathname_join(shader_path, menu_path, info->path, sizeof(shader_path)); menu_shader_manager_set_preset(menu->shader, video_shader_parse_type(shader_path, RARCH_SHADER_NONE), shader_path); @@ -571,50 +440,48 @@ static int action_ok_shader_preset_load(const char *path, #endif } -static int action_ok_cheat(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_cheat(menu_displaylist_info_t *info) { menu_input_key_start_line("Input Cheat", - label, type, idx, menu_input_st_cheat_callback); + info->label, info->type, + info->directory_ptr, menu_input_st_cheat_callback); return 0; } -static int action_ok_shader_preset_save_as(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_shader_preset_save_as(menu_displaylist_info_t *info) { menu_input_key_start_line("Preset Filename", - label, type, idx, menu_input_st_string_callback); + info->label, info->type, info->directory_ptr, + menu_input_st_string_callback); return 0; } -static int action_ok_cheat_file_save_as(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_cheat_file_save_as(menu_displaylist_info_t *info) { menu_input_key_start_line("Cheat Filename", - label, type, idx, menu_input_st_string_callback); + info->label, info->type, + info->directory_ptr, menu_input_st_string_callback); return 0; } -static int action_ok_remap_file_save_as(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_remap_file_save_as(menu_displaylist_info_t *info) { menu_input_key_start_line("Remapping Filename", - label, type, idx, menu_input_st_string_callback); + info->label, info->type, info->directory_ptr, + menu_input_st_string_callback); return 0; } -static int action_ok_remap_file_save_core(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_remap_file_save_core(menu_displaylist_info_t *info) { + char directory[PATH_MAX_LENGTH]; + char file[PATH_MAX_LENGTH]; + const char *core_name; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - const char *core_name; core_name = global->system.info.library_name; - char directory[PATH_MAX_LENGTH]; - char file[PATH_MAX_LENGTH]; - fill_pathname_join(directory,settings->input_remapping_directory,core_name,PATH_MAX_LENGTH); fill_pathname_join(file,core_name,core_name,PATH_MAX_LENGTH); @@ -629,21 +496,17 @@ static int action_ok_remap_file_save_core(const char *path, return 0; } -static int action_ok_remap_file_save_game(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_remap_file_save_game(menu_displaylist_info_t *info) { + char directory[PATH_MAX_LENGTH]; + char file[PATH_MAX_LENGTH]; + const char *core_name, *game_name; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - const char *core_name; core_name = global->system.info.library_name; - - const char *game_name; game_name = path_basename(global->basename); - char directory[PATH_MAX_LENGTH]; - char file[PATH_MAX_LENGTH]; - fill_pathname_join(directory,settings->input_remapping_directory,core_name,PATH_MAX_LENGTH); fill_pathname_join(file,core_name,game_name,PATH_MAX_LENGTH); @@ -658,8 +521,7 @@ static int action_ok_remap_file_save_game(const char *path, return 0; } -static int action_ok_path_use_directory(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_path_use_directory(menu_displaylist_info_t *info) { const char *menu_label = NULL; const char *menu_path = NULL; @@ -686,8 +548,7 @@ static int action_ok_path_use_directory(const char *path, return 0; } -static int action_ok_core_load_deferred(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_core_load_deferred(menu_displaylist_info_t *info) { menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); @@ -696,8 +557,8 @@ static int action_ok_core_load_deferred(const char *path, if (!menu) return -1; - if (path) - strlcpy(settings->libretro, path, sizeof(settings->libretro)); + if (info && info->path) + strlcpy(settings->libretro, info->path, sizeof(settings->libretro)); strlcpy(global->fullpath, menu->deferred_path, sizeof(global->fullpath)); @@ -706,41 +567,37 @@ static int action_ok_core_load_deferred(const char *path, return -1; } -static int action_ok_database_manager_list_deferred(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_database_manager_list_deferred(menu_displaylist_info_t *info) { + (void)info; + return 0; } -static int action_ok_rdb_entry(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_rdb_entry(menu_displaylist_info_t *info) { char tmp[PATH_MAX_LENGTH]; - menu_displaylist_info_t info = {0}; menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) return -1; strlcpy(tmp, "deferred_rdb_entry_detail|", sizeof(tmp)); - strlcat(tmp, path, sizeof(tmp)); + strlcat(tmp, info->path, sizeof(tmp)); - info.list = menu->menu_list->menu_stack; - info.type = 0; - info.directory_ptr = idx; - strlcpy(info.path, label, sizeof(info.path)); - strlcpy(info.label, tmp, sizeof(info.label)); + info->type = 0; + strlcpy(info->path, info->label, sizeof(info->path)); + strlcpy(info->label, tmp, sizeof(info->label)); - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_cursor_manager_list_deferred(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_cursor_manager_list_deferred(menu_displaylist_info_t *info) { + (void)info; return 0; } -static int action_ok_core_load(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_core_load(menu_displaylist_info_t *info) { const char *menu_path = NULL; menu_handle_t *menu = menu_driver_get_ptr(); @@ -755,7 +612,8 @@ static int action_ok_core_load(const char *path, menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); - fill_pathname_join(settings->libretro, menu_path, path, + fill_pathname_join(settings->libretro, menu_path, + info->path, sizeof(settings->libretro)); event_command(EVENT_CMD_LOAD_CORE); menu_list_flush_stack(menu->menu_list, MENU_SETTINGS); @@ -779,29 +637,26 @@ static int action_ok_core_load(const char *path, #endif } -static int action_ok_core_download(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_core_download(menu_displaylist_info_t *info) { + (void)info; return 0; } -static int action_ok_compressed_archive_push(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_compressed_archive_push(menu_displaylist_info_t *info) { menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) return -1; - menu_list_push(menu->menu_list->menu_stack, - path, "load_open_zip", 0, idx); + menu_list_push(info->list, info->path, + "load_open_zip", 0, info->directory_ptr); return 0; } -static int action_ok_directory_push(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_directory_push(menu_displaylist_info_t *info) { - menu_displaylist_info_t info = {0}; const char *menu_path = NULL; const char *menu_label = NULL; char cat_path[PATH_MAX_LENGTH]; @@ -809,55 +664,44 @@ static int action_ok_directory_push(const char *path, if (!menu) return -1; - if (!path) + if (!info || !info->path) return -1; menu_list_get_last_stack(menu->menu_list, &menu_path, &menu_label, NULL); - fill_pathname_join(cat_path, menu_path, path, sizeof(cat_path)); + fill_pathname_join(cat_path, menu_path, info->path, sizeof(cat_path)); - info.list = menu->menu_list->menu_stack; - info.type = type; - info.directory_ptr = idx; - strlcpy(info.path, cat_path, sizeof(info.path)); - strlcpy(info.label, menu_label, sizeof(info.label)); + strlcpy(info->path, cat_path, sizeof(info->path)); + strlcpy(info->label, menu_label, sizeof(info->label)); - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_database_manager_list(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_database_manager_list(menu_displaylist_info_t *info) { char rdb_path[PATH_MAX_LENGTH]; - menu_displaylist_info_t info = {0}; menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); if (!menu) return -1; - if (!path) - return -1; - if (!label) + if (!info || !info->path || !info->label) return -1; fill_pathname_join(rdb_path, settings->content_database, - path, sizeof(rdb_path)); + info->path, sizeof(rdb_path)); - info.list = menu->menu_list->menu_stack; - info.type = 0; - info.directory_ptr = idx; - strlcpy(info.path, rdb_path, sizeof(info.path)); - strlcpy(info.label, "deferred_database_manager_list", sizeof(info.label)); + info->type = 0; + strlcpy(info->path, rdb_path, sizeof(info->path)); + strlcpy(info->label, "deferred_database_manager_list", sizeof(info->label)); - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_cursor_manager_list(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_cursor_manager_list(menu_displaylist_info_t *info) { char cursor_path[PATH_MAX_LENGTH]; - menu_displaylist_info_t info = {0}; menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); @@ -865,19 +709,16 @@ static int action_ok_cursor_manager_list(const char *path, return -1; fill_pathname_join(cursor_path, settings->cursor_directory, - path, sizeof(cursor_path)); + info->path, sizeof(cursor_path)); - info.list = menu->menu_list->menu_stack; - info.type = 0; - info.directory_ptr = idx; - strlcpy(info.path, cursor_path, sizeof(info.path)); - strlcpy(info.label, "deferred_cursor_manager_list", sizeof(info.label)); + info->type = 0; + strlcpy(info->path, cursor_path, sizeof(info->path)); + strlcpy(info->label, "deferred_cursor_manager_list", sizeof(info->label)); - return menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + return menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } -static int action_ok_config_load(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_config_load(menu_displaylist_info_t *info) { const char *menu_path = NULL; char config[PATH_MAX_LENGTH]; @@ -889,7 +730,7 @@ static int action_ok_config_load(const char *path, menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); - fill_pathname_join(config, menu_path, path, sizeof(config)); + fill_pathname_join(config, menu_path, info->path, sizeof(config)); menu_list_flush_stack(menu->menu_list, MENU_SETTINGS); menu->msg_force = true; if (rarch_replace_config(config)) @@ -901,8 +742,7 @@ static int action_ok_config_load(const char *path, return 0; } -static int action_ok_disk_image_append(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_disk_image_append(menu_displaylist_info_t *info) { char image[PATH_MAX_LENGTH]; const char *menu_path = NULL; @@ -914,7 +754,7 @@ static int action_ok_disk_image_append(const char *path, menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); - fill_pathname_join(image, menu_path, path, sizeof(image)); + fill_pathname_join(image, menu_path, info->path, sizeof(image)); event_disk_control_append_image(image); event_command(EVENT_CMD_RESUME); @@ -923,11 +763,9 @@ static int action_ok_disk_image_append(const char *path, return -1; } -static int action_ok_file_load_with_detect_core(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_file_load_with_detect_core(menu_displaylist_info_t *info) { int ret; - menu_displaylist_info_t info = {0}; const char *menu_path = NULL; menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); @@ -940,7 +778,7 @@ static int action_ok_file_load_with_detect_core(const char *path, &menu_path, NULL, NULL); ret = rarch_defer_core(global->core_info, - menu_path, path, label, menu->deferred_path, + menu_path, info->path, info->label, menu->deferred_path, sizeof(menu->deferred_path)); if (ret == -1) @@ -952,20 +790,17 @@ static int action_ok_file_load_with_detect_core(const char *path, if (ret == 0) { - info.list = menu->menu_list->menu_stack; - info.type = 0; - info.directory_ptr = idx; - strlcpy(info.path, settings->libretro_directory, sizeof(info.path)); - strlcpy(info.label, "deferred_core_list", sizeof(info.label)); + info->type = 0; + strlcpy(info->path, settings->libretro_directory, sizeof(info->path)); + strlcpy(info->label, "deferred_core_list", sizeof(info->label)); - ret = menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + ret = menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); } return ret; } -static int action_ok_file_load(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_file_load(menu_displaylist_info_t *info) { const char *menu_label = NULL; const char *menu_path = NULL; @@ -983,16 +818,16 @@ static int action_ok_file_load(const char *path, if (setting && setting->type == ST_PATH) { - menu_action_setting_set_current_string_path(setting, menu_path, path); + menu_action_setting_set_current_string_path(setting, menu_path, info->path); menu_list_pop_stack_by_needle(menu->menu_list, setting->name); } else { - if (type == MENU_FILE_IN_CARCHIVE) - fill_pathname_join_delim(global->fullpath, menu_path, path, + if (info->type == MENU_FILE_IN_CARCHIVE) + fill_pathname_join_delim(global->fullpath, menu_path, info->path, '#',sizeof(global->fullpath)); else - fill_pathname_join(global->fullpath, menu_path, path, + fill_pathname_join(global->fullpath, menu_path, info->path, sizeof(global->fullpath)); menu_entries_common_load_content(true); @@ -1003,8 +838,7 @@ static int action_ok_file_load(const char *path, return 0; } -static int action_ok_set_path(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_set_path(menu_displaylist_info_t *info) { const char *menu_path = NULL; const char *menu_label = NULL; @@ -1022,14 +856,13 @@ static int action_ok_set_path(const char *path, if (!setting) return -1; - menu_action_setting_set_current_string_path(setting, menu_path, path); + menu_action_setting_set_current_string_path(setting, menu_path, info->path); menu_list_pop_stack_by_needle(menu->menu_list, setting->name); return 0; } -static int action_ok_custom_viewport(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_custom_viewport(menu_displaylist_info_t *info) { /* Start with something sane. */ global_t *global = global_get_ptr(); @@ -1040,13 +873,12 @@ static int action_ok_custom_viewport(const char *path, if (!menu) return -1; - menu_list_push( - menu->menu_list->menu_stack, + info->list, "", "custom_viewport_1", MENU_SETTINGS_CUSTOM_VIEWPORT, - idx); + info->directory_ptr); video_driver_viewport_info(custom); @@ -1067,35 +899,35 @@ static int generic_action_ok_command(enum event_command cmd) return 0; } -static int action_ok_load_state(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_load_state(menu_displaylist_info_t *info) { + (void)info; if (generic_action_ok_command(EVENT_CMD_LOAD_STATE) == -1) return -1; return generic_action_ok_command(EVENT_CMD_RESUME); } -static int action_ok_save_state(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_save_state(menu_displaylist_info_t *info) { + (void)info; + if (generic_action_ok_command(EVENT_CMD_SAVE_STATE) == -1) return -1; return generic_action_ok_command(EVENT_CMD_RESUME); } -static int action_ok_core_updater_download(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_core_updater_download(menu_displaylist_info_t *info) { #ifdef HAVE_NETWORKING char core_path[PATH_MAX_LENGTH], msg[PATH_MAX_LENGTH]; settings_t *settings = config_get_ptr(); fill_pathname_join(core_path, settings->network.buildbot_url, - path, sizeof(core_path)); + info->path, sizeof(core_path)); - strlcpy(core_updater_path, path, sizeof(core_updater_path)); - snprintf(msg, sizeof(msg), "Starting download: %s.", path); + strlcpy(core_updater_path, info->path, sizeof(core_updater_path)); + snprintf(msg, sizeof(msg), "Starting download: %s.", info->path); rarch_main_msg_queue_push(msg, 1, 90, true); @@ -1105,50 +937,46 @@ static int action_ok_core_updater_download(const char *path, return 0; } -static int action_ok_disk_cycle_tray_status(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_disk_cycle_tray_status(menu_displaylist_info_t *info) { return generic_action_ok_command(EVENT_CMD_DISK_EJECT_TOGGLE); } -static int action_ok_unload_core(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_unload_core(menu_displaylist_info_t *info) { return generic_action_ok_command(EVENT_CMD_UNLOAD_CORE); } -static int action_ok_quit(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_quit(menu_displaylist_info_t *info) { return generic_action_ok_command(EVENT_CMD_QUIT); } -static int action_ok_save_new_config(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_save_new_config(menu_displaylist_info_t *info) { + (void)info; return generic_action_ok_command(EVENT_CMD_MENU_SAVE_CONFIG); } -static int action_ok_resume_content(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_resume_content(menu_displaylist_info_t *info) { + (void)info; return generic_action_ok_command(EVENT_CMD_RESUME); } -static int action_ok_restart_content(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_restart_content(menu_displaylist_info_t *info) { + (void)info; + return generic_action_ok_command(EVENT_CMD_RESET); } -static int action_ok_screenshot(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_screenshot(menu_displaylist_info_t *info) { return generic_action_ok_command(EVENT_CMD_TAKE_SCREENSHOT); } -static int action_ok_file_load_or_resume(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_file_load_or_resume(menu_displaylist_info_t *info) { menu_handle_t *menu = menu_driver_get_ptr(); global_t *global = global_get_ptr(); @@ -1168,25 +996,23 @@ static int action_ok_file_load_or_resume(const char *path, } } -static int action_ok_shader_apply_changes(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_shader_apply_changes(menu_displaylist_info_t *info) { + (void)info; return generic_action_ok_command(EVENT_CMD_SHADERS_APPLY_CHANGES); } -static int action_ok_lookup_setting(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_lookup_setting(menu_displaylist_info_t *info) { - return menu_setting_set(type, label, MENU_ACTION_OK, false); + (void)info; + return menu_setting_set(info->type, info->label, MENU_ACTION_OK, false); } -static int action_ok_rdb_entry_submenu(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_rdb_entry_submenu(menu_displaylist_info_t *info) { int ret; union string_list_elem_attr attr; char new_label[PATH_MAX_LENGTH]; - menu_displaylist_info_t info = {0}; char *rdb = NULL; int len = 0; struct string_list *str_list = NULL; @@ -1196,10 +1022,10 @@ static int action_ok_rdb_entry_submenu(const char *path, if (!menu) return -1; - if (!label) + if (!info || !info->label) return -1; - str_list = string_split(label, "|"); + str_list = string_split(info->label, "|"); if (!str_list) return -1; @@ -1238,13 +1064,11 @@ static int action_ok_rdb_entry_submenu(const char *path, strlcpy(new_label, "deferred_cursor_manager_list_", sizeof(new_label)); strlcat(new_label, str_list->elems[0].data, sizeof(new_label)); - info.list = menu->menu_list->menu_stack; - info.type = 0; - info.directory_ptr = idx; - strlcpy(info.path, rdb, sizeof(info.path)); - strlcpy(info.label, new_label, sizeof(info.label)); + info->type = 0; + strlcpy(info->path, rdb, sizeof(info->path)); + strlcpy(info->label, new_label, sizeof(info->label)); - ret = menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); + ret = menu_displaylist_push_list(info, DISPLAYLIST_GENERIC); string_list_free(str_list); string_list_free(str_list2); @@ -1252,15 +1076,14 @@ static int action_ok_rdb_entry_submenu(const char *path, return ret; } -static int action_ok_help(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_help(menu_displaylist_info_t *info) { menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) return -1; menu_list_push( - menu->menu_list->menu_stack, + info->list, "", "help", 0, @@ -1270,8 +1093,7 @@ static int action_ok_help(const char *path, return 0; } -static int action_ok_video_resolution(const char *path, - const char *label, unsigned type, size_t idx) +static int action_ok_video_resolution(menu_displaylist_info_t *info) { unsigned width = 0, height = 0; global_t *global = global_get_ptr(); diff --git a/menu/menu_entry.c b/menu/menu_entry.c index c49b54da5c..8a08e11e31 100644 --- a/menu/menu_entry.c +++ b/menu/menu_entry.c @@ -451,6 +451,7 @@ int menu_entry_iterate(unsigned action) int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action) { + menu_displaylist_info_t info = {0}; menu_navigation_t *nav = menu_navigation_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); @@ -477,7 +478,14 @@ int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action) case MENU_ACTION_OK: if (cbs && cbs->action_ok) - return cbs->action_ok(entry->path, entry->label, entry->type, i); + { + info.list = menu_list->menu_stack; + info.type = entry->type; + info.directory_ptr = i; + strlcpy(info.path, entry->path, sizeof(info.path)); + strlcpy(info.label, entry->label, sizeof(info.label)); + return cbs->action_ok(&info); + } break; case MENU_ACTION_START: if (cbs && cbs->action_start) diff --git a/menu/menu_input.c b/menu/menu_input.c index 97125aab16..7f403077f4 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -716,7 +716,7 @@ static int menu_input_mouse_frame( return cbs->action_toggle(entry->type, entry->label, MENU_ACTION_RIGHT, true); if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L_OK)) - return cbs->action_ok(entry->path, entry->label, entry->type, nav->selection_ptr); + return menu_entry_action(entry, nav->selection_ptr, MENU_ACTION_OK); if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L_SET_NAVIGATION)) { @@ -846,7 +846,7 @@ static int pointer_tap(menu_file_list_cbs_t *cbs, || setting->type == ST_FLOAT || setting->type == ST_STRING)) return cbs->action_toggle(entry->type, entry->label, MENU_ACTION_RIGHT, true); else if (menu->pointer.ptr == menu->navigation.selection_ptr) - return cbs->action_ok(entry->path, entry->label, entry->type, menu->navigation.selection_ptr); + return menu_entry_action(entry, menu->navigation.selection_ptr, MENU_ACTION_OK); else menu_navigation_set(&menu->navigation, menu->pointer.ptr, false); diff --git a/menu/menu_list.h b/menu/menu_list.h index ea1337eeee..a5e76a15fa 100644 --- a/menu/menu_list.h +++ b/menu/menu_list.h @@ -36,8 +36,7 @@ typedef struct menu_file_list_cbs { int (*action_iterate)(const char *label, unsigned action); int (*action_deferred_push)(menu_displaylist_info_t *info); - int (*action_ok)(const char *path, const char *label, unsigned type, - size_t idx); + int (*action_ok)(menu_displaylist_info_t *info); int (*action_cancel)(const char *path, const char *label, unsigned type, size_t idx); int (*action_start)(unsigned type, const char *label, unsigned action);