- } 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));
+
+ badge_menu_show(lines, n, &first_visible, first_visible + (first_visible + 1 == n ? 0 : 1), ' ');
+
+ scroll_ticks = MENU_SCROLL_TICKS;
+ }
+
+ badge_event_t ev;
+
+ ev = badge_event_wait();
+ switch(badge_event_type(ev)) {
+ case BADGE_EVENT_USER_INPUT:
+ {
+ uint8_t old_state = badge_event_old_input_state(ev);
+ uint8_t new_state = badge_event_new_input_state(ev);
+ uint8_t new_buttons = new_state & (old_state ^ new_state);
+
+ if(new_buttons & (BADGE_EVENT_KEY_BTN_A | BADGE_EVENT_KEY_BTN_B)) {
+ return;
+ } else if((new_buttons & BADGE_EVENT_KEY_UP )) {
+ scroll_direction = -1;
+ } else if((new_buttons & BADGE_EVENT_KEY_DOWN)) {
+ scroll_direction = 1;
+ } else {
+ scroll_direction = 0;