diff --git a/menu/cbs/menu_cbs_down.c b/menu/cbs/menu_cbs_down.c index fc148b02ed..5790f630b1 100644 --- a/menu/cbs/menu_cbs_down.c +++ b/menu/cbs/menu_cbs_down.c @@ -27,15 +27,12 @@ static int action_bind_down_generic(unsigned type, const char *label) { size_t scroll_accel = 0; unsigned scroll_speed = 0; - menu_list_t *menu_list = menu_list_get_ptr(); - if (!menu_list) - return -1; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) return -1; scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1; - if (menu_list_get_size(menu_list) <= 0) + if (menu_entries_get_size() <= 0) return 0; menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, &scroll_speed); diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 275ca9a6b7..659e317c9c 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -126,9 +126,6 @@ static int action_right_scroll(unsigned type, const char *label, size_t selection; size_t scroll_accel = 0; unsigned scroll_speed = 0, fast_scroll_speed = 0; - menu_list_t *menu_list = menu_list_get_ptr(); - if (!menu_list) - return -1; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) return false; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) @@ -137,7 +134,7 @@ static int action_right_scroll(unsigned type, const char *label, scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1; fast_scroll_speed = 4 + 4 * scroll_speed; - if (selection + fast_scroll_speed < (menu_list_get_size(menu_list))) + if (selection + fast_scroll_speed < (menu_entries_get_size())) { size_t idx = selection + fast_scroll_speed; bool scroll = true; @@ -146,7 +143,7 @@ static int action_right_scroll(unsigned type, const char *label, } else { - if ((menu_list_get_size(menu_list) > 0)) + if ((menu_entries_get_size() > 0)) menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_LAST, NULL); } diff --git a/menu/cbs/menu_cbs_up.c b/menu/cbs/menu_cbs_up.c index b6f1d72ddd..2a478d5e8e 100644 --- a/menu/cbs/menu_cbs_up.c +++ b/menu/cbs/menu_cbs_up.c @@ -27,15 +27,12 @@ static int action_bind_up_generic(unsigned type, const char *label) { size_t scroll_accel = 0; unsigned scroll_speed = 0; - menu_list_t *menu_list = menu_list_get_ptr(); - if (!menu_list) - return -1; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) return -1; scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1; - if (menu_list_get_size(menu_list) <= 0) + if (menu_entries_get_size() <= 0) return 0; menu_navigation_ctl(MENU_NAVIGATION_CTL_DECREMENT, &scroll_speed); diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 618b5c9d8b..4cf2d3201e 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -212,13 +212,12 @@ int generic_menu_iterate(enum menu_action action) uint32_t label_hash = 0; uint32_t hash = 0; menu_handle_t *menu = menu_driver_get_ptr(); - menu_list_t *menu_list = menu_list_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 || !menu_list) + if (!menu) return 0; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) return 0; @@ -275,7 +274,7 @@ int generic_menu_iterate(enum menu_action action) * * 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_list_get_size(menu_list)-1), 0); + 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); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index eb2b6ddd6b..a36165d4ea 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1403,7 +1403,6 @@ static void xmb_render(void) xmb_handle_t *xmb = NULL; settings_t *settings = config_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr(); - menu_list_t *menu_list = menu_list_get_ptr(); if (!menu) return; @@ -1422,7 +1421,7 @@ static void xmb_render(void) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) return; - end = menu_list_get_size(menu_list); + end = menu_entries_get_size(); if (settings->menu.pointer.enable || settings->menu.mouse.enable) { diff --git a/menu/menu_entries.c b/menu/menu_entries.c index f3065aed81..c95c0ab4d3 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -78,8 +78,7 @@ size_t menu_entries_get_start(void) /* Returns the last index (+1) of the menu entry list. */ size_t menu_entries_get_end(void) { - menu_entries_t *entries = menu_entries_get_ptr(); - return menu_list_get_size(entries->menu_list); + return menu_entries_get_size(); } /* Get an entry from the top of the menu stack */ @@ -324,3 +323,11 @@ size_t menu_entries_get_stack_size(void) return 0; return menu_list_get_stack_size(menu_list); } + +size_t menu_entries_get_size(void) +{ + menu_list_t *menu_list = menu_list_get_ptr(); + if (!menu_list) + return 0; + return menu_list_get_size(menu_list); +} diff --git a/menu/menu_entries.h b/menu/menu_entries.h index 59da873712..54e808d2a1 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -143,6 +143,8 @@ void menu_entries_flush_stack(const char *needle, unsigned final_type); size_t menu_entries_get_stack_size(void); +size_t menu_entries_get_size(void); + #ifdef __cplusplus } #endif diff --git a/menu/menu_input.c b/menu/menu_input.c index 1473fb3693..cba2028aaf 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -942,7 +942,6 @@ static int menu_input_mouse_post_iterate(uint64_t *input_mouse, unsigned header_height; settings_t *settings = config_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); - menu_list_t *menu_list = menu_list_get_ptr(); *input_mouse = MOUSE_ACTION_NONE; @@ -981,7 +980,7 @@ static int menu_input_mouse_post_iterate(uint64_t *input_mouse, { BIT64_SET(*input_mouse, MOUSE_ACTION_BUTTON_L_TOGGLE); } - else if (menu_input->mouse.ptr <= menu_list_get_size(menu_list)-1) + else if (menu_input->mouse.ptr <= (menu_entries_get_size() - 1)) { BIT64_SET(*input_mouse, MOUSE_ACTION_BUTTON_L_SET_NAVIGATION); } @@ -1080,7 +1079,6 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs, unsigned header_height; size_t selection; int ret = 0; - menu_list_t *menu_list = menu_list_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); settings_t *settings = config_get_ptr(); @@ -1142,7 +1140,7 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs, menu_entries_pop_stack(&selection); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); } - else if (menu_input->pointer.ptr <= menu_list_get_size(menu_list)-1) + else if (menu_input->pointer.ptr <= (menu_entries_get_size() - 1)) { menu_input->pointer.oldpressed[0] = false; ret = pointer_tap(cbs, entry, action); diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index c415edf796..c737336028 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -58,11 +58,9 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data) const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr(); settings_t *settings = config_get_ptr(); menu_navigation_t *nav = menu_navigation_get_ptr(); - menu_list_t *menu_list = menu_list_get_ptr(); - size_t menu_list_size = menu_list_get_size(menu_list); + size_t menu_list_size = menu_entries_get_size(); size_t selection = nav->selection_ptr; - (void)menu_list; (void)settings; switch (state)