diff --git a/menu/cbs/menu_cbs_down.c b/menu/cbs/menu_cbs_down.c index b711525392..b711576b1e 100644 --- a/menu/cbs/menu_cbs_down.c +++ b/menu/cbs/menu_cbs_down.c @@ -30,7 +30,7 @@ static int action_bind_down_generic(unsigned type, const char *label) if (menu_list_get_size(menu_list) <= 0) return 0; - menu_navigation_increment(nav, scroll_speed); + menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, &scroll_speed); return 0; } diff --git a/menu/menu_input.c b/menu/menu_input.c index 629c314a9f..c13084f726 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -902,7 +902,10 @@ static int menu_input_mouse_frame( menu_list_pop_stack(menu_list, &nav->selection_ptr); if (BIT64_GET(input_mouse, MOUSE_ACTION_WHEEL_DOWN)) - menu_navigation_increment(nav, 1); + { + unsigned increment_by = 1; + menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, &increment_by); + } if (BIT64_GET(input_mouse, MOUSE_ACTION_WHEEL_UP)) { diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index 464c800f08..272de3e641 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -44,8 +44,36 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data) } return true; case MENU_NAVIGATION_CTL_INCREMENT: - if (driver->navigation_increment) - driver->navigation_increment(); + { + settings_t *settings = config_get_ptr(); + menu_list_t *menu_list = menu_list_get_ptr(); + size_t selection = nav->selection_ptr; + unsigned *scroll_speed = (unsigned*)data; + + if (!scroll_speed) + return false; + + if ((selection + (*scroll_speed)) < (menu_list_get_size(menu_list))) + { + menu_navigation_set(nav, selection + (*scroll_speed), true); + menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, NULL); + } + else + { + if (settings->menu.navigation.wraparound.vertical_enable) + menu_navigation_clear(nav, false); + else + { + if ((menu_list_get_size(menu_list) > 0)) + { + menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_LAST, NULL); + menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, NULL); + } + } + } + if (driver->navigation_increment) + driver->navigation_increment(); + } return true; case MENU_NAVIGATION_CTL_DECREMENT: { @@ -130,41 +158,6 @@ void menu_navigation_clear(menu_navigation_t *nav, bool pending_push) menu_navigation_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push); } -/** - * 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(); - size_t selection = nav->selection_ptr; - - if (!nav) - return; - - if ((selection + scroll_speed) < (menu_list_get_size(menu_list))) - { - menu_navigation_set(nav, selection + scroll_speed, true); - menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, NULL); - } - else - { - if (settings->menu.navigation.wraparound.vertical_enable) - menu_navigation_clear(nav, false); - else - { - if ((menu_list_get_size(menu_list) > 0)) - { - menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_LAST, NULL); - menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, NULL); - } - } - } - -} - /** * menu_navigation_set: * @idx : index to set navigation pointer to. diff --git a/menu/menu_navigation.h b/menu/menu_navigation.h index 106a121f07..714e51e1c3 100644 --- a/menu/menu_navigation.h +++ b/menu/menu_navigation.h @@ -63,13 +63,6 @@ enum menu_navigation_ctl_state **/ void menu_navigation_clear(menu_navigation_t *nav, bool pending_push); -/** - * menu_navigation_increment: - * - * Increment the navigation pointer. - **/ -void menu_navigation_increment(menu_navigation_t *nav, unsigned scroll_speed); - /** * menu_navigation_set: * @idx : index to set navigation pointer to. @@ -112,6 +105,8 @@ void menu_navigation_ascend_alphabet(menu_navigation_t *nav, size_t *ptr_out); size_t menu_navigation_get_selection(menu_navigation_t *nav); +bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data); + #ifdef __cplusplus } #endif