X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/c63dbfcb347e10f9406053545eaf44dd4d9d9bdb..637dcc82c8595130b3627c526126946b43c0707a:/badge/ui/menu.c diff --git a/badge/ui/menu.c b/badge/ui/menu.c index e4eaac7..0627a10 100644 --- a/badge/ui/menu.c +++ b/badge/ui/menu.c @@ -65,12 +65,12 @@ static void badge_menu_show(char const *const *menu, } size_t badge_menu(char const *const *menu, - size_t n, - size_t first_visible, - size_t selected) + size_t n, + size_t *first_visible, + size_t selected) { for(;;) { - badge_menu_show(menu, n, first_visible, selected); + badge_menu_show(menu, n, *first_visible, selected); badge_event_t ev; @@ -86,13 +86,13 @@ size_t badge_menu(char const *const *menu, return selected; } else if((new_buttons & BADGE_EVENT_KEY_UP ) && selected != 0) { --selected; - if(first_visible != 0 && selected <= first_visible) { - first_visible = selected - 1; + if(*first_visible != 0 && selected <= *first_visible) { + *first_visible = selected - 1; } } else if(new_buttons & BADGE_EVENT_KEY_DOWN && selected + 1 < n) { ++selected; - if(first_visible + (MENU_ENTRIES_VISIBLE - 2 + (selected + 1 == n)) < selected) { - first_visible = selected - (MENU_ENTRIES_VISIBLE - 2 + (selected + 1 == n)); + if(*first_visible + (MENU_ENTRIES_VISIBLE - 2 + (selected + 1 == n)) < selected) { + *first_visible = selected - (MENU_ENTRIES_VISIBLE - 2 + (selected + 1 == n)); } } }