int action_scan_directory(const char *path, const char *label, unsigned type, size_t idx) { char fullpath[PATH_MAX_LENGTH]; enum msg_hash_enums enum_idx = MSG_UNKNOWN; const char *menu_label = NULL; const char *menu_path = NULL; settings_t *settings = config_get_ptr(); fullpath[0] = '\0'; menu_entries_get_last_stack(&menu_path, &menu_label, NULL, &enum_idx, NULL); strlcpy(fullpath, menu_path, sizeof(fullpath)); if (path) fill_pathname_join(fullpath, fullpath, path, sizeof(fullpath)); task_push_dbscan( settings->paths.directory_playlist, settings->paths.path_content_database, fullpath, true, handle_dbscan_finished); return 0; }
/* Get an entry from the top of the menu stack */ void menu_entries_get(size_t i, menu_entry_t *entry) { const char *label = NULL; const char *path = NULL; const char *entry_label = NULL; menu_file_list_cbs_t *cbs = NULL; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); menu_entries_get_last_stack(NULL, &label, NULL, NULL); entry->path[0] = entry->value[0] = entry->label[0] = '\0'; menu_entries_get_at_offset(selection_buf, i, &path, &entry_label, &entry->type, &entry->entry_idx, NULL); cbs = menu_entries_get_actiondata_at_offset(selection_buf, i); if (cbs && cbs->action_get_value) cbs->action_get_value(selection_buf, &entry->spacing, entry->type, i, label, entry->value, sizeof(entry->value), entry_label, path, entry->path, sizeof(entry->path)); entry->idx = i; if (entry_label) strlcpy(entry->label, entry_label, sizeof(entry->label)); }
/* Get an entry from the top of the menu stack */ void menu_entries_get(size_t i, void *entry_data) { const char *label = NULL; const char *path = NULL; const char *entry_label = NULL; menu_file_list_cbs_t *cbs = NULL; enum msg_hash_enums enum_idx = MSG_UNKNOWN; menu_entry_t *entry = (menu_entry_t*)entry_data; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); menu_entries_get_last_stack(NULL, &label, NULL, &enum_idx, NULL); entry->path[0] = entry->value[0] = string_is_empty(entry->label); menu_entries_get_at_offset(selection_buf, i, &path, &entry_label, &entry->type, &entry->entry_idx, NULL); cbs = menu_entries_get_actiondata_at_offset(selection_buf, i); if (cbs && cbs->action_get_value) cbs->action_get_value(selection_buf, &entry->spacing, entry->type, i, label, entry->value, sizeof(entry->value), entry_label, path, entry->path, sizeof(entry->path)); entry->idx = i; if (entry_label) strlcpy(entry->label, entry_label, sizeof(entry->label)); }
static int action_scan_input_desc(const char *path, const char *label, unsigned type, size_t idx) { const char *menu_label = NULL; unsigned key = 0; unsigned inp_desc_user = 0; struct retro_keybind *target = NULL; menu_entries_get_last_stack(NULL, &menu_label, NULL, NULL, NULL); if (string_is_equal(menu_label, "deferred_user_binds_list")) { unsigned char player_no_str = atoi(&label[1]); inp_desc_user = (unsigned)(player_no_str - 1); /* This hardcoded value may cause issues if any entries are added on top of the input binds */ key = (unsigned)(idx - 7); } else key = input_config_translate_str_to_bind_id(label); target = &input_config_binds[inp_desc_user][key]; if (target) { target->key = RETROK_UNKNOWN; target->joykey = NO_BTN; target->joyaxis = AXIS_NONE; target->mbutton = NO_BTN; } return 0; }
void menu_entries_append_enum(file_list_t *list, const char *path, const char *label, enum msg_hash_enums enum_idx, unsigned type, size_t directory_ptr, size_t entry_idx) { menu_ctx_list_t list_info; size_t idx; const char *menu_path = NULL; menu_file_list_cbs_t *cbs = NULL; if (!list || !label) return; file_list_append(list, path, label, type, directory_ptr, entry_idx); menu_entries_get_last_stack(&menu_path, NULL, NULL, NULL, NULL); idx = list->size - 1; list_info.fullpath = NULL; if (!string_is_empty(menu_path)) list_info.fullpath = strdup(menu_path); list_info.list = list; list_info.path = path; list_info.label = label; list_info.idx = idx; list_info.entry_type = type; menu_driver_ctl(RARCH_MENU_CTL_LIST_INSERT, &list_info); if (list_info.fullpath) free(list_info.fullpath); file_list_free_actiondata(list, idx); cbs = (menu_file_list_cbs_t*) calloc(1, sizeof(menu_file_list_cbs_t)); if (!cbs) return; file_list_set_actiondata(list, idx, cbs); cbs->enum_idx = enum_idx; if (enum_idx != MENU_ENUM_LABEL_PLAYLIST_ENTRY && enum_idx != MENU_ENUM_LABEL_PLAYLIST_COLLECTION_ENTRY && enum_idx != MENU_ENUM_LABEL_RDB_ENTRY) { cbs->setting = menu_setting_find_enum(enum_idx); } menu_cbs_init(list, cbs, path, label, type, idx); }
/* Sets title to what the name of the current menu should be. */ int menu_entries_get_title(char *s, size_t len) { unsigned menu_type = 0; const char *path = NULL; const char *label = NULL; menu_file_list_cbs_t *cbs = menu_entries_get_last_stack_actiondata(); if (!cbs) return -1; menu_entries_get_last_stack(&path, &label, &menu_type, NULL); if (cbs && cbs->action_get_title) return cbs->action_get_title(path, label, menu_type, s, len); return 0; }
void menu_entries_append(file_list_t *list, const char *path, const char *label, unsigned type, size_t directory_ptr, size_t entry_idx) { menu_ctx_list_t list_info; size_t idx; const char *menu_path = NULL; menu_file_list_cbs_t *cbs = NULL; if (!list || !label) return; file_list_append(list, path, label, type, directory_ptr, entry_idx); menu_entries_get_last_stack(&menu_path, NULL, NULL, NULL, NULL); idx = list->size - 1; list_info.list = list; list_info.path = path; list_info.fullpath = NULL; if (!string_is_empty(menu_path)) list_info.fullpath = strdup(menu_path); list_info.label = label; list_info.idx = idx; list_info.entry_type = type; menu_driver_list_insert(&list_info); if (list_info.fullpath) free(list_info.fullpath); file_list_free_actiondata(list, idx); cbs = (menu_file_list_cbs_t*) calloc(1, sizeof(menu_file_list_cbs_t)); if (!cbs) return; file_list_set_actiondata(list, idx, cbs); cbs->enum_idx = MSG_UNKNOWN; cbs->setting = menu_setting_find(label); menu_cbs_init(list, cbs, path, label, type, idx); }
int menu_entry_pathdir_set_value(uint32_t i, const char *s) { const char *menu_path = NULL; menu_file_list_cbs_t *cbs = menu_entries_get_last_stack_actiondata(); menu_entries_get_last_stack(&menu_path, NULL, NULL, NULL); if (!cbs || !cbs->setting) return -1; if (menu_setting_get_type(cbs->setting) != ST_DIR) return -1; menu_setting_set_with_string_representation(cbs->setting, menu_path); menu_setting_generic(cbs->setting, false); menu_entries_flush_stack(NULL, 49); return 0; }
/* Sets title to what the name of the current menu should be. */ int menu_entries_get_title(char *s, size_t len) { unsigned menu_type = 0; const char *path = NULL; const char *label = NULL; enum msg_hash_enums enum_idx = MSG_UNKNOWN; menu_file_list_cbs_t *cbs = menu_entries_list ? (menu_file_list_cbs_t*)file_list_get_last_actiondata( menu_list_get(menu_entries_list, 0)) : NULL; if (!cbs) return -1; menu_entries_get_last_stack(&path, &label, &menu_type, &enum_idx, NULL); if (cbs && cbs->action_get_title) return cbs->action_get_title(path, label, menu_type, s, len); return 0; }
static void netplay_lan_scan_callback(void *task_data, void *user_data, const char *error) { unsigned i; unsigned menu_type = 0; const char *path = NULL; const char *label = NULL; enum msg_hash_enums enum_idx = MSG_UNKNOWN; file_list_t *file_list = NULL; struct netplay_host_list *netplay_hosts = NULL; menu_entries_get_last_stack(&path, &label, &menu_type, &enum_idx, NULL); /* Don't push the results if we left the LAN scan menu */ if (!string_is_equal(label, msg_hash_to_str( MENU_ENUM_LABEL_DEFERRED_NETPLAY_LAN_SCAN_SETTINGS_LIST))) return; if (netplay_discovery_driver_ctl( RARCH_NETPLAY_DISCOVERY_CTL_LAN_GET_RESPONSES, (void *) &netplay_hosts)) { if (netplay_hosts->size > 0) { file_list = menu_entries_get_selection_buf_ptr(0); menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, file_list); } for (i = 0; i < netplay_hosts->size; i++) { struct netplay_host *host = &netplay_hosts->hosts[i]; menu_entries_append_enum(file_list, host->nick, msg_hash_to_str(MENU_ENUM_LABEL_NETPLAY_CONNECT_TO), MENU_ENUM_LABEL_NETPLAY_CONNECT_TO, MENU_NETPLAY_LAN_SCAN, 0, 0); } } }
void menu_entry_get(menu_entry_t *entry, size_t stack_idx, size_t i, void *userdata, bool use_representation) { const char *path = NULL; const char *entry_label = NULL; menu_file_list_cbs_t *cbs = NULL; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(stack_idx); file_list_t *list = selection_buf; if (userdata) list = (file_list_t*)userdata; if (!list) return; menu_entries_get_at_offset(list, i, &path, &entry_label, &entry->type, &entry->entry_idx, NULL); cbs = menu_entries_get_actiondata_at_offset(list, i); if (cbs && cbs->action_get_value && use_representation) { const char *label = NULL; menu_entries_get_last_stack(NULL, &label, NULL, NULL); cbs->action_get_value(list, &entry->spacing, entry->type, i, label, entry->value, sizeof(entry->value), entry_label, path, entry->path, sizeof(entry->path)); } entry->idx = i; if (path && !use_representation) strlcpy(entry->path, path, sizeof(entry->path)); if (entry_label) strlcpy(entry->label, entry_label, sizeof(entry->label)); }
/* This sets up all the callback functions for a menu entry. * * OK : When we press the 'OK' button on an entry. * Cancel : When we press the 'Cancel' button on an entry. * Scan : When we press the 'Scan' button on an entry. * Start : When we press the 'Start' button on an entry. * Select : When we press the 'Select' button on an entry. * Info : When we press the 'Info' button on an entry. * Content Switch : ??? (TODO/FIXME - Kivutar should document this) * Up : when we press 'Up' on the D-pad while this entry is selected. * Down : when we press 'Down' on the D-pad while this entry is selected. * Left : when we press 'Left' on the D-pad while this entry is selected. * Right : when we press 'Right' on the D-pad while this entry is selected. * Deferred push : When pressing an entry results in spawning a new list, it waits until the next * frame to push this onto the stack. This function callback will then be invoked. * Refresh : What happens when the screen has to be refreshed. Does an entry have internal state * that needs to be rebuild? * Get value: Each entry has associated 'text', which we call the value. This function callback * lets us render that text. * Get title: Each entry can have a custom 'title'. * Label: Each entry has a label name. This function callback lets us render that label text. * Sublabel: each entry has a sublabel, which consists of one or more lines of additional information. * This function callback lets us render that text. */ void menu_cbs_init(void *data, menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx) { menu_ctx_bind_t bind_info; const char *repr_label = NULL; const char *menu_label = NULL; uint32_t label_hash = 0; uint32_t menu_label_hash = 0; enum msg_hash_enums enum_idx = MSG_UNKNOWN; file_list_t *list = (file_list_t*)data; if (!list) return; menu_entries_get_last_stack(NULL, &menu_label, NULL, &enum_idx, NULL); if (!label || !menu_label) return; label_hash = msg_hash_calculate(label); menu_label_hash = msg_hash_calculate(menu_label); #ifdef DEBUG_LOG RARCH_LOG("\n"); #endif repr_label = (!string_is_empty(label)) ? label : path; #ifdef DEBUG_LOG if (cbs && cbs->enum_idx != MSG_UNKNOWN) RARCH_LOG("\t\t\tenum_idx %d [%s]\n", cbs->enum_idx, msg_hash_to_str(cbs->enum_idx)); #endif /* It will try to find a corresponding callback function inside * menu_cbs_ok.c, then map this callback to the entry. */ menu_cbs_init_bind_ok(cbs, path, label, type, idx, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "OK", cbs->action_ok_ident); /* It will try to find a corresponding callback function inside * menu_cbs_cancel.c, then map this callback to the entry. */ menu_cbs_init_bind_cancel(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "CANCEL", cbs->action_cancel_ident); /* It will try to find a corresponding callback function inside * menu_cbs_scan.c, then map this callback to the entry. */ menu_cbs_init_bind_scan(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "SCAN", cbs->action_scan_ident); /* It will try to find a corresponding callback function inside * menu_cbs_start.c, then map this callback to the entry. */ menu_cbs_init_bind_start(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "START", cbs->action_start_ident); /* It will try to find a corresponding callback function inside * menu_cbs_select.c, then map this callback to the entry. */ menu_cbs_init_bind_select(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "SELECT", cbs->action_select_ident); /* It will try to find a corresponding callback function inside * menu_cbs_info.c, then map this callback to the entry. */ menu_cbs_init_bind_info(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "INFO", cbs->action_info_ident); /* It will try to find a corresponding callback function inside * menu_cbs_bind_content_list_switch.c, then map this callback to the entry. */ menu_cbs_init_bind_content_list_switch(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "CONTENT SWITCH", cbs->action_content_list_switch_ident); /* It will try to find a corresponding callback function inside * menu_cbs_up.c, then map this callback to the entry. */ menu_cbs_init_bind_up(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "UP", cbs->action_up_ident); /* It will try to find a corresponding callback function inside * menu_cbs_down.c, then map this callback to the entry. */ menu_cbs_init_bind_down(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "DOWN", cbs->action_down_ident); /* It will try to find a corresponding callback function inside * menu_cbs_left.c, then map this callback to the entry. */ menu_cbs_init_bind_left(cbs, path, label, type, idx, menu_label, label_hash); menu_cbs_init_log(repr_label, "LEFT", cbs->action_left_ident); /* It will try to find a corresponding callback function inside * menu_cbs_right.c, then map this callback to the entry. */ menu_cbs_init_bind_right(cbs, path, label, type, idx, menu_label, label_hash); menu_cbs_init_log(repr_label, "RIGHT", cbs->action_right_ident); /* It will try to find a corresponding callback function inside * menu_cbs_deferred_push.c, then map this callback to the entry. */ menu_cbs_init_bind_deferred_push(cbs, path, label, type, idx, label_hash); menu_cbs_init_log(repr_label, "DEFERRED PUSH", cbs->action_deferred_push_ident); /* It will try to find a corresponding callback function inside * menu_cbs_refresh.c, then map this callback to the entry. */ menu_cbs_init_bind_refresh(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "REFRESH", cbs->action_refresh_ident); /* It will try to find a corresponding callback function inside * menu_cbs_get_string_representation.c, then map this callback to the entry. */ menu_cbs_init_bind_get_string_representation(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "GET VALUE", cbs->action_get_value_ident); /* It will try to find a corresponding callback function inside * menu_cbs_title.c, then map this callback to the entry. */ menu_cbs_init_bind_title(cbs, path, label, type, idx, label_hash); menu_cbs_init_log(repr_label, "GET TITLE", cbs->action_get_title_ident); /* It will try to find a corresponding callback function inside * menu_cbs_label.c, then map this callback to the entry. */ menu_cbs_init_bind_label(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "LABEL", cbs->action_label_ident); /* It will try to find a corresponding callback function inside * menu_cbs_sublabel.c, then map this callback to the entry. */ menu_cbs_init_bind_sublabel(cbs, path, label, type, idx); menu_cbs_init_log(repr_label, "SUBLABEL", cbs->action_sublabel_ident); bind_info.cbs = cbs; bind_info.path = path; bind_info.label = label; bind_info.type = type; bind_info.idx = idx; bind_info.label_hash = label_hash; menu_driver_ctl(RARCH_MENU_CTL_BIND_INIT, &bind_info); }
/** * menu_iterate: * @input : input sample for this frame * @old_input : input sample of the previous frame * @trigger_input : difference' input sample - difference * between 'input' and 'old_input' * * Runs RetroArch menu for one frame. * * Returns: 0 on success, -1 if we need to quit out of the loop. **/ int generic_menu_iterate(enum menu_action action) { size_t selection; menu_entry_t entry; enum action_iterate_type iterate_type; const char *label = NULL; int ret = 0; uint32_t label_hash = 0; uint32_t hash = 0; menu_handle_t *menu = menu_driver_get_ptr(); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(); menu_entries_get_last_stack(NULL, &label, NULL, NULL); if (!menu) return 0; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) return 0; menu->menu_state.msg[0] = '\0'; hash = menu_hash_calculate(label); iterate_type = action_iterate_type(hash); if (action != MENU_ACTION_NOOP || menu_entries_needs_refresh() || menu_display_ctl(MENU_DISPLAY_CTL_UPDATE_PENDING, NULL)) { BIT64_SET(menu->state, MENU_STATE_RENDER_FRAMEBUFFER); } switch (iterate_type) { case ITERATE_TYPE_HELP: ret = action_iterate_help(menu->menu_state.msg, sizeof(menu->menu_state.msg), label); BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX); BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); if (ret == 1 || action == MENU_ACTION_OK) BIT64_SET(menu->state, MENU_STATE_POP_STACK); break; case ITERATE_TYPE_BIND: if (menu_input_key_bind_iterate(menu->menu_state.msg, sizeof(menu->menu_state.msg))) { menu_entries_pop_stack(&selection); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); } else BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX); break; case ITERATE_TYPE_INFO: { menu_file_list_cbs_t *cbs = menu_entries_get_actiondata_at_offset(selection_buf, selection); rarch_setting_t *setting = cbs->setting; if (setting) { char needle[PATH_MAX_LENGTH]; strlcpy(needle, menu_setting_get_name(setting), sizeof(needle)); label_hash = menu_hash_calculate(needle); } ret = menu_hash_get_help(label_hash, menu->menu_state.msg, sizeof(menu->menu_state.msg)); } BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX); BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); if (action == MENU_ACTION_OK) BIT64_SET(menu->state, MENU_STATE_POP_STACK); break; case ITERATE_TYPE_DEFAULT: /* FIXME: Crappy hack, needed for mouse controls to not be completely broken * in case we press back. * * We need to fix this entire mess, mouse controls should not rely on a * hack like this in order to work. */ selection = max(min(selection, (menu_entries_get_size() - 1)), 0); menu_entry_get(&entry, selection, NULL, false); ret = menu_entry_action(&entry, selection, (enum menu_action)action); if (ret) goto end; BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); /* Have to defer it so we let settings refresh. */ if (menu->push_help_screen) { menu_displaylist_info_t info = {0}; info.list = menu_stack; strlcpy(info.label, menu_hash_to_str(MENU_LABEL_HELP), sizeof(info.label)); menu_displaylist_push_list(&info, DISPLAYLIST_HELP); } break; } BIT64_SET(menu->state, MENU_STATE_BLIT); if (BIT64_GET(menu->state, MENU_STATE_POP_STACK)) { size_t new_selection_ptr = selection; menu_entries_pop_stack(&new_selection_ptr); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); } if (BIT64_GET(menu->state, MENU_STATE_POST_ITERATE)) menu_input_post_iterate(&ret, action); end: if (ret) return -1; return 0; }
void menu_cbs_init(void *data, menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx) { menu_ctx_bind_t bind_info; char elem0[PATH_MAX_LENGTH]; char elem1[PATH_MAX_LENGTH]; const char *repr_label = NULL; struct string_list *str_list = NULL; const char *menu_label = NULL; uint32_t label_hash = 0; uint32_t menu_label_hash = 0; file_list_t *list = (file_list_t*)data; if (!list) return; elem0[0] = '\0'; elem1[0] = '\0'; menu_entries_get_last_stack(NULL, &menu_label, NULL, NULL); if (label) str_list = string_split(label, "|"); if (str_list && str_list->size > 0) strlcpy(elem0, str_list->elems[0].data, sizeof(elem0)); if (str_list && str_list->size > 1) strlcpy(elem1, str_list->elems[1].data, sizeof(elem1)); if (!label || !menu_label) goto error; label_hash = menu_hash_calculate(label); menu_label_hash = menu_hash_calculate(menu_label); #ifdef DEBUG_LOG RARCH_LOG("\n"); #endif repr_label = (!string_is_empty(label)) ? label : path; menu_cbs_init_bind_ok(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "OK", cbs->action_ok_ident); menu_cbs_init_bind_cancel(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "CANCEL", cbs->action_cancel_ident); menu_cbs_init_bind_scan(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "SCAN", cbs->action_scan_ident); menu_cbs_init_bind_start(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "START", cbs->action_start_ident); menu_cbs_init_bind_select(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "SELECT", cbs->action_select_ident); menu_cbs_init_bind_info(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "INFO", cbs->action_info_ident); menu_cbs_init_bind_content_list_switch(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "CONTENT SWITCH", cbs->action_content_list_switch_ident); menu_cbs_init_bind_up(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "UP", cbs->action_up_ident); menu_cbs_init_bind_down(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "DOWN", cbs->action_down_ident); menu_cbs_init_bind_left(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "LEFT", cbs->action_left_ident); menu_cbs_init_bind_right(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "RIGHT", cbs->action_right_ident); menu_cbs_init_bind_deferred_push(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "DEFERRED PUSH", cbs->action_deferred_push_ident); menu_cbs_init_bind_refresh(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "REFRESH", cbs->action_refresh_ident); menu_cbs_init_bind_get_string_representation(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "GET VALUE", cbs->action_get_value_ident); menu_cbs_init_bind_title(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "GET TITLE", cbs->action_get_title_ident); bind_info.cbs = cbs; bind_info.path = path; bind_info.label = label; bind_info.type = type; bind_info.idx = idx; bind_info.elem0 = elem0; bind_info.elem1 = elem1; bind_info.label_hash = label_hash; bind_info.menu_label_hash = menu_label_hash; menu_driver_ctl(RARCH_MENU_CTL_BIND_INIT, &bind_info); error: string_list_free(str_list); str_list = NULL; }
/** * menu_iterate: * @input : input sample for this frame * @old_input : input sample of the previous frame * @trigger_input : difference' input sample - difference * between 'input' and 'old_input' * * Runs RetroArch menu for one frame. * * Returns: 0 on success, -1 if we need to quit out of the loop. **/ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) { menu_entry_t entry; enum action_iterate_type iterate_type; size_t selection = 0; unsigned file_type = 0; int ret = 0; uint32_t hash = 0; enum msg_hash_enums enum_idx = MSG_UNKNOWN; const char *label = NULL; menu_handle_t *menu = (menu_handle_t*)data; menu_entries_get_last_stack(NULL, &label, &file_type, &enum_idx, NULL); if (!menu) return 0; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) return 0; menu->menu_state.msg[0] = '\0'; hash = msg_hash_calculate(label); iterate_type = action_iterate_type(hash); menu_driver_set_binding_state(iterate_type == ITERATE_TYPE_BIND); if ( action != MENU_ACTION_NOOP || menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL) || menu_display_get_update_pending()) { BIT64_SET(menu->state, MENU_STATE_RENDER_FRAMEBUFFER); } switch (iterate_type) { case ITERATE_TYPE_HELP: ret = menu_dialog_iterate( menu->menu_state.msg, sizeof(menu->menu_state.msg), label); BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX); BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); if (ret == 1 || action == MENU_ACTION_OK) { BIT64_SET(menu->state, MENU_STATE_POP_STACK); menu_dialog_set_active(false); } if (action == MENU_ACTION_CANCEL) { BIT64_SET(menu->state, MENU_STATE_POP_STACK); menu_dialog_set_active(false); } break; case ITERATE_TYPE_BIND: { menu_input_ctx_bind_t bind; bind.s = menu->menu_state.msg; bind.len = sizeof(menu->menu_state.msg); if (menu_input_key_bind_iterate(&bind)) { menu_entries_pop_stack(&selection, 0, 0); menu_navigation_ctl( MENU_NAVIGATION_CTL_SET_SELECTION, &selection); } else BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX); } break; case ITERATE_TYPE_INFO: { file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); menu_file_list_cbs_t *cbs = menu_entries_get_actiondata_at_offset(selection_buf, selection); if (cbs->enum_idx != MSG_UNKNOWN) { ret = menu_hash_get_help_enum(cbs->enum_idx, menu->menu_state.msg, sizeof(menu->menu_state.msg)); } else { unsigned type = 0; enum msg_hash_enums enum_idx = MSG_UNKNOWN; menu_entries_get_at_offset(selection_buf, selection, NULL, NULL, &type, NULL, NULL); switch (type) { case FILE_TYPE_FONT: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_FONT; break; case FILE_TYPE_RDB: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_RDB; break; case FILE_TYPE_OVERLAY: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_OVERLAY; break; case FILE_TYPE_CHEAT: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_CHEAT; break; case FILE_TYPE_SHADER_PRESET: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_SHADER_PRESET; break; case FILE_TYPE_SHADER: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_SHADER; break; case FILE_TYPE_REMAP: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_REMAP; break; case FILE_TYPE_RECORD_CONFIG: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_RECORD_CONFIG; break; case FILE_TYPE_CURSOR: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_CURSOR; break; case FILE_TYPE_CONFIG: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_CONFIG; break; case FILE_TYPE_CARCHIVE: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_COMPRESSED_ARCHIVE; break; case FILE_TYPE_DIRECTORY: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_DIRECTORY; break; case FILE_TYPE_VIDEOFILTER: /* TODO/FIXME */ case FILE_TYPE_AUDIOFILTER: /* TODO/FIXME */ case FILE_TYPE_SHADER_SLANG: /* TODO/FIXME */ case FILE_TYPE_SHADER_GLSL: /* TODO/FIXME */ case FILE_TYPE_SHADER_HLSL: /* TODO/FIXME */ case FILE_TYPE_SHADER_CG: /* TODO/FIXME */ case FILE_TYPE_SHADER_PRESET_GLSLP: /* TODO/FIXME */ case FILE_TYPE_SHADER_PRESET_HLSLP: /* TODO/FIXME */ case FILE_TYPE_SHADER_PRESET_CGP: /* TODO/FIXME */ case FILE_TYPE_SHADER_PRESET_SLANGP: /* TODO/FIXME */ case FILE_TYPE_PLAIN: enum_idx = MENU_ENUM_LABEL_FILE_BROWSER_PLAIN_FILE; break; default: break; } if (enum_idx != MSG_UNKNOWN) ret = menu_hash_get_help_enum(enum_idx, menu->menu_state.msg, sizeof(menu->menu_state.msg)); } } BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX); BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); if (action == MENU_ACTION_OK || action == MENU_ACTION_CANCEL) { BIT64_SET(menu->state, MENU_STATE_POP_STACK); } menu_dialog_set_active(false); break; case ITERATE_TYPE_DEFAULT: /* FIXME: Crappy hack, needed for mouse controls * to not be completely broken in case we press back. * * We need to fix this entire mess, mouse controls * should not rely on a hack like this in order to work. */ selection = MAX(MIN(selection, (menu_entries_get_size() - 1)), 0); menu_entry_get(&entry, 0, selection, NULL, false); ret = menu_entry_action(&entry, selection, (enum menu_action)action); if (ret) goto end; BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); /* Have to defer it so we let settings refresh. */ menu_dialog_push(); break; } BIT64_SET(menu->state, MENU_STATE_BLIT); if (BIT64_GET(menu->state, MENU_STATE_POP_STACK)) { size_t new_selection_ptr = selection; menu_entries_pop_stack(&new_selection_ptr, 0, 0); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); } if (BIT64_GET(menu->state, MENU_STATE_POST_ITERATE)) menu_input_post_iterate(&ret, action); end: if (ret) return -1; return 0; }
void menu_entry_get(menu_entry_t *entry, size_t stack_idx, size_t i, void *userdata, bool use_representation) { char newpath[255]; const char *path = NULL; const char *entry_label = NULL; menu_file_list_cbs_t *cbs = NULL; file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(stack_idx); file_list_t *list = (userdata) ? (file_list_t*)userdata : selection_buf; newpath[0] = '\0'; if (!list) return; file_list_get_at_offset(list, i, &path, &entry_label, &entry->type, &entry->entry_idx); cbs = (menu_file_list_cbs_t*)file_list_get_actiondata_at_offset(list, i); if (cbs) { const char *label = NULL; enum msg_hash_enums enum_idx = MSG_UNKNOWN; entry->enum_idx = cbs->enum_idx; entry->checked = cbs->checked; menu_entries_get_last_stack(NULL, &label, NULL, &enum_idx, NULL); if (cbs->action_get_value && use_representation) { char tmp[255]; tmp[0] = '\0'; cbs->action_get_value(list, &entry->spacing, entry->type, (unsigned)i, label, tmp, sizeof(tmp), entry_label, path, newpath, sizeof(newpath) ); if (!string_is_empty(tmp)) entry->value = strdup(tmp); } if (cbs->action_label) { char tmp[255]; tmp[0] = '\0'; cbs->action_label(list, entry->type, (unsigned)i, label, path, tmp, sizeof(tmp)); if (!string_is_empty(tmp)) entry->rich_label = strdup(tmp); } if (cbs->action_sublabel) { char tmp[512]; tmp[0] = '\0'; cbs->action_sublabel(list, entry->type, (unsigned)i, label, path, tmp, sizeof(tmp)); if (!string_is_empty(tmp)) entry->sublabel = strdup(tmp); } } entry->idx = (unsigned)i; if (!string_is_empty(path) && !use_representation) strlcpy(newpath, path, sizeof(newpath)); else if (cbs && cbs->setting && cbs->setting->enum_value_idx != MSG_UNKNOWN && !cbs->setting->dont_use_enum_idx_representation) strlcpy(newpath, msg_hash_to_str(cbs->setting->enum_value_idx), sizeof(newpath)); if (!string_is_empty(newpath)) entry->path = strdup(newpath); if (!string_is_empty(entry_label)) entry->label = strdup(entry_label); }