Skip to content

Use side buttons to confirm dice rolls - #1078

Open
AdamFerguson wants to merge 1 commit into
SeedSigner:devfrom
AdamFerguson:dice-anyclick-confirm
Open

AdamFerguson wants to merge 1 commit into
SeedSigner:devfrom
AdamFerguson:dice-anyclick-confirm

Conversation

@AdamFerguson

Copy link
Copy Markdown

Description

Problem or Issue being addressed

The dice-entry screen used the joystick for both navigation and confirmation: the joystick center press was the only way to lock in the highlighted die. During a long entry sequence an accidental center press while moving between dice is recorded immediately as an extra roll, and the resulting duplicate digit is easy to miss in the compact roll history. #988 hit this while entering a 99-roll sequence across multiple devices and had to restart.

Solution

  • KeyboardScreen gains a key_confirm_inputs field that defines which hardware inputs lock in the highlighted key. The default stays [KEY_PRESS], so every other keyboard screen (passphrase, seed words, BIP85 child index, custom derivation path, coin flip) behaves exactly as before.
  • Only ToolsDiceEntropyEntryScreen opts in to HardwareButtonsConstants.KEYS__ANYCLICK — the joystick center press plus KEY1, KEY2 and KEY3.
  • No UI changes: the dice grid, the roll history field and the soft-button area are untouched.

This implements the approach kdmukai preferred in #988 (comment) — "Just enable ANYCLICK handling for this screen ... but make no UI changes" — rather than the green check button from #988, which reads as "I'm done" everywhere else in the keyboard UI (see #988 (comment)). KEYS__ANYCLICK is already how ButtonListScreen treats any click as "select", so the dice screen now matches the rest of the UI.

Additional Information

Tested hands-on on SeedSigner OS on a Pi Zero 1.3, using a pi0 image built from this branch: each side button records exactly one roll (middle button included), joystick navigation still moves the selection, and passphrase/seed-word entry still saves with KEY3.

Tests: pytest tests/test_keyboard_screen.py -> 9 passed. Covers all four confirmation inputs, the unchanged default for other keyboard screens, top-nav back navigation, backspace and the KEY3 save button. The full flow suite was not run locally (no zbar shared library on the authoring machine).

One deliberate difference from #988: KEYS__ANYCLICK includes KEY_PRESS, so an accidental joystick center press still records a die. schjonhaug argued for strict separation so the joystick press can never alter entropy (#988 (comment)). If you'd prefer that, it is a one-line change: set key_confirm_inputs to [KEY1, KEY2, KEY3] on the dice screen.


This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Documentation
  • Other

Checklist

I ran pytest locally

  • All tests passed before submitting the PR
  • I couldn't run the tests
  • N/A

I included screenshots of any new or modified screens

No UI changes, so there is nothing new to screenshot.

  • Yes
  • No
  • N/A

I added or updated tests

Any new or altered functionality should be covered in a unit test. Any new or updated sequences require FlowTests.

  • Yes
  • No, I'm a fool
  • N/A

I tested this PR hands-on on the following platform(s):


I have reviewed these notes:

  • Keep your changes limited in scope.
  • If you uncover other issues or improvements along the way, ideally submit those as a separate PR.
  • The more complicated the PR, the harder it is to review, test, and merge.
  • We appreciate your efforts, but we're a small team of volunteers so PR review can be a very slow process.
  • Please only "@" mention a contributor if their input is truly needed to enable further progress.
  • I understand

Thank you! Please join our Devs' Telegram group to get more involved.

The dice-entry screen only accepted the joystick center press to lock in the
highlighted die, so an accidental joystick click while navigating silently
recorded an extra roll and corrupted the entropy sequence.

KeyboardScreen now takes a `key_confirm_inputs` list that defines which
hardware inputs lock in the highlighted key. The default is unchanged (joystick
center press only), so every other keyboard screen behaves exactly as before.

ToolsDiceEntropyEntryScreen opts in to `KEYS__ANYCLICK`, i.e. the joystick
center press plus KEY1, KEY2 and KEY3, matching how the ButtonListScreens
already accept any click to select an entry. No UI changes.

Adds tests/test_keyboard_screen.py covering all four confirmation inputs, the
unchanged default, top-nav back navigation, backspace, and the KEY3 save button.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant