add circular navigation logic
This commit is contained in:
parent
d69671e3bd
commit
fb97298cad
|
@ -312,11 +312,15 @@ app_err_t dialog_confirm_text_based(const uint8_t* data, size_t len, eip712_doma
|
|||
case KEYPAD_KEY_LEFT:
|
||||
if (page > 0) {
|
||||
page--;
|
||||
} else {
|
||||
page = last_page;
|
||||
}
|
||||
break;
|
||||
case KEYPAD_KEY_RIGHT:
|
||||
if (page < last_page) {
|
||||
page++;
|
||||
} else {
|
||||
page = 0;
|
||||
}
|
||||
break;
|
||||
case KEYPAD_KEY_CANCEL:
|
||||
|
|
|
@ -267,6 +267,8 @@ static char input_keyboard(int *idx, bool show_space) {
|
|||
*idx -= KEYBOARD_ROW2_LEN;
|
||||
} else if (*idx >= KEYBOARD_ROW1_LIMIT) {
|
||||
*idx -= KEYBOARD_ROW1_LEN;
|
||||
} else {
|
||||
*idx = APP_MIN(*idx + KEYBOARD_ROW2_LIMIT, (KEYBOARD_ROW3_LIMIT(show_space) - 1));
|
||||
}
|
||||
break;
|
||||
case KEYPAD_KEY_LEFT:
|
||||
|
@ -274,6 +276,14 @@ static char input_keyboard(int *idx, bool show_space) {
|
|||
((*idx > KEYBOARD_ROW1_LIMIT) && (*idx < KEYBOARD_ROW2_LIMIT)) ||
|
||||
((*idx > 0) && (*idx < KEYBOARD_ROW1_LIMIT))) {
|
||||
(*idx)--;
|
||||
} else {
|
||||
if (*idx == 0) {
|
||||
*idx = KEYBOARD_ROW1_LIMIT - 1;
|
||||
} else if (*idx == KEYBOARD_ROW1_LIMIT) {
|
||||
*idx = KEYBOARD_ROW2_LIMIT - 1;
|
||||
} else {
|
||||
*idx = KEYBOARD_ROW3_LIMIT(show_space) - 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KEYPAD_KEY_RIGHT:
|
||||
|
@ -281,6 +291,14 @@ static char input_keyboard(int *idx, bool show_space) {
|
|||
((*idx < (KEYBOARD_ROW2_LIMIT - 1)) && (*idx >= KEYBOARD_ROW1_LIMIT)) ||
|
||||
((*idx < (KEYBOARD_ROW3_LIMIT(show_space) - 1)) && (*idx >= KEYBOARD_ROW2_LIMIT))) {
|
||||
(*idx)++;
|
||||
} else {
|
||||
if (*idx == KEYBOARD_ROW1_LIMIT - 1) {
|
||||
*idx = 0;
|
||||
} else if (*idx == KEYBOARD_ROW2_LIMIT - 1) {
|
||||
*idx = KEYBOARD_ROW1_LIMIT;
|
||||
} else {
|
||||
*idx = KEYBOARD_ROW2_LIMIT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KEYPAD_KEY_DOWN:
|
||||
|
@ -288,6 +306,8 @@ static char input_keyboard(int *idx, bool show_space) {
|
|||
*idx = APP_MIN(*idx + KEYBOARD_ROW1_LEN, (KEYBOARD_ROW2_LIMIT - 1));
|
||||
} else if (*idx < KEYBOARD_ROW2_LIMIT) {
|
||||
*idx = APP_MIN(*idx + KEYBOARD_ROW2_LEN, (KEYBOARD_ROW3_LIMIT(show_space) - 1));
|
||||
} else {
|
||||
*idx -= KEYBOARD_ROW2_LIMIT;
|
||||
}
|
||||
break;
|
||||
case KEYPAD_KEY_BACK:
|
||||
|
|
|
@ -200,12 +200,18 @@ app_err_t menu_run() {
|
|||
if (selected[depth] > 0) {
|
||||
selected[depth]--;
|
||||
draw = MENU_NEXT;
|
||||
} else {
|
||||
selected[depth] = menu->len - 1;
|
||||
draw = MENU_ALL;
|
||||
}
|
||||
break;
|
||||
case KEYPAD_KEY_DOWN:
|
||||
if (selected[depth] < (menu->len - 1)) {
|
||||
selected[depth]++;
|
||||
draw = MENU_PREV;
|
||||
} else {
|
||||
selected[depth] = 0;
|
||||
draw = MENU_ALL;
|
||||
}
|
||||
break;
|
||||
case KEYPAD_KEY_CONFIRM:
|
||||
|
|
Loading…
Reference in New Issue