UI: fixed issue on callsign's last character editing

When editing the callsign on a device with keypad, when entering the last
character the same key did not rotate through the possible values
This commit is contained in:
Marco 2024-05-28 20:19:51 +02:00 committed by Silvano Seva
parent 3940405c68
commit 65bc773a1f
1 changed files with 7 additions and 3 deletions

View File

@ -1093,11 +1093,12 @@ static void _ui_textInputReset(char *buf)
static void _ui_textInputKeypad(char *buf, uint8_t max_len, kbd_msg_t msg, static void _ui_textInputKeypad(char *buf, uint8_t max_len, kbd_msg_t msg,
bool callsign) bool callsign)
{ {
if(ui_state.input_position >= max_len)
return;
long long now = getTick(); long long now = getTick();
// Get currently pressed number key // Get currently pressed number key
uint8_t num_key = input_getPressedNumber(msg); uint8_t num_key = input_getPressedNumber(msg);
bool key_timeout = ((now - ui_state.last_keypress) >= input_longPressTimeout);
bool same_key = ui_state.input_number == num_key;
// Get number of symbols related to currently pressed key // Get number of symbols related to currently pressed key
uint8_t num_symbols = 0; uint8_t num_symbols = 0;
if(callsign) if(callsign)
@ -1105,11 +1106,14 @@ static void _ui_textInputKeypad(char *buf, uint8_t max_len, kbd_msg_t msg,
else else
num_symbols = strlen(symbols_ITU_T_E161[num_key]); num_symbols = strlen(symbols_ITU_T_E161[num_key]);
if((ui_state.input_position > max_len) || ((ui_state.input_position == max_len) && (key_timeout || !same_key)))
return;
// Skip keypad logic for first keypress // Skip keypad logic for first keypress
if(ui_state.last_keypress != 0) if(ui_state.last_keypress != 0)
{ {
// Same key pressed and timeout not expired: cycle over chars of current key // Same key pressed and timeout not expired: cycle over chars of current key
if((ui_state.input_number == num_key) && ((now - ui_state.last_keypress) < input_longPressTimeout)) if(same_key && !key_timeout)
{ {
ui_state.input_set = (ui_state.input_set + 1) % num_symbols; ui_state.input_set = (ui_state.input_set + 1) % num_symbols;
} }