add circular navigation logic

This commit is contained in:
Michele Balistreri 2024-04-26 09:28:26 +02:00
parent d69671e3bd
commit fb97298cad
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
3 changed files with 30 additions and 0 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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: