From 31c1f312990ea060b5373abab43066371ffc3f98 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 19 Jun 2016 00:25:52 +0200 Subject: [PATCH] Improve MENU_NAVIGATION_CTL_ASCEND_ALPHABET - can no longer get out of bounds, will now properly scroll down to end of list if it can not jump alphabetically to the next letter and there is still space to go to the end of the list --- menu/menu_navigation.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index 290c4988bf..fbf764ff27 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -142,7 +142,9 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data) case MENU_NAVIGATION_CTL_ASCEND_ALPHABET: { size_t i = 0, ptr; - size_t *ptr_out = (size_t*)&selection_ptr; + bool scrolled_down = false; + size_t *ptr_out = (size_t*)&selection_ptr; + size_t menu_list_size = menu_entries_get_size(); if (!scroll_index.size || !ptr_out) return false; @@ -150,13 +152,20 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data) ptr = *ptr_out; if (ptr == scroll_index.list[scroll_index.size - 1]) - return false; + { + *ptr_out = menu_list_size - 1; + menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_ASCEND_ALPHABET, ptr_out); + return true; + } while (i < scroll_index.size - 1 && scroll_index.list[i + 1] <= ptr) i++; *ptr_out = scroll_index.list[i + 1]; + if (*ptr_out >= menu_list_size) + *ptr_out = menu_list_size - 1; + menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_ASCEND_ALPHABET, ptr_out); } break;