diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index ecb9de475a..e8ac23bff3 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -465,11 +465,11 @@ static int action_left_mainmenu(unsigned type, const char *label, if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); - menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SELECTION, &list_info); + menu_driver_list_get_selection(&list_info); list_info.type = MENU_LIST_PLAIN; - menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_info); + menu_driver_list_get_size(&list_info); if (list_info.size == 1) { @@ -498,7 +498,7 @@ static int action_left_mainmenu(unsigned type, const char *label, list_info.type = MENU_LIST_HORIZONTAL; list_info.action = MENU_ACTION_LEFT; - menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); + menu_driver_list_cache(&list_info); if (cbs && cbs->action_content_list_switch) return cbs->action_content_list_switch( diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index dde4c64858..f1b3859530 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -225,7 +225,7 @@ static int action_right_goto_tab(void) list_info.type = MENU_LIST_HORIZONTAL; list_info.action = MENU_ACTION_RIGHT; - menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); + menu_driver_list_cache(&list_info); if (cbs && cbs->action_content_list_switch) return cbs->action_content_list_switch(selection_buf, menu_stack, @@ -239,11 +239,11 @@ static int action_right_mainmenu(unsigned type, const char *label, { menu_ctx_list_t list_info; - menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SELECTION, &list_info); + menu_driver_list_get_selection(&list_info); list_info.type = MENU_LIST_PLAIN; - menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_info); + menu_driver_list_get_size(&list_info); if (list_info.size == 1) { @@ -254,8 +254,8 @@ static int action_right_mainmenu(unsigned type, const char *label, list_horiz_info.type = MENU_LIST_HORIZONTAL; list_tabs_info.type = MENU_LIST_TABS; - menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_horiz_info); - menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_tabs_info); + menu_driver_list_get_size(&list_horiz_info); + menu_driver_list_get_size(&list_tabs_info); if ((list_info.selection != (list_horiz_info.size + list_tabs_info.size)) || settings->bools.menu_navigation_wraparound_enable) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index cccd8c0fa7..a99f3c4b3f 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2494,15 +2494,16 @@ static int menu_displaylist_parse_horizontal_list( playlist_t *playlist = NULL; struct item_file *item = NULL; - menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SELECTION, &list_info); + menu_driver_list_get_selection(&list_info); list_info.type = MENU_LIST_TABS; - menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_info); + + menu_driver_list_get_size(&list_info); list_horiz_info.type = MENU_LIST_HORIZONTAL; list_horiz_info.idx = list_info.selection - (list_info.size +1); - menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_ENTRY, &list_horiz_info); + menu_driver_list_get_entry(&list_horiz_info); item = (struct item_file*)list_horiz_info.entry; @@ -7339,7 +7340,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) list_info.type = MENU_LIST_PLAIN; list_info.action = 0; - menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); + menu_driver_list_cache(&list_info); menu_entries_append_enum(info->list, info->path, info->label, MSG_UNKNOWN, info->type, info->directory_ptr, 0); @@ -7355,7 +7356,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) list_info.type = MENU_LIST_PLAIN; list_info.action = 0; - menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); + menu_driver_list_cache(&list_info); menu_entries_append_enum(info->list, info->path, info->label, MSG_UNKNOWN, info->type, info->directory_ptr, 0); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 5c784bfc9b..26bf0a9f9f 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -1949,10 +1949,19 @@ bool menu_driver_iterate(menu_ctx_iterate_t *iterate) return true; } -/* Clear all the menu lists. */ -bool menu_driver_list_clear(void *data) +bool menu_driver_list_cache(menu_ctx_list_t *list) +{ + if (!list || !menu_driver_ctx || !menu_driver_ctx->list_cache) + return false; + + menu_driver_ctx->list_cache(menu_userdata, + list->type, list->action); + return true; +} + +/* Clear all the menu lists. */ +bool menu_driver_list_clear(file_list_t *list) { - file_list_t *list = (file_list_t*)data; if (!list) return false; if (menu_driver_ctx->list_clear) @@ -1960,6 +1969,18 @@ bool menu_driver_list_clear(void *data) return true; } +bool menu_driver_list_set_selection(file_list_t *list) +{ + if (!list) + return false; + + if (!menu_driver_ctx || !menu_driver_ctx->list_set_selection) + return false; + + menu_driver_ctx->list_set_selection(menu_userdata, list); + return true; +} + static void menu_update_libretro_info(void) { command_event(CMD_EVENT_CORE_INFO_INIT, NULL); @@ -2057,6 +2078,41 @@ void menu_driver_destroy(void) menu_userdata = NULL; } +bool menu_driver_list_get_entry(menu_ctx_list_t *list) +{ + if (!menu_driver_ctx || !menu_driver_ctx->list_get_entry) + { + list->entry = NULL; + return false; + } + list->entry = menu_driver_ctx->list_get_entry(menu_userdata, + list->type, (unsigned int)list->idx); + return true; +} + +bool menu_driver_list_get_selection(menu_ctx_list_t *list) +{ + if (!menu_driver_ctx || !menu_driver_ctx->list_get_selection) + { + list->selection = 0; + return false; + } + list->selection = menu_driver_ctx->list_get_selection(menu_userdata); + + return true; +} + +bool menu_driver_list_get_size(menu_ctx_list_t *list) +{ + if (!menu_driver_ctx || !menu_driver_ctx->list_get_size) + { + list->size = 0; + return false; + } + list->size = menu_driver_ctx->list_get_size(menu_userdata, list->type); + return true; +} + bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) { switch (state) @@ -2202,42 +2258,6 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) } menu_driver_data = NULL; break; - case RARCH_MENU_CTL_LIST_GET_ENTRY: - { - menu_ctx_list_t *list = (menu_ctx_list_t*)data; - - if (!menu_driver_ctx || !menu_driver_ctx->list_get_entry) - { - list->entry = NULL; - return false; - } - list->entry = menu_driver_ctx->list_get_entry(menu_userdata, - list->type, (unsigned int)list->idx); - } - break; - case RARCH_MENU_CTL_LIST_GET_SIZE: - { - menu_ctx_list_t *list = (menu_ctx_list_t*)data; - if (!menu_driver_ctx || !menu_driver_ctx->list_get_size) - { - list->size = 0; - return false; - } - list->size = menu_driver_ctx->list_get_size(menu_userdata, list->type); - } - break; - case RARCH_MENU_CTL_LIST_GET_SELECTION: - { - menu_ctx_list_t *list = (menu_ctx_list_t*)data; - - if (!menu_driver_ctx || !menu_driver_ctx->list_get_selection) - { - list->selection = 0; - return false; - } - list->selection = menu_driver_ctx->list_get_selection(menu_userdata); - } - break; case RARCH_MENU_CTL_LIST_FREE: { menu_ctx_list_t *list = (menu_ctx_list_t*)data; @@ -2255,28 +2275,6 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) } } break; - case RARCH_MENU_CTL_LIST_SET_SELECTION: - { - file_list_t *list = (file_list_t*)data; - - if (!list) - return false; - - if (!menu_driver_ctx || !menu_driver_ctx->list_set_selection) - return false; - - menu_driver_ctx->list_set_selection(menu_userdata, list); - } - break; - case RARCH_MENU_CTL_LIST_CACHE: - { - menu_ctx_list_t *list = (menu_ctx_list_t*)data; - if (!list || !menu_driver_ctx || !menu_driver_ctx->list_cache) - return false; - menu_driver_ctx->list_cache(menu_userdata, - list->type, list->action); - } - break; case RARCH_MENU_CTL_LIST_INSERT: { menu_ctx_list_t *list = (menu_ctx_list_t*)data; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 996a65d7de..ad16062a91 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -102,11 +102,6 @@ enum rarch_menu_ctl_state RARCH_MENU_CTL_OWNS_DRIVER, RARCH_MENU_CTL_FIND_DRIVER, RARCH_MENU_CTL_LIST_FREE, - RARCH_MENU_CTL_LIST_SET_SELECTION, - RARCH_MENU_CTL_LIST_GET_SELECTION, - RARCH_MENU_CTL_LIST_GET_SIZE, - RARCH_MENU_CTL_LIST_GET_ENTRY, - RARCH_MENU_CTL_LIST_CACHE, RARCH_MENU_CTL_LIST_INSERT, RARCH_MENU_CTL_ENVIRONMENT, RARCH_MENU_CTL_DRIVER_DATA_GET, @@ -655,7 +650,9 @@ bool menu_driver_is_alive(void); bool menu_driver_iterate(menu_ctx_iterate_t *iterate); -bool menu_driver_list_clear(void *data); +bool menu_driver_list_clear(file_list_t *list); + +bool menu_driver_list_cache(menu_ctx_list_t *list); void menu_driver_navigation_set(bool scroll); @@ -669,11 +666,18 @@ void menu_driver_set_thumbnail_system(char *s, size_t len); void menu_driver_set_thumbnail_content(char *s, size_t len); +bool menu_driver_list_set_selection(file_list_t *list); + +bool menu_driver_list_get_selection(menu_ctx_list_t *list); + +bool menu_driver_list_get_entry(menu_ctx_list_t *list); + +bool menu_driver_list_get_size(menu_ctx_list_t *list); + size_t menu_navigation_get_selection(void); void menu_navigation_set_selection(size_t val); - enum menu_toggle_reason menu_display_toggle_get_reason(void); void menu_display_toggle_set_reason(enum menu_toggle_reason reason); diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 3ac71df212..5c85e2d0e7 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -181,7 +181,7 @@ static bool menu_list_pop_stack(menu_list_t *list, list_info.action = 0; if (animate) - menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); + menu_driver_list_cache(&list_info); if (menu_list->size != 0) { @@ -195,7 +195,7 @@ static bool menu_list_pop_stack(menu_list_t *list, } file_list_pop(menu_list, directory_ptr); - menu_driver_ctl(RARCH_MENU_CTL_LIST_SET_SELECTION, menu_list); + menu_driver_list_set_selection(menu_list); if (animate) menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh);