Skip to content

Commit

Permalink
Merge pull request #832 from LedgerHQ/fweo-1254-pinpad-nano
Browse files Browse the repository at this point in the history
FWEO-1254 pinpad nano
  • Loading branch information
jarevalo-ledger authored Dec 10, 2024
2 parents e8f68a6 + 823c5ca commit 751547a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
4 changes: 2 additions & 2 deletions lib_nbgl/src/nbgl_layout_keypad_nanos.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ int nbgl_layoutUpdateKeypad(nbgl_layout_t *layout,
// if validate key is enabled and was not, select it directly
keypad->selectedKey = 11;
}
else {
// otherwise let the draw function pick a new selected
// Shuffle if selected key was not backspace or if the last pin entry has been deleted
else if ((keypad->selectedKey != 0) || (keypad->enableBackspace && !enableBackspace)) {
keypad->selectedKey = 0xFF;
}
keypad->enableValidate = enableValidate;
Expand Down
20 changes: 2 additions & 18 deletions lib_nbgl/src/nbgl_obj_keypad_nanos.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,8 @@ static void keypadInitSelected(nbgl_keypad_t *keypad)
keypad->selectedKey = 1 + INIT_DIGIT_VALUE;
}
else {
uint8_t nbChoices = 10;
uint8_t random;
if (keypad->enableBackspace) {
nbChoices++;
}
if (keypad->enableValidate) {
nbChoices++;
}
random = cx_rng_u32_range(0, nbChoices);
if (random < 10) {
keypad->selectedKey = 1 + random;
}
else if (random == 10) {
keypad->selectedKey = 0;
}
else if (random == 11) {
keypad->selectedKey = 11;
}
// Exclude backspace and validate keys ([0,11]), shuffle only digits
keypad->selectedKey = cx_rng_u32_range(1, 11);
}
}

Expand Down

0 comments on commit 751547a

Please sign in to comment.