file_list_t *menu_entries_get_selection_buf_ptr(void) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return NULL; return menu_list->selection_buf; }
size_t menu_entries_get_size(void) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return 0; return file_list_get_size(menu_list->selection_buf[0]); }
int menu_entry_pathdir_set_value(uint32_t i, const char *s) { const char *menu_label = NULL; const char *menu_path = NULL; rarch_setting_t *setting = NULL; menu_list_t *menu_list = menu_list_get_ptr(); menu_list_get_last_stack(menu_list, &menu_path, &menu_label, NULL, NULL); setting = menu_setting_find(menu_label); if (!setting) return -1; if (setting->type != ST_DIR) return -1; (void)s; setting_set_with_string_representation(setting, menu_path); menu_setting_generic(setting, false); menu_list_pop_stack_by_needle(menu_list, setting->name); return 0; }
static int menu_input_mouse_frame( menu_file_list_cbs_t *cbs, menu_entry_t *entry, uint64_t input_mouse) { menu_input_t *menu_input = menu_input_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); menu_navigation_t *nav = menu_navigation_get_ptr(); if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L)) { if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L_TOGGLE)) return menu_entry_action(entry, nav->selection_ptr, MENU_ACTION_SELECT); if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L_SET_NAVIGATION)) menu_navigation_set(nav, menu_input->mouse.ptr, false); } if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_R)) menu_list_pop_stack(menu_list, &nav->selection_ptr); if (BIT64_GET(input_mouse, MOUSE_ACTION_WHEEL_DOWN)) menu_navigation_increment(nav, 1); if (BIT64_GET(input_mouse, MOUSE_ACTION_WHEEL_UP)) menu_navigation_decrement(nav, 1); return 0; }
/** * menu_navigation_increment: * * Increment the navigation pointer. **/ void menu_navigation_increment(menu_navigation_t *nav, unsigned scroll_speed) { settings_t *settings = config_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); if (!nav) return; if (nav->selection_ptr + scroll_speed < (menu_list_get_size(menu_list))) { menu_navigation_set(nav, nav->selection_ptr + scroll_speed, true); menu_driver_navigation_increment(); } else { if (settings->menu.navigation.wraparound.vertical_enable) menu_navigation_clear(nav, false); else { if ((menu_list_get_size(menu_list) > 0)) { menu_navigation_set_last(nav); menu_driver_navigation_increment(); } } } }
void menu_entries_get_last_stack(const char **path, const char **label, unsigned *file_type, size_t *entry_idx) { menu_list_t *menu_list = menu_list_get_ptr(); if (menu_list) menu_entries_get_last(menu_list->menu_stack[0], path, label, file_type, entry_idx); }
menu_file_list_cbs_t *menu_entries_get_last_stack_actiondata(void) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return NULL; return (menu_file_list_cbs_t*)file_list_get_last_actiondata(menu_list->menu_stack[0]); }
file_list_t *menu_entries_get_selection_buf_ptr(size_t idx) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return NULL; return menu_list->selection_buf[idx]; }
file_list_t *menu_entries_get_menu_stack_ptr(size_t idx) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return NULL; return menu_list->menu_stack[idx]; }
void menu_common_load_content(bool persist, enum rarch_core_type type) { menu_display_t *disp = menu_display_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return; switch (type) { case CORE_TYPE_PLAIN: case CORE_TYPE_DUMMY: event_command(persist ? EVENT_CMD_LOAD_CONTENT_PERSIST : EVENT_CMD_LOAD_CONTENT); break; #ifdef HAVE_FFMPEG case CORE_TYPE_FFMPEG: event_command(EVENT_CMD_LOAD_CONTENT_FFMPEG); break; #endif case CORE_TYPE_IMAGEVIEWER: #ifdef HAVE_IMAGEVIEWER event_command(EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER); #endif break; } menu_list_flush_stack(menu_list, NULL, MENU_SETTINGS); disp->msg_force = true; menu_common_push_content_settings(); }
void menu_input_post_iterate(int *ret, unsigned action) { size_t selection; menu_file_list_cbs_t *cbs = NULL; menu_entry_t entry = {{0}}; menu_input_t *menu_input = menu_input_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); settings_t *settings = config_get_ptr(); if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) return; cbs = menu_list_get_actiondata_at_offset (menu_list->selection_buf, selection); menu_entry_get(&entry, selection, NULL, false); if (settings->menu.mouse.enable) *ret = menu_input_mouse_post_iterate (&menu_input->mouse.state, cbs, action); *ret = menu_input_mouse_frame(cbs, &entry, menu_input->mouse.state); if (settings->menu.pointer.enable) *ret |= menu_input_pointer_post_iterate(cbs, &entry, action); }
size_t menu_entries_get_stack_size(size_t idx) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return 0; return menu_list_get_stack_size(menu_list, idx); }
file_list_t *menu_entries_get_menu_stack_ptr(void) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return NULL; return menu_list->menu_stack; }
int deferred_push_content_list(void *data, void *userdata, const char *path, const char *label, unsigned type) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return -1; return menu_displaylist_push((file_list_t*)data, menu_list->selection_buf); }
// Returns true if a Back button should be shown (i.e. we are at least // one level deep in the menu hierarchy) uint32_t menu_entries_show_back(void) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return false; return (menu_list_get_stack_size(menu_list) > 1); }
// Returns the last index + 1 of the menu entry list size_t menu_entries_get_end(void) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return 0; return menu_list_get_size(menu_list); }
static int menu_input_set_bind_mode_common(rarch_setting_t *setting, enum menu_input_bind_mode type) { size_t selection; menu_displaylist_info_t info = {0}; struct retro_keybind *keybind = NULL; settings_t *settings = config_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); if (!setting) return -1; menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); switch (type) { case MENU_INPUT_BIND_NONE: return -1; case MENU_INPUT_BIND_SINGLE: keybind = (struct retro_keybind*)setting->value.keybind; if (!keybind) return -1; menu_input->binds.begin = setting->bind_type; menu_input->binds.last = setting->bind_type; menu_input->binds.target = keybind; menu_input->binds.user = setting->index_offset; info.list = menu_list->menu_stack; info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; info.directory_ptr = selection; strlcpy(info.label, menu_hash_to_str(MENU_LABEL_CUSTOM_BIND), sizeof(info.label)); menu_displaylist_push_list(&info, DISPLAYLIST_INFO); break; case MENU_INPUT_BIND_ALL: menu_input->binds.target = &settings->input.binds [setting->index_offset][0]; menu_input->binds.begin = MENU_SETTINGS_BIND_BEGIN; menu_input->binds.last = MENU_SETTINGS_BIND_LAST; info.list = menu_list->menu_stack; info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; info.directory_ptr = selection; strlcpy(info.label, menu_hash_to_str(MENU_LABEL_CUSTOM_BIND_ALL), sizeof(info.label)); menu_displaylist_push_list(&info, DISPLAYLIST_INFO); break; } return 0; }
static int action_select_default(const char *path, const char *label, unsigned type, size_t idx) { menu_entry_t entry; int ret = 0; enum menu_action action = MENU_ACTION_NOOP; menu_file_list_cbs_t *cbs = NULL; menu_list_t *menu_list = menu_list_get_ptr(); menu_entry_get(&entry, idx, NULL, false); cbs = menu_list_get_actiondata_at_offset(menu_list->selection_buf, idx); if (cbs->setting) { switch (cbs->setting->type) { case ST_BOOL: case ST_INT: case ST_UINT: case ST_FLOAT: action = MENU_ACTION_RIGHT; break; case ST_PATH: case ST_DIR: case ST_ACTION: case ST_STRING: case ST_HEX: case ST_BIND: action = MENU_ACTION_OK; break; default: break; } } if (action == MENU_ACTION_NOOP) { if (cbs && cbs->action_ok) action = MENU_ACTION_OK; else { if (cbs && cbs->action_start) action = MENU_ACTION_START; if (cbs && cbs->action_right) action = MENU_ACTION_RIGHT; } } if (action != MENU_ACTION_NOOP) ret = menu_entry_action(&entry, idx, action); rarch_main_data_iterate(); return ret; }
/** * menu_navigation_set_last: * * Sets navigation pointer to last index. **/ void menu_navigation_set_last(menu_navigation_t *nav) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list || !nav) return; nav->selection_ptr = menu_list_get_size(menu_list) - 1; menu_driver_navigation_set_last(); }
static int archive_load(void) { int ret = 0; menu_displaylist_info_t info = {0}; const char *menu_path = NULL; const char *menu_label = NULL; const char* path = NULL; size_t entry_idx = 0; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); size_t selected = menu_navigation_get_current_selection(); menu_handle_t *menu = menu_driver_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); if (!menu || !menu_list) return -1; menu_list_pop_stack(menu_list); menu_list_get_last_stack(menu_list, &menu_path, &menu_label, NULL, NULL); if (menu_list_get_size(menu_list) == 0) return 0; menu_list_get_at_offset(menu_list->selection_buf, selected, &path, NULL, NULL, &entry_idx); ret = rarch_defer_core(global->core_info, menu_path, path, menu_label, menu->deferred_path, sizeof(menu->deferred_path)); fill_pathname_join(detect_content_path, menu_path, path, sizeof(detect_content_path)); switch (ret) { case -1: event_command(EVENT_CMD_LOAD_CORE); menu_common_load_content(false, CORE_TYPE_PLAIN); break; case 0: info.list = menu_list->menu_stack; info.type = 0; info.directory_ptr = selected; strlcpy(info.path, settings->libretro_directory, sizeof(info.path)); strlcpy(info.label, menu_hash_to_str(MENU_LABEL_DEFERRED_CORE_LIST), sizeof(info.label)); ret = menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC); break; } return ret; }
void menu_common_load_content(bool persist) { menu_display_t *disp = menu_display_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return; event_command(persist ? EVENT_CMD_LOAD_CONTENT_PERSIST : EVENT_CMD_LOAD_CONTENT); menu_list_flush_stack(menu_list, NULL, MENU_SETTINGS); disp->msg_force = true; }
// Sets title to what the name of the current menu should be void menu_entries_get_title(char *title, size_t title_len) { const char *dir = NULL; const char *label = NULL; unsigned menu_type = 0; menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return; menu_list_get_last_stack(menu_list, &dir, &label, &menu_type); get_title(label, dir, menu_type, title, title_len); }
int menu_common_load_content( const char *core_path, const char *fullpath, bool persist, enum rarch_core_type type) { settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); menu_display_t *disp = menu_display_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); enum event_command cmd = EVENT_CMD_NONE; if (core_path) { strlcpy(settings->libretro, core_path, sizeof(settings->libretro)); event_command(EVENT_CMD_LOAD_CORE); } if (fullpath) { strlcpy(global->path.fullpath, fullpath, sizeof(global->path.fullpath)); } switch (type) { case CORE_TYPE_PLAIN: case CORE_TYPE_DUMMY: cmd = persist ? EVENT_CMD_LOAD_CONTENT_PERSIST : EVENT_CMD_LOAD_CONTENT; break; #ifdef HAVE_FFMPEG case CORE_TYPE_FFMPEG: cmd = EVENT_CMD_LOAD_CONTENT_FFMPEG; break; #endif case CORE_TYPE_IMAGEVIEWER: #ifdef HAVE_IMAGEVIEWER cmd = EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER; #endif break; } if (cmd != EVENT_CMD_NONE) event_command(cmd); menu_list_flush_stack(menu_list, NULL, MENU_SETTINGS); disp->msg_force = true; generic_action_ok_displaylist_push("", "", 0, 0, 0, ACTION_OK_DL_CONTENT_SETTINGS); return -1; }
static void menu_input_search_callback(void *userdata, const char *str) { size_t idx = 0; menu_list_t *menu_list = menu_list_get_ptr(); menu_navigation_t *nav = menu_navigation_get_ptr(); if (!menu_list || !nav) return; if (str && *str && file_list_search(menu_list->selection_buf, str, &idx)) menu_navigation_set(nav, idx, true); menu_input_key_end_line(); }
static int action_ok_help(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(); menu_list_t *menu_list = menu_list_get_ptr(); if (!menu || !menu_list) return -1; info.list = menu_list->menu_stack; strlcpy(info.label, "help", sizeof(info.label)); return menu_displaylist_push_list(&info, DISPLAYLIST_HELP); }
static int action_ok_compressed_archive_push(const char *path, const char *label, unsigned type, size_t idx) { menu_displaylist_info_t info = {0}; menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return -1; info.list = menu_list->menu_stack; info.directory_ptr = idx; strlcpy(info.path, path, sizeof(info.path)); strlcpy(info.label, "load_open_zip", sizeof(info.label)); return menu_displaylist_push_list(&info, DISPLAYLIST_SELECT); }
void menu_common_push_content_settings(void) { menu_list_t *menu_list = menu_list_get_ptr(); menu_displaylist_info_t info = {0}; if (!menu_list) return; info.list = menu_list->selection_buf; strlcpy(info.path, menu_hash_to_str(MENU_LABEL_VALUE_CONTENT_SETTINGS), sizeof(info.path)); strlcpy(info.label, menu_hash_to_str(MENU_LABEL_CONTENT_SETTINGS), sizeof(info.label)); menu_list_push(menu_list->menu_stack, info.path, info.label, info.type, info.flags, 0); menu_displaylist_push_list(&info, DISPLAYLIST_CONTENT_SETTINGS); }
/* Clicks the back button */ int menu_entry_go_back(void) { menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return -1; menu_setting_apply_deferred(); menu_list_pop_stack(menu_list); if (menu_entries_needs_refresh()) menu_entries_refresh(MENU_ACTION_CANCEL); rarch_main_data_iterate(); return 0; }
static int action_info_default(unsigned type, const char *label) { menu_displaylist_info_t info = {0}; menu_navigation_t *nav = menu_navigation_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return 0; info.list = menu_list->menu_stack; info.directory_ptr = nav->selection_ptr; strlcpy(info.label, menu_hash_to_str(MENU_LABEL_INFO_SCREEN), sizeof(info.label)); return menu_displaylist_push_list(&info, DISPLAYLIST_HELP); }
int menu_entry_get_current_id(bool use_representation) { size_t i; menu_list_t *menu_list = menu_list_get_ptr(); size_t end = menu_list_get_size(menu_list); for (i = 0; i < end; i++) { menu_entry_t entry = {{0}}; menu_entry_get(&entry, i, NULL, use_representation); if (menu_entry_is_currently_selected(entry.idx)) return i; } return -1; }