From 2759c9fe046c0bfcc2e29f9fe8597704e242f7af Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 25 Sep 2015 18:31:54 +0200 Subject: [PATCH] No longer need menu_navigation_get_ptr inside menu_entry.c --- menu/menu_entry.c | 5 ++--- menu/menu_navigation.c | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/menu/menu_entry.c b/menu/menu_entry.c index b84983e835..4114965565 100644 --- a/menu/menu_entry.c +++ b/menu/menu_entry.c @@ -354,7 +354,6 @@ int menu_entry_select(uint32_t i) int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action) { int ret = 0; - menu_navigation_t *nav = menu_navigation_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); menu_file_list_cbs_t *cbs = menu_list_get_actiondata_at_offset(menu_list->selection_buf, i); @@ -369,10 +368,10 @@ int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action) ret = cbs->action_down(entry->type, entry->label); break; case MENU_ACTION_SCROLL_UP: - menu_navigation_ctl(MENU_NAVIGATION_CTL_DESCEND_ALPHABET, &nav->selection_ptr); + menu_navigation_ctl(MENU_NAVIGATION_CTL_DESCEND_ALPHABET, NULL); break; case MENU_ACTION_SCROLL_DOWN: - menu_navigation_ctl(MENU_NAVIGATION_CTL_ASCEND_ALPHABET, &nav->selection_ptr); + menu_navigation_ctl(MENU_NAVIGATION_CTL_ASCEND_ALPHABET, NULL); break; case MENU_ACTION_CANCEL: if (cbs && cbs->action_cancel) diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index d3e1f4ef11..208b0e77c4 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -135,10 +135,14 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data) return true; case MENU_NAVIGATION_CTL_ASCEND_ALPHABET: { - size_t *ptr_out = (size_t*)data; - size_t i = 0, ptr = *ptr_out; + size_t i = 0, ptr; + size_t *ptr_out = nav ? (size_t*)&nav->selection_ptr : NULL; + if (!nav || !nav->scroll.indices.size || !ptr_out) return false; + + ptr = *ptr_out; + if (ptr == nav->scroll.indices.list[nav->scroll.indices.size - 1]) return false; @@ -153,13 +157,18 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data) return true; case MENU_NAVIGATION_CTL_DESCEND_ALPHABET: { - size_t *ptr_out = (size_t*)data; - size_t i, ptr = *ptr_out; + size_t i = 0, ptr; + size_t *ptr_out = nav ? (size_t*)&nav->selection_ptr : NULL; - if (!nav || !nav->scroll.indices.size || ptr == 0 || !ptr_out) + if (!nav || !nav->scroll.indices.size || !ptr_out) return false; - i = nav->scroll.indices.size - 1; + ptr = *ptr_out; + + if (ptr == 0) + return false; + + i = nav->scroll.indices.size - 1; while (i && nav->scroll.indices.list[i - 1] >= ptr) i--;