From 59cce091869b8243620117e18b28779fe2ec9073 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sun, 20 Nov 2022 18:55:07 +0100 Subject: [PATCH] Menu cleanups: * Some control flow improvements in callback functions, less return paths * Remove menu_cbs_exit(), which was a stub function that always returned -1 --- menu/cbs/menu_cbs_deferred_push.c | 4 +- menu/cbs/menu_cbs_left.c | 12 +- menu/cbs/menu_cbs_ok.c | 163 +++++++++-------- menu/cbs/menu_cbs_right.c | 279 +++++++++++++++--------------- menu/cbs/menu_cbs_scan.c | 66 +++---- menu/cbs/menu_cbs_start.c | 8 +- menu/cbs/menu_cbs_sublabel.c | 69 ++++---- menu/cbs/menu_cbs_title.c | 191 ++++++++++---------- menu/menu_cbs.h | 2 - menu/menu_driver.c | 6 - 10 files changed, 384 insertions(+), 416 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index adfd1dff7c..5c6d6d9449 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -72,7 +72,7 @@ static int deferred_push_dlist( settings_t *settings) { if (!menu_displaylist_ctl(state, info, settings)) - return menu_cbs_exit(); + return -1; menu_displaylist_process(info); return 0; } @@ -411,7 +411,7 @@ static int general_push(menu_displaylist_info_t *info, bool filter_by_current_core = settings->bools.filter_by_current_core; if (!menu) - return menu_cbs_exit(); + return -1; core_info_get_list(&list); diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index e621a72511..cbac61fd39 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -85,7 +85,7 @@ static int shader_action_parameter_left_internal(unsigned type, const char *labe param_menu = shader ? &shader->parameters [type - offset] : NULL; if (!param_prev || !param_menu) - return menu_cbs_exit(); + return -1; ret = generic_shader_action_parameter_left(param_prev, type, label, wraparound); param_menu->current = param_prev->current; @@ -304,7 +304,7 @@ static int action_left_shader_scale_pass(unsigned type, const char *label, struct video_shader_pass *shader_pass = shader ? &shader->pass[pass] : NULL; if (!shader_pass) - return menu_cbs_exit(); + return -1; /* A 20x scale is used to support scaling handheld border shaders up to 8K resolutions */ current_scale = shader_pass->fbo.scale_x; @@ -332,7 +332,7 @@ static int action_left_shader_filter_pass(unsigned type, const char *label, struct video_shader_pass *shader_pass = shader ? &shader->pass[pass] : NULL; if (!shader_pass) - return menu_cbs_exit(); + return -1; shader_pass->filter = ((shader_pass->filter + delta) % 3); shader->flags |= SHDR_FLAG_MODIFIED; @@ -346,7 +346,7 @@ static int action_left_shader_filter_default(unsigned type, const char *label, rarch_setting_t *setting = menu_setting_find_enum( MENU_ENUM_LABEL_VIDEO_SMOOTH); if (!setting) - return menu_cbs_exit(); + return -1; return menu_action_handle_setting(setting, setting->type, MENU_ACTION_LEFT, wraparound); } @@ -378,7 +378,7 @@ static int action_left_shader_num_passes(unsigned type, const char *label, unsigned pass_count = shader ? shader->passes : 0; if (!shader) - return menu_cbs_exit(); + return -1; if (pass_count > 0) shader->passes--; @@ -419,7 +419,7 @@ static int playlist_association_left(unsigned type, const char *label, core_info_get_list(&core_info_list); if (!core_info_list) - return menu_cbs_exit(); + return -1; /* Get current core path association */ if (!string_is_empty(default_core_path) && diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 7015f4de23..70d72a509c 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -599,7 +599,7 @@ int generic_action_ok_displaylist_push(const char *path, if (!menu || string_is_equal(menu_ident, "null")) { menu_displaylist_info_free(&info); - return menu_cbs_exit(); + return -1; } #ifdef HAVE_AUDIOMIXER @@ -1662,7 +1662,7 @@ int generic_action_ok_displaylist_push(const char *path, } menu_displaylist_info_free(&info); - return menu_cbs_exit(); + return -1; } /** @@ -1774,7 +1774,7 @@ static int file_load_with_detect_core_wrapper( menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; { menu_content_ctx_defer_info_t def_info; @@ -1865,7 +1865,7 @@ static int action_ok_file_load_with_detect_core_carchive( menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; fill_pathname_join_delim(menu->detect_content_path, menu->detect_content_path, path, @@ -1929,7 +1929,7 @@ int generic_action_ok_command(enum event_command cmd) #endif if (!command_event(cmd, NULL)) - return menu_cbs_exit(); + return -1; return 0; } @@ -1955,7 +1955,7 @@ static int generic_action_ok(const char *path, #endif if (!menu) - goto error; + return -1; menu_entries_get_last_stack(&menu_path, &menu_label, NULL, &enum_idx, NULL); @@ -2130,7 +2130,7 @@ static int generic_action_ok(const char *path, cheat_manager_state_free(); if (!cheat_manager_load(action_path,false)) - goto error; + return -1; #endif break; case ACTION_OK_LOAD_CHEAT_FILE_APPEND: @@ -2138,7 +2138,7 @@ static int generic_action_ok(const char *path, flush_char = msg_hash_to_str(flush_id); if (!cheat_manager_load(action_path,true)) - goto error; + return -1; #endif break; case ACTION_OK_LOAD_RGUI_MENU_THEME_PRESET: @@ -2215,9 +2215,6 @@ static int generic_action_ok(const char *path, menu_entries_flush_stack(flush_char, flush_type); return ret; - -error: - return menu_cbs_exit(); } static int default_action_ok_load_content_with_core_from_menu(const char *_path, unsigned _type) @@ -2292,7 +2289,7 @@ static int action_ok_file_load(const char *path, * action */ menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; fill_pathname_join_special(menu_path_new, menu->scratch2_buf, menu->scratch_buf, @@ -2340,7 +2337,7 @@ static int action_ok_file_load(const char *path, { menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; fill_pathname_join_special(menu_path_new, menu->scratch2_buf, menu->scratch_buf, @@ -2641,7 +2638,7 @@ error: playlist = NULL; } - return menu_cbs_exit(); + return -1; } #ifdef HAVE_AUDIOMIXER @@ -2897,7 +2894,7 @@ static int action_ok_audio_add_to_mixer_and_collection(const char *path, menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; fill_pathname_join_special(combined_path, menu->scratch2_buf, menu->scratch_buf, sizeof(combined_path)); @@ -2927,7 +2924,7 @@ static int action_ok_audio_add_to_mixer_and_collection_and_play(const char *path menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; fill_pathname_join_special(combined_path, menu->scratch2_buf, menu->scratch_buf, sizeof(combined_path)); @@ -3014,21 +3011,21 @@ static int action_ok_wifi(const char *path, const char *label_setting, if (idx >= RBUF_LEN(scan->net_list)) return -1; + /* No need to ask for a password, should be stored */ if (scan->net_list[idx].saved_password) - { - /* No need to ask for a password, should be stored */ task_push_wifi_connect(NULL, &scan->net_list[idx]); - return 0; + else + { + /* Show password input dialog */ + line.label = "Passphrase"; + line.label_setting = label_setting; + line.type = type; + line.idx = (unsigned)idx; + line.cb = menu_input_wifi_cb; + if (!menu_input_dialog_start(&line)) + return -1; } - /* Show password input dialog */ - line.label = "Passphrase"; - line.label_setting = label_setting; - line.type = type; - line.idx = (unsigned)idx; - line.cb = menu_input_wifi_cb; - if (!menu_input_dialog_start(&line)) - return -1; return 0; } #endif @@ -3123,7 +3120,7 @@ static int action_ok_shader_pass(const char *path, menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; menu->scratchpad.unsigned_var = type - MENU_SETTINGS_SHADER_PASS_0; return generic_action_ok_displaylist_push(path, NULL, label, type, idx, @@ -3354,7 +3351,7 @@ static int action_ok_video_filter_remove(const char *path, settings_t *settings = config_get_ptr(); if (!settings) - return menu_cbs_exit(); + return -1; if (!string_is_empty(settings->paths.path_softfilter_plugin)) { @@ -3378,7 +3375,7 @@ static int action_ok_audio_dsp_plugin_remove(const char *path, settings_t *settings = config_get_ptr(); if (!settings) - return menu_cbs_exit(); + return -1; if (!string_is_empty(settings->paths.path_audio_dsp_plugin)) { @@ -3465,7 +3462,7 @@ static int generic_action_ok_remap_file_operation(const char *path, /* Cannot perform remap file operation if we * have no core */ if (string_is_empty(core_name)) - return menu_cbs_exit(); + return -1; switch (action_type) { @@ -3768,7 +3765,7 @@ static int action_ok_core_deferred_set(const char *new_core_path, if ( !menu || string_is_empty(new_core_path)) - return menu_cbs_exit(); + return -1; /* Get core display name */ if (core_info_find(new_core_path, &core_info)) @@ -3842,7 +3839,7 @@ static int action_ok_set_switch_cpu_profile(const char *path, runloop_msg_queue_push(command, 1, 90, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - return menu_cbs_exit(); + return -1; } #endif @@ -3869,7 +3866,7 @@ static int action_ok_set_switch_gpu_profile(const char *path, runloop_msg_queue_push(command, 1, 90, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - return menu_cbs_exit(); + return -1; } #endif @@ -3886,7 +3883,7 @@ static int action_ok_load_core_deferred(const char *path, content_info.environ_get = NULL; if (!menu) - return menu_cbs_exit(); + return -1; if (!task_push_load_content_with_new_core_from_menu( path, menu->deferred_path, @@ -3936,7 +3933,7 @@ static int action_ok_audio_run(const char *path, char combined_path[PATH_MAX_LENGTH]; menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; fill_pathname_join_special(combined_path, menu->scratch2_buf, menu->scratch_buf, sizeof(combined_path)); @@ -4370,7 +4367,7 @@ static int action_ok_file_load_current_core(const char *path, menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; return default_action_ok_load_content_with_core_from_menu( menu->detect_content_path, CORE_TYPE_PLAIN); @@ -4383,7 +4380,7 @@ static int action_ok_file_load_detect_core(const char *path, menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; content_info.argc = 0; content_info.argv = NULL; @@ -4409,7 +4406,7 @@ static int action_ok_load_state(const char *path, bool resume = settings->bools.menu_savestate_resume; if (generic_action_ok_command(CMD_EVENT_LOAD_STATE) == -1) - return menu_cbs_exit(); + return -1; if (resume) return generic_action_ok_command(CMD_EVENT_RESUME); @@ -4424,7 +4421,7 @@ static int action_ok_save_state(const char *path, bool resume = settings->bools.menu_savestate_resume; if (generic_action_ok_command(CMD_EVENT_SAVE_STATE) == -1) - return menu_cbs_exit(); + return -1; if (resume) return generic_action_ok_command(CMD_EVENT_RESUME); @@ -4450,7 +4447,7 @@ static int action_ok_undo_load_state(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { if (generic_action_ok_command(CMD_EVENT_UNDO_LOAD_STATE) == -1) - return menu_cbs_exit(); + return -1; return generic_action_ok_command(CMD_EVENT_RESUME); } @@ -4458,7 +4455,7 @@ static int action_ok_undo_save_state(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { if (generic_action_ok_command(CMD_EVENT_UNDO_SAVE_STATE) == -1) - return menu_cbs_exit(); + return -1; return generic_action_ok_command(CMD_EVENT_RESUME); } @@ -4511,7 +4508,7 @@ static int action_ok_core_updater_list(const char *path, core_list = core_updater_list_get_cached(); if (!core_list) - return menu_cbs_exit(); + return -1; } #if defined(ANDROID) @@ -4530,7 +4527,7 @@ static int action_ok_core_updater_list(const char *path, bool success = false; if (!available_cores) - return menu_cbs_exit(); + return -1; core_updater_list_reset(core_list); @@ -4543,7 +4540,7 @@ static int action_ok_core_updater_list(const char *path, string_list_free(available_cores); if (!success) - return menu_cbs_exit(); + return -1; /* Ensure network is initialised */ generic_action_ok_command(CMD_EVENT_NETWORK_INIT); @@ -4697,7 +4694,7 @@ static int generic_action_ok_network(const char *path, case MENU_ENUM_LABEL_CB_CORE_CONTENT_DIRS_LIST: if (string_is_empty(network_buildbot_assets_url)) - return menu_cbs_exit(); + return -1; fill_pathname_join_special(url_path, network_buildbot_assets_url, @@ -4718,7 +4715,7 @@ static int generic_action_ok_network(const char *path, break; case MENU_ENUM_LABEL_CB_CORE_SYSTEM_FILES_LIST: if (string_is_empty(network_buildbot_assets_url)) - return menu_cbs_exit(); + return -1; fill_pathname_join_special(url_path, network_buildbot_assets_url, "system/" FILE_PATH_INDEX_URL, @@ -5099,7 +5096,7 @@ static int action_ok_core_updater_download(const char *path, const char *path_dir_core_assets = settings->paths.directory_core_assets; if (!core_list) - return menu_cbs_exit(); + return -1; #if defined(ANDROID) /* Play Store builds install cores via @@ -5169,7 +5166,7 @@ static int action_ok_sideload_core(const char *path, const char *dir_libretro = settings->paths.directory_libretro; if (string_is_empty(core_file) || !menu) - return menu_cbs_exit(); + return -1; /* Get path of source (core 'backup') file */ menu_entries_get_last_stack( @@ -5353,7 +5350,7 @@ static int action_ok_set_core_association(const char *path, menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; /* TODO/FIXME - menu->rpl_entry_selection_ptr - find * a way so that we can remove this temporary state */ @@ -5369,13 +5366,13 @@ static int action_ok_reset_core_association(const char *path, menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; playlist_index = (size_t)menu->rpl_entry_selection_ptr; if (!command_event(CMD_EVENT_RESET_CORE_ASSOCIATION, (void *)&playlist_index)) - return menu_cbs_exit(); + return -1; return 0; } @@ -5492,7 +5489,7 @@ static int action_ok_add_to_favorites(const char *path, /* Trigger 'ADD_TO_FAVORITES' event */ if (!command_event(CMD_EVENT_ADD_TO_FAVORITES, (void*)str_list)) - ret = menu_cbs_exit(); + ret = -1; /* Clean up */ string_list_free(str_list); @@ -5515,7 +5512,7 @@ static int action_ok_add_to_favorites_playlist(const char *path, if (!playlist_curr) return 0; if (!menu) - return menu_cbs_exit(); + return -1; /* Read current playlist parameters */ playlist_get_index(playlist_curr, menu->rpl_entry_selection_ptr, &entry); @@ -5620,7 +5617,7 @@ static int action_ok_add_to_favorites_playlist(const char *path, /* Trigger 'ADD_TO_FAVORITES' event */ if (!command_event(CMD_EVENT_ADD_TO_FAVORITES, (void*)str_list)) - ret = menu_cbs_exit(); + ret = -1; /* Clean up */ string_list_free(str_list); @@ -5648,7 +5645,7 @@ static int action_ok_delete_entry(const char *path, menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; conf_path = playlist_get_conf_path(playlist); def_conf_path = playlist_get_conf_path(g_defaults.content_history); @@ -5702,7 +5699,7 @@ static int action_ok_rdb_entry_submenu(const char *path, struct string_list str_list2 = {0}; if (!label) - return menu_cbs_exit(); + return -1; new_label[0] = new_path[0] = '\0'; @@ -5969,7 +5966,7 @@ static int action_ok_netplay_connect_room(const char *path, const char *label, unsigned room_index = type - MENU_SETTINGS_NETPLAY_ROOMS_START; if (room_index >= (unsigned)net_st->room_count) - return menu_cbs_exit(); + return -1; room = &net_st->room_list[room_index]; @@ -6231,7 +6228,7 @@ int action_ok_push_filebrowser_list_dir_select(const char *path, menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; filebrowser_set_type(FILEBROWSER_SELECT_DIR); strlcpy(menu->filebrowser_label, label, sizeof(menu->filebrowser_label)); @@ -6245,7 +6242,7 @@ int action_ok_push_filebrowser_list_file_select(const char *path, menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; filebrowser_set_type(FILEBROWSER_SELECT_FILE); strlcpy(menu->filebrowser_label, label, sizeof(menu->filebrowser_label)); @@ -6465,7 +6462,7 @@ static int action_ok_push_dropdown_item_video_shader_num_pass(const char *path, struct video_shader *shader = menu_shader_get(); if (!shader) - return menu_cbs_exit(); + return -1; shader->passes = (unsigned)idx; @@ -6498,7 +6495,7 @@ static int action_ok_push_dropdown_item_video_shader_param_generic(const char *p param_menu = &shader->parameters [entry_idx - offset]; if (!param_prev || !param_menu) - return menu_cbs_exit(); + return -1; param_prev->current = val; param_menu->current = param_prev->current; @@ -6531,13 +6528,11 @@ static int action_ok_push_dropdown_item_video_shader_preset_param( static int action_ok_push_dropdown_item_resolution(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { + /* TODO/FIXME - menu drivers like XMB don't rescale + * automatically */ if (action_cb_push_dropdown_item_resolution(path, label, type, idx, entry_idx) == 1) - { - /* TODO/FIXME - menu drivers like XMB don't rescale - * automatically */ - return menu_cbs_exit(); - } + return -1; return 0; } @@ -6737,7 +6732,7 @@ static int action_ok_push_dropdown_item_input_device_type(const char *path, setting = menu_setting_find_enum(enum_idx); if (!setting) - return menu_cbs_exit(); + return -1; port = setting->index_offset; device = atoi(label); @@ -6765,7 +6760,7 @@ static int action_ok_push_dropdown_item_input_device_index(const char *path, setting = menu_setting_find_enum(enum_idx); if (!setting) - return menu_cbs_exit(); + return -1; settings->uints.input_joypad_index[setting->index_offset] = (unsigned)entry_idx; @@ -6785,7 +6780,7 @@ static int action_ok_push_dropdown_item_input_description(const char *path, (entry_type < MENU_SETTINGS_INPUT_DESC_BEGIN) || ((remap_idx >= RARCH_CUSTOM_BIND_LIST_END) && (remap_idx != RARCH_UNMAPPED))) - return menu_cbs_exit(); + return -1; /* Determine user/button indices */ user_idx = (entry_type - MENU_SETTINGS_INPUT_DESC_BEGIN) @@ -6794,7 +6789,7 @@ static int action_ok_push_dropdown_item_input_description(const char *path, - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx; if ((user_idx >= MAX_USERS) || (btn_idx >= RARCH_CUSTOM_BIND_LIST_END)) - return menu_cbs_exit(); + return -1; /* Assign new mapping */ settings->uints.input_remap_ids[user_idx][btn_idx] = remap_idx; @@ -6812,10 +6807,10 @@ static int action_ok_push_dropdown_item_input_description_kbd( unsigned user_idx; unsigned btn_idx; - if (!settings || - (entry_type < MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) || - (key_id >= (RARCH_MAX_KEYS + MENU_SETTINGS_INPUT_DESC_KBD_BEGIN))) - return menu_cbs_exit(); + if ( (!settings) + || (entry_type < MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) + || (key_id >= (RARCH_MAX_KEYS + MENU_SETTINGS_INPUT_DESC_KBD_BEGIN))) + return -1; /* Determine user/button indices */ user_idx = (entry_type - MENU_SETTINGS_INPUT_DESC_KBD_BEGIN) @@ -6824,7 +6819,7 @@ static int action_ok_push_dropdown_item_input_description_kbd( - RARCH_ANALOG_BIND_LIST_END * user_idx; if ((user_idx >= MAX_USERS) || (btn_idx >= RARCH_CUSTOM_BIND_LIST_END)) - return menu_cbs_exit(); + return -1; /* Assign new mapping */ settings->uints.input_keymapper_ids[user_idx][btn_idx] = key_id; @@ -6845,7 +6840,7 @@ static int action_ok_push_dropdown_item_netplay_mitm_server(const char *path, setting = menu_setting_find_enum(enum_idx); if (!setting) - return menu_cbs_exit(); + return -1; strlcpy(setting->value.target.string, label, setting->size); @@ -6904,7 +6899,7 @@ static int action_ok_contentless_core_run(const char *path, uint32_t flags = runloop_get_flags(); if (string_is_empty(core_path)) - return menu_cbs_exit(); + return -1; /* If core is already running, open quick menu */ if ( retroarch_ctl(RARCH_CTL_IS_CORE_LOADED, (void*)core_path) @@ -6944,7 +6939,7 @@ static int action_ok_load_archive(const char *path, menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; menu_path = menu->scratch2_buf; content_path = menu->scratch_buf; @@ -6972,7 +6967,7 @@ static int action_ok_load_archive_detect_core(const char *path, menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; menu_path = menu->scratch2_buf; content_path = menu->scratch_buf; @@ -7218,7 +7213,7 @@ static int action_ok_disk_cycle_tray_status(const char *path, bool menu_insert_disk_resume = settings->bools.menu_insert_disk_resume; if (!settings) - return menu_cbs_exit(); + return -1; #ifdef HAVE_AUDIOMIXER if (audio_enable_menu && audio_enable_menu_ok) @@ -7237,7 +7232,7 @@ static int action_ok_disk_cycle_tray_status(const char *path, print_log = menu_insert_disk_resume && disk_ejected; if (!command_event(CMD_EVENT_DISK_EJECT_TOGGLE, &print_log)) - return menu_cbs_exit(); + return -1; /* If we reach this point, then tray toggle * was successful */ @@ -7274,7 +7269,7 @@ static int action_ok_disk_image_append(const char *path, image_path[0] = '\0'; if (!menu) - return menu_cbs_exit(); + return -1; #ifdef HAVE_AUDIOMIXER if (audio_enable_menu && audio_enable_menu_ok) @@ -7769,7 +7764,7 @@ static int action_ok_pl_entry_content_thumbnails(const char *path, return -1; if (!menu) - return menu_cbs_exit(); + return -1; menu_driver_get_thumbnail_system(system, sizeof(system)); diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 7f644a4bf7..4a229ca270 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -85,7 +85,7 @@ static int generic_shader_action_parameter_right_internal(unsigned type, const c param_menu = shader ? &shader->parameters [type - offset] : NULL; if (!param_prev || !param_menu) - return menu_cbs_exit(); + return -1; ret = generic_shader_action_parameter_right(param_prev, type, label, wraparound); param_menu->current = param_prev->current; @@ -179,58 +179,53 @@ static int action_right_input_desc_kbd(unsigned type, const char *label, static int action_right_input_desc(unsigned type, const char *label, bool wraparound) { - unsigned btn_idx; - unsigned user_idx; - unsigned remap_idx; - unsigned bind_idx; - unsigned mapped_port; settings_t *settings = config_get_ptr(); rarch_system_info_t *system = &runloop_state_get_ptr()->system; - if (!settings || !system) - return 0; - - user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); - btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx; - mapped_port = settings->uints.input_remap_ports[user_idx]; - remap_idx = settings->uints.input_remap_ids[user_idx][btn_idx]; - - for (bind_idx = 0; bind_idx < RARCH_ANALOG_BIND_LIST_END; bind_idx++) + if (settings && system) { - if (input_config_bind_order[bind_idx] == remap_idx) - break; - } - - if (bind_idx < RARCH_CUSTOM_BIND_LIST_END - 1) - { - if (bind_idx > RARCH_ANALOG_BIND_LIST_END) - settings->uints.input_remap_ids[user_idx][btn_idx]++; - else + unsigned bind_idx; + unsigned user_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) / (RARCH_FIRST_CUSTOM_BIND + 8); + unsigned btn_idx = (type - MENU_SETTINGS_INPUT_DESC_BEGIN) - (RARCH_FIRST_CUSTOM_BIND + 8) * user_idx; + unsigned mapped_port = settings->uints.input_remap_ports[user_idx]; + unsigned remap_idx = settings->uints.input_remap_ids[user_idx][btn_idx]; + for (bind_idx = 0; bind_idx < RARCH_ANALOG_BIND_LIST_END; bind_idx++) { - if (bind_idx < RARCH_ANALOG_BIND_LIST_END - 1) - { - bind_idx++; - bind_idx = input_config_bind_order[bind_idx]; - } - else if (bind_idx == RARCH_ANALOG_BIND_LIST_END - 1) - bind_idx = RARCH_UNMAPPED; - else - bind_idx = input_config_bind_order[0]; - settings->uints.input_remap_ids[user_idx][btn_idx] = bind_idx; + if (input_config_bind_order[bind_idx] == remap_idx) + break; } - } - else if (bind_idx == RARCH_CUSTOM_BIND_LIST_END - 1) - settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_UNMAPPED; - else - settings->uints.input_remap_ids[user_idx][btn_idx] = input_config_bind_order[0]; - remap_idx = settings->uints.input_remap_ids[user_idx][btn_idx]; + if (bind_idx < RARCH_CUSTOM_BIND_LIST_END - 1) + { + if (bind_idx > RARCH_ANALOG_BIND_LIST_END) + settings->uints.input_remap_ids[user_idx][btn_idx]++; + else + { + if (bind_idx < RARCH_ANALOG_BIND_LIST_END - 1) + { + bind_idx++; + bind_idx = input_config_bind_order[bind_idx]; + } + else if (bind_idx == RARCH_ANALOG_BIND_LIST_END - 1) + bind_idx = RARCH_UNMAPPED; + else + bind_idx = input_config_bind_order[0]; + settings->uints.input_remap_ids[user_idx][btn_idx] = bind_idx; + } + } + else if (bind_idx == RARCH_CUSTOM_BIND_LIST_END - 1) + settings->uints.input_remap_ids[user_idx][btn_idx] = RARCH_UNMAPPED; + else + settings->uints.input_remap_ids[user_idx][btn_idx] = input_config_bind_order[0]; - /* skip the not used buttons (unless they are at the end by calling the right desc function recursively - also skip all the axes until analog remapping is implemented */ - if (remap_idx != RARCH_UNMAPPED) - { - if ((string_is_empty(system->input_desc_btn[mapped_port][remap_idx]) && remap_idx < RARCH_CUSTOM_BIND_LIST_END)) - action_right_input_desc(type, label, wraparound); + remap_idx = settings->uints.input_remap_ids[user_idx][btn_idx]; + + /* skip the not used buttons (unless they are at the end by calling the right desc function recursively + also skip all the axes until analog remapping is implemented */ + if (remap_idx != RARCH_UNMAPPED) + { + if ((string_is_empty(system->input_desc_btn[mapped_port][remap_idx]) && remap_idx < RARCH_CUSTOM_BIND_LIST_END)) + action_right_input_desc(type, label, wraparound); + } } return 0; @@ -240,26 +235,25 @@ static int action_right_scroll(unsigned type, const char *label, bool wraparound) { size_t scroll_accel = 0; - unsigned scroll_speed = 0, fast_scroll_speed = 0; - size_t selection = menu_navigation_get_selection(); - if (!menu_driver_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) - return false; - - scroll_speed = (unsigned)((MAX(scroll_accel, 2) - 2) / 4 + 1); - fast_scroll_speed = 10 * scroll_speed; - - if (selection + fast_scroll_speed < (menu_entries_get_size())) + if (menu_driver_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) { - size_t idx = selection + fast_scroll_speed; + size_t selection = menu_navigation_get_selection(); + unsigned scroll_speed = (unsigned)((MAX(scroll_accel, 2) - 2) / 4 + 1); + unsigned fast_scroll_speed = 10 * scroll_speed; - menu_navigation_set_selection(idx); - menu_driver_navigation_set(true); - } - else - { - if ((menu_entries_get_size() > 0)) - menu_driver_ctl(MENU_NAVIGATION_CTL_SET_LAST, NULL); + if (selection + fast_scroll_speed < (menu_entries_get_size())) + { + size_t idx = selection + fast_scroll_speed; + + menu_navigation_set_selection(idx); + menu_driver_navigation_set(true); + } + else + { + if ((menu_entries_get_size() > 0)) + menu_driver_ctl(MENU_NAVIGATION_CTL_SET_LAST, NULL); + } } return 0; @@ -269,17 +263,13 @@ static int action_right_scroll(unsigned type, const char *label, static int audio_mixer_stream_volume_right(unsigned type, const char *label, bool wraparound) { - unsigned offset = (type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_VOLUME_BEGIN); - float orig_volume = 0.0f; - - if (offset >= AUDIO_MIXER_MAX_STREAMS) - return 0; - - orig_volume = audio_driver_mixer_get_stream_volume(offset); - orig_volume = orig_volume + 1.00f; - - audio_driver_mixer_set_stream_volume(offset, orig_volume); - + unsigned offset = (type - MENU_SETTINGS_AUDIO_MIXER_STREAM_ACTIONS_VOLUME_BEGIN); + if (offset < AUDIO_MIXER_MAX_STREAMS) + { + float orig_volume = audio_driver_mixer_get_stream_volume(offset); + orig_volume = orig_volume + 1.00f; + audio_driver_mixer_set_stream_volume(offset, orig_volume); + } return 0; } #endif @@ -346,7 +336,7 @@ static int action_right_shader_scale_pass(unsigned type, const char *label, struct video_shader_pass *shader_pass = shader ? &shader->pass[pass] : NULL; if (!shader_pass) - return menu_cbs_exit(); + return -1; /* A 20x scale is used to support scaling handheld border shaders up to 8K resolutions */ current_scale = shader_pass->fbo.scale_x; @@ -373,7 +363,7 @@ static int action_right_shader_filter_pass(unsigned type, const char *label, struct video_shader_pass *shader_pass = shader ? &shader->pass[pass] : NULL; if (!shader_pass) - return menu_cbs_exit(); + return -1; shader_pass->filter = ((shader_pass->filter + delta) % 3); @@ -387,7 +377,7 @@ static int action_right_shader_filter_default(unsigned type, const char *label, { rarch_setting_t *setting = menu_setting_find_enum(MENU_ENUM_LABEL_VIDEO_SMOOTH); if (!setting) - return menu_cbs_exit(); + return -1; return menu_action_handle_setting(setting, setting->type, MENU_ACTION_RIGHT, wraparound); @@ -401,7 +391,7 @@ static int action_right_shader_num_passes(unsigned type, const char *label, unsigned pass_count = shader ? shader->passes : 0; if (!shader) - return menu_cbs_exit(); + return -1; if (pass_count < GFX_MAX_SHADERS) shader->passes++; @@ -523,7 +513,7 @@ static int playlist_association_right(unsigned type, const char *label, core_info_get_list(&core_info_list); if (!core_info_list) - return menu_cbs_exit(); + return -1; /* Get current core path association */ if (!string_is_empty(default_core_path) && @@ -822,18 +812,19 @@ static int cpu_policy_freq_managed_tweak(unsigned type, const char *label, cpu_scaling_opts_t opts; enum cpu_scaling_mode mode = get_cpu_scaling_mode(&opts); - switch (type) { - case MENU_SETTINGS_CPU_MANAGED_SET_MINFREQ: - opts.min_freq = get_cpu_scaling_next_frequency_limit( - opts.min_freq, 1); - set_cpu_scaling_mode(mode, &opts); - break; - case MENU_SETTINGS_CPU_MANAGED_SET_MAXFREQ: - opts.max_freq = get_cpu_scaling_next_frequency_limit( - opts.max_freq, 1); - set_cpu_scaling_mode(mode, &opts); - break; - }; + switch (type) + { + case MENU_SETTINGS_CPU_MANAGED_SET_MINFREQ: + opts.min_freq = get_cpu_scaling_next_frequency_limit( + opts.min_freq, 1); + set_cpu_scaling_mode(mode, &opts); + break; + case MENU_SETTINGS_CPU_MANAGED_SET_MAXFREQ: + opts.max_freq = get_cpu_scaling_next_frequency_limit( + opts.max_freq, 1); + set_cpu_scaling_mode(mode, &opts); + break; + } return 0; } @@ -844,37 +835,38 @@ static int cpu_policy_freq_managed_gov(unsigned type, const char *label, int pidx; bool refresh = false; cpu_scaling_opts_t opts; - enum cpu_scaling_mode mode = get_cpu_scaling_mode(&opts); + enum cpu_scaling_mode mode = get_cpu_scaling_mode(&opts); cpu_scaling_driver_t **drivers = get_cpu_scaling_drivers(false); /* Using drivers[0] governors, should be improved */ if (!drivers || !drivers[0]) return -1; - switch (atoi(label)) { - case 0: - pidx = string_list_find_elem(drivers[0]->available_governors, - opts.main_policy); - if (pidx && pidx + 1 < drivers[0]->available_governors->size) - { - strlcpy(opts.main_policy, - drivers[0]->available_governors->elems[pidx].data, - sizeof(opts.main_policy)); - set_cpu_scaling_mode(mode, &opts); - } - break; - case 1: - pidx = string_list_find_elem(drivers[0]->available_governors, - opts.menu_policy); - if (pidx && pidx + 1 < drivers[0]->available_governors->size) - { - strlcpy(opts.menu_policy, - drivers[0]->available_governors->elems[pidx].data, - sizeof(opts.menu_policy)); - set_cpu_scaling_mode(mode, &opts); - } - break; - }; + switch (atoi(label)) + { + case 0: + pidx = string_list_find_elem(drivers[0]->available_governors, + opts.main_policy); + if (pidx && pidx + 1 < drivers[0]->available_governors->size) + { + strlcpy(opts.main_policy, + drivers[0]->available_governors->elems[pidx].data, + sizeof(opts.main_policy)); + set_cpu_scaling_mode(mode, &opts); + } + break; + case 1: + pidx = string_list_find_elem(drivers[0]->available_governors, + opts.menu_policy); + if (pidx && pidx + 1 < drivers[0]->available_governors->size) + { + strlcpy(opts.menu_policy, + drivers[0]->available_governors->elems[pidx].data, + sizeof(opts.menu_policy)); + set_cpu_scaling_mode(mode, &opts); + } + break; + } return 0; } @@ -882,36 +874,37 @@ static int cpu_policy_freq_managed_gov(unsigned type, const char *label, static int cpu_policy_freq_tweak(unsigned type, const char *label, bool wraparound) { - bool refresh = false; cpu_scaling_driver_t **drivers = get_cpu_scaling_drivers(false); - unsigned policyid = atoi(label); - uint32_t next_freq; - if (!drivers) - return 0; - switch (type) { - case MENU_SETTINGS_CPU_POLICY_SET_MINFREQ: - next_freq = get_cpu_scaling_next_frequency(drivers[policyid], - drivers[policyid]->min_policy_freq, 1); - set_cpu_scaling_min_frequency(drivers[policyid], next_freq); - break; - case MENU_SETTINGS_CPU_POLICY_SET_MAXFREQ: - next_freq = get_cpu_scaling_next_frequency(drivers[policyid], - drivers[policyid]->max_policy_freq, 1); - set_cpu_scaling_max_frequency(drivers[policyid], next_freq); - break; - case MENU_SETTINGS_CPU_POLICY_SET_GOVERNOR: + if (drivers) { - int pidx = string_list_find_elem(drivers[policyid]->available_governors, - drivers[policyid]->scaling_governor); - if (pidx && pidx + 1 < drivers[policyid]->available_governors->size) + uint32_t next_freq; + unsigned policyid = atoi(label); + switch (type) { - set_cpu_scaling_governor(drivers[policyid], - drivers[policyid]->available_governors->elems[pidx].data); + case MENU_SETTINGS_CPU_POLICY_SET_MINFREQ: + next_freq = get_cpu_scaling_next_frequency(drivers[policyid], + drivers[policyid]->min_policy_freq, 1); + set_cpu_scaling_min_frequency(drivers[policyid], next_freq); + break; + case MENU_SETTINGS_CPU_POLICY_SET_MAXFREQ: + next_freq = get_cpu_scaling_next_frequency(drivers[policyid], + drivers[policyid]->max_policy_freq, 1); + set_cpu_scaling_max_frequency(drivers[policyid], next_freq); + break; + case MENU_SETTINGS_CPU_POLICY_SET_GOVERNOR: + { + int pidx = string_list_find_elem(drivers[policyid]->available_governors, + drivers[policyid]->scaling_governor); + if (pidx && pidx + 1 < drivers[policyid]->available_governors->size) + { + set_cpu_scaling_governor(drivers[policyid], + drivers[policyid]->available_governors->elems[pidx].data); + } + break; + } } - break; } - }; return 0; } @@ -1268,9 +1261,7 @@ static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs, } } else - { return -1; - } } return 0; @@ -1281,7 +1272,7 @@ int menu_cbs_init_bind_right(menu_file_list_cbs_t *cbs, const char *menu_label) { if (!cbs) - return menu_cbs_exit(); + return -1; BIND_ACTION_RIGHT(cbs, bind_right_generic); @@ -1307,5 +1298,5 @@ int menu_cbs_init_bind_right(menu_file_list_cbs_t *cbs, if (menu_cbs_init_bind_right_compare_type(cbs, type, menu_label ) == 0) return 0; - return menu_cbs_exit(); + return -1; } diff --git a/menu/cbs/menu_cbs_scan.c b/menu/cbs/menu_cbs_scan.c index 9466b9d45d..56f40d8be9 100644 --- a/menu/cbs/menu_cbs_scan.c +++ b/menu/cbs/menu_cbs_scan.c @@ -120,53 +120,53 @@ int action_switch_thumbnail(const char *path, * changing thumbnail view mode. * For other menu drivers, we cycle through available thumbnail * types and skip if already visible. */ - if (!switch_enabled) - return 0; - - if (settings->uints.gfx_thumbnails == 0) + if (switch_enabled) { - configuration_set_uint(settings, - settings->uints.menu_left_thumbnails, - settings->uints.menu_left_thumbnails + 1); - - if (settings->uints.gfx_thumbnails == settings->uints.menu_left_thumbnails) + if (settings->uints.gfx_thumbnails == 0) + { configuration_set_uint(settings, settings->uints.menu_left_thumbnails, settings->uints.menu_left_thumbnails + 1); - if (settings->uints.menu_left_thumbnails > 3) - configuration_set_uint(settings, - settings->uints.menu_left_thumbnails, 1); + if (settings->uints.gfx_thumbnails == settings->uints.menu_left_thumbnails) + configuration_set_uint(settings, + settings->uints.menu_left_thumbnails, + settings->uints.menu_left_thumbnails + 1); - if (settings->uints.gfx_thumbnails == settings->uints.menu_left_thumbnails) - configuration_set_uint(settings, - settings->uints.menu_left_thumbnails, - settings->uints.menu_left_thumbnails + 1); - } - else - { - configuration_set_uint(settings, - settings->uints.gfx_thumbnails, - settings->uints.gfx_thumbnails + 1); + if (settings->uints.menu_left_thumbnails > 3) + configuration_set_uint(settings, + settings->uints.menu_left_thumbnails, 1); - if (settings->uints.gfx_thumbnails == settings->uints.menu_left_thumbnails) + if (settings->uints.gfx_thumbnails == settings->uints.menu_left_thumbnails) + configuration_set_uint(settings, + settings->uints.menu_left_thumbnails, + settings->uints.menu_left_thumbnails + 1); + } + else + { configuration_set_uint(settings, settings->uints.gfx_thumbnails, settings->uints.gfx_thumbnails + 1); - if (settings->uints.gfx_thumbnails > 3) - configuration_set_uint(settings, - settings->uints.gfx_thumbnails, 1); + if (settings->uints.gfx_thumbnails == settings->uints.menu_left_thumbnails) + configuration_set_uint(settings, + settings->uints.gfx_thumbnails, + settings->uints.gfx_thumbnails + 1); - if (settings->uints.gfx_thumbnails == settings->uints.menu_left_thumbnails) - configuration_set_uint(settings, - settings->uints.gfx_thumbnails, - settings->uints.gfx_thumbnails + 1); + if (settings->uints.gfx_thumbnails > 3) + configuration_set_uint(settings, + settings->uints.gfx_thumbnails, 1); + + if (settings->uints.gfx_thumbnails == settings->uints.menu_left_thumbnails) + configuration_set_uint(settings, + settings->uints.gfx_thumbnails, + settings->uints.gfx_thumbnails + 1); + } + + menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH, NULL); + menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_IMAGE, NULL); } - menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH, NULL); - menu_driver_ctl(RARCH_MENU_CTL_UPDATE_THUMBNAIL_IMAGE, NULL); - return 0; } diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index aa6e7931bd..013c59676d 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -127,7 +127,7 @@ static int action_start_video_filter_file_load( settings_t *settings = config_get_ptr(); if (!settings) - return menu_cbs_exit(); + return -1; if (!string_is_empty(settings->paths.path_softfilter_plugin)) { @@ -152,7 +152,7 @@ static int action_start_audio_dsp_plugin_file_load( settings_t *settings = config_get_ptr(); if (!settings) - return menu_cbs_exit(); + return -1; if (!string_is_empty(settings->paths.path_audio_dsp_plugin)) { @@ -302,7 +302,7 @@ static int action_start_shader_pass( menu_handle_t *menu = menu_state_get_ptr()->driver_data; if (!menu) - return menu_cbs_exit(); + return -1; menu->scratchpad.unsigned_var = type - MENU_SETTINGS_SHADER_PASS_0; @@ -480,10 +480,8 @@ static int action_start_menu_wallpaper( /* Reset wallpaper by menu context reset */ if (menu_st->driver_ctx && menu_st->driver_ctx->context_reset) - { menu_st->driver_ctx->context_reset(menu_st->userdata, video_driver_is_threaded()); - } return 0; } diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 501d773be6..9344565b10 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -87,16 +87,18 @@ static int menu_action_sublabel_file_browser_core(file_list_t *list, unsigned ty s[_len+1] = ' '; s[_len+2] = '\0'; strlcat(s, tmp, len); - return 1; + } + else + { + /* No license found - set to N/A */ + _len = strlcpy(s, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), len); + s[_len ] = ':'; + s[_len+1] = ' '; + s[_len+2] = '\0'; + strlcat(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len); } - /* No license found - set to N/A */ - _len = strlcpy(s, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), len); - s[_len ] = ':'; - s[_len+1] = ' '; - s[_len+2] = '\0'; - strlcat(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len); return 1; } @@ -185,12 +187,9 @@ static int menu_action_sublabel_contentless_core(file_list_t *list, { tmp[n ] = '\n'; tmp[n+1] = '\0'; - n = strlcat(tmp, entry->runtime.last_played_str, sizeof(tmp)); + strlcat(tmp, entry->runtime.last_played_str, sizeof(tmp)); } - if (n >= 64) - n = 0; /* Silence GCC warnings... */ - (void)n; if (!string_is_empty(tmp)) strlcat(s, tmp, len); } @@ -1539,7 +1538,7 @@ static int action_bind_sublabel_netplay_room(file_list_t *list, unsigned room_index = type - MENU_SETTINGS_NETPLAY_ROOMS_START; if (room_index >= (unsigned)net_st->room_count) - return menu_cbs_exit(); + return -1; room = &net_st->room_list[room_index]; @@ -1593,7 +1592,7 @@ static int action_bind_sublabel_netplay_kick_client(file_list_t *list, net_driver_state_t *net_st = networking_state_get_ptr(); if (idx >= net_st->client_info_count) - return menu_cbs_exit(); + return -1; client = &net_st->client_info[idx]; @@ -1809,12 +1808,9 @@ static int action_bind_sublabel_playlist_entry( { tmp[n ] = '\n'; tmp[n+1] = '\0'; - n = strlcat(tmp, entry->last_played_str, sizeof(tmp)); + strlcat(tmp, entry->last_played_str, sizeof(tmp)); } - if (n >= 64) - n = 0; /* Silence GCC warnings... */ - (void)n; if (!string_is_empty(tmp)) strlcat(s, tmp, len); } @@ -1864,17 +1860,13 @@ static int action_bind_sublabel_core_option( char *s, size_t len) { core_option_manager_t *opt = NULL; - const char *info = NULL; - - if (!retroarch_ctl(RARCH_CTL_CORE_OPTIONS_LIST_GET, &opt)) - return 0; - - info = core_option_manager_get_info(opt, - type - MENU_SETTINGS_CORE_OPTION_START, true); - - if (!string_is_empty(info)) - strlcpy(s, info, len); - + if (retroarch_ctl(RARCH_CTL_CORE_OPTIONS_LIST_GET, &opt)) + { + const char *info = core_option_manager_get_info(opt, + type - MENU_SETTINGS_CORE_OPTION_START, true); + if (!string_is_empty(info)) + strlcpy(s, info, len); + } return 0; } @@ -1905,16 +1897,17 @@ static int action_bind_sublabel_core_updater_entry( s[_len+1] = ' '; s[_len+2] = '\0'; strlcat(s, tmp, len); - return 1; } - - /* No license found - set to N/A */ - _len = strlcpy(s, - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), len); - s[_len ] = ':'; - s[_len+1] = ' '; - s[_len+2] = '\0'; - strlcat(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len); + else + { + /* No license found - set to N/A */ + _len = strlcpy(s, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), len); + s[_len ] = ':'; + s[_len+1] = ' '; + s[_len+2] = '\0'; + strlcat(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len); + } return 1; } #endif diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 175e2f8157..1d8c84e31a 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -249,116 +249,115 @@ static int action_get_title_dropdown_item( char *s, size_t len) { /* Sanity check */ - if (string_is_empty(path)) - return 0; - - if (string_starts_with_size(path, "core_option_", - STRLEN_CONST("core_option_"))) + if (!string_is_empty(path)) { - /* This is a core options item */ - struct string_list tmp_str_list = {0}; - core_option_manager_t *coreopts = NULL; - int ret = 0; + if (string_starts_with_size(path, "core_option_", + STRLEN_CONST("core_option_"))) + { + /* This is a core options item */ + struct string_list tmp_str_list = {0}; + core_option_manager_t *coreopts = NULL; - string_list_initialize(&tmp_str_list); - string_split_noalloc(&tmp_str_list, path, "_"); + string_list_initialize(&tmp_str_list); + string_split_noalloc(&tmp_str_list, path, "_"); - if (tmp_str_list.size > 0) - { - retroarch_ctl(RARCH_CTL_CORE_OPTIONS_LIST_GET, &coreopts); + if (tmp_str_list.size > 0) + { + retroarch_ctl(RARCH_CTL_CORE_OPTIONS_LIST_GET, &coreopts); - if (coreopts) - { - unsigned option_index = string_to_unsigned( - tmp_str_list.elems[(unsigned)tmp_str_list.size - 1].data); - const char *title = core_option_manager_get_desc( - coreopts, option_index, true); + if (coreopts) + { + unsigned option_index = string_to_unsigned( + tmp_str_list.elems[(unsigned)tmp_str_list.size - 1].data); + const char *title = core_option_manager_get_desc( + coreopts, option_index, true); - if (s && !string_is_empty(title)) - { - strlcpy(s, title, len); - ret = 1; - } - } - } + if (s && !string_is_empty(title)) + { + strlcpy(s, title, len); + /* Clean up before returning */ + string_list_deinitialize(&tmp_str_list); + return 1; + } + } + } - /* Clean up */ - string_list_deinitialize(&tmp_str_list); + /* Clean up */ + string_list_deinitialize(&tmp_str_list); + } + else + { + /* This is a 'normal' drop down list */ - return ret; - } - else - { - /* This is a 'normal' drop down list */ + /* In msg_hash.h, msg_hash_enums are generated via + * the following macro: + * #define MENU_LABEL(STR) \ + * MENU_ENUM_LABEL_##STR, \ + * MENU_ENUM_SUBLABEL_##STR, \ + * MENU_ENUM_LABEL_VALUE_##STR + * to get 'MENU_ENUM_LABEL_VALUE_' from a + * 'MENU_ENUM_LABEL_', we therefore add 2... */ + enum msg_hash_enums enum_idx = (enum msg_hash_enums) + (string_to_unsigned(path) + 2); - /* In msg_hash.h, msg_hash_enums are generated via - * the following macro: - * #define MENU_LABEL(STR) \ - * MENU_ENUM_LABEL_##STR, \ - * MENU_ENUM_SUBLABEL_##STR, \ - * MENU_ENUM_LABEL_VALUE_##STR - * to get 'MENU_ENUM_LABEL_VALUE_' from a - * 'MENU_ENUM_LABEL_', we therefore add 2... */ - enum msg_hash_enums enum_idx = (enum msg_hash_enums) - (string_to_unsigned(path) + 2); + /* Check if enum index is valid + * Note: This is a very crude check, but better than nothing */ + if ((enum_idx > MSG_UNKNOWN) && (enum_idx < MSG_LAST)) + { + /* An annoyance: MENU_ENUM_LABEL_THUMBNAILS and + * MENU_ENUM_LABEL_LEFT_THUMBNAILS require special + * treatment, since their titles depend upon the + * current menu driver... */ + switch (enum_idx) + { + case MENU_ENUM_LABEL_VALUE_THUMBNAILS: + return action_get_title_thumbnails( + path, label, menu_type, s, len); + case MENU_ENUM_LABEL_VALUE_LEFT_THUMBNAILS: + return action_get_title_left_thumbnails( + path, label, menu_type, s, len); + default: + { + /* Submenu label exceptions */ + /* Device Type */ + if ((enum_idx >= MENU_ENUM_LABEL_INPUT_LIBRETRO_DEVICE) && + (enum_idx <= MENU_ENUM_LABEL_INPUT_LIBRETRO_DEVICE_LAST)) + enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_DEVICE_TYPE; - /* Check if enum index is valid - * Note: This is a very crude check, but better than nothing */ - if ((enum_idx > MSG_UNKNOWN) && (enum_idx < MSG_LAST)) - { - /* An annoyance: MENU_ENUM_LABEL_THUMBNAILS and - * MENU_ENUM_LABEL_LEFT_THUMBNAILS require special - * treatment, since their titles depend upon the - * current menu driver... */ - switch (enum_idx) - { - case MENU_ENUM_LABEL_VALUE_THUMBNAILS: - return action_get_title_thumbnails( - path, label, menu_type, s, len); - case MENU_ENUM_LABEL_VALUE_LEFT_THUMBNAILS: - return action_get_title_left_thumbnails( - path, label, menu_type, s, len); - default: - { - /* Submenu label exceptions */ - /* Device Type */ - if ((enum_idx >= MENU_ENUM_LABEL_INPUT_LIBRETRO_DEVICE) && - (enum_idx <= MENU_ENUM_LABEL_INPUT_LIBRETRO_DEVICE_LAST)) - enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_DEVICE_TYPE; + /* Analog to Digital Type */ + if ((enum_idx >= MENU_ENUM_LABEL_INPUT_PLAYER_ANALOG_DPAD_MODE) && + (enum_idx <= MENU_ENUM_LABEL_INPUT_PLAYER_ANALOG_DPAD_MODE_LAST)) + enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_ADC_TYPE; - /* Analog to Digital Type */ - if ((enum_idx >= MENU_ENUM_LABEL_INPUT_PLAYER_ANALOG_DPAD_MODE) && - (enum_idx <= MENU_ENUM_LABEL_INPUT_PLAYER_ANALOG_DPAD_MODE_LAST)) - enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_ADC_TYPE; + /* Device Index */ + if ((enum_idx >= MENU_ENUM_LABEL_INPUT_DEVICE_INDEX) && + (enum_idx <= MENU_ENUM_LABEL_INPUT_DEVICE_INDEX_LAST)) + enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_DEVICE_INDEX; - /* Device Index */ - if ((enum_idx >= MENU_ENUM_LABEL_INPUT_DEVICE_INDEX) && - (enum_idx <= MENU_ENUM_LABEL_INPUT_DEVICE_INDEX_LAST)) - enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_DEVICE_INDEX; + /* Mouse Index */ + if ((enum_idx >= MENU_ENUM_LABEL_INPUT_MOUSE_INDEX) && + (enum_idx <= MENU_ENUM_LABEL_INPUT_MOUSE_INDEX_LAST)) + enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_INDEX; - /* Mouse Index */ - if ((enum_idx >= MENU_ENUM_LABEL_INPUT_MOUSE_INDEX) && - (enum_idx <= MENU_ENUM_LABEL_INPUT_MOUSE_INDEX_LAST)) - enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_INDEX; + /* Mapped Port (virtual -> 'physical' port mapping) */ + if ((enum_idx >= MENU_ENUM_LABEL_INPUT_REMAP_PORT) && + (enum_idx <= MENU_ENUM_LABEL_INPUT_REMAP_PORT_LAST)) + enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_REMAP_PORT; - /* Mapped Port (virtual -> 'physical' port mapping) */ - if ((enum_idx >= MENU_ENUM_LABEL_INPUT_REMAP_PORT) && - (enum_idx <= MENU_ENUM_LABEL_INPUT_REMAP_PORT_LAST)) - enum_idx = MENU_ENUM_LABEL_VALUE_INPUT_REMAP_PORT; + { + const char *title = msg_hash_to_str(enum_idx); - { - const char *title = msg_hash_to_str(enum_idx); - - if (s && !string_is_empty(title)) - { - SANITIZE_TO_STRING(s, title, len); - return 1; - } - } - } - break; - } - } + if (s && !string_is_empty(title)) + { + SANITIZE_TO_STRING(s, title, len); + return 1; + } + } + } + break; + } + } + } } return 0; diff --git a/menu/menu_cbs.h b/menu/menu_cbs.h index 1eeff965d7..78822441e4 100644 --- a/menu/menu_cbs.h +++ b/menu/menu_cbs.h @@ -329,8 +329,6 @@ int bind_right_generic(unsigned type, const char *label, int action_ok_core_option_dropdown_list(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx); -int menu_cbs_exit(void); - void cb_generic_download(retro_task_t *task, void *task_data, void *user_data, const char *err); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 09c00cf945..0c77c58460 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -2623,12 +2623,6 @@ void menu_cbs_init( idx); } -/* Pretty much a stub function. TODO/FIXME - Might as well remove this. */ -int menu_cbs_exit(void) -{ - return -1; -} - #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) void menu_driver_set_last_shader_preset_path(const char *path) {