fix(eink): queue input so a burst of taps survives a blocking refresh

The joystick directions and Back were never begin()'d, so on the e-ink build
they never claimed a GPIOTE channel — edges landing during a blocking panel
refresh were lost and the IRQ-capture work didn't reach them. begin() them.

Even with edges captured, rapid taps of one direction replayed into a single
check() and collapsed into a double/triple-click event the navigation handler
ignores, and the loop only ever dispatched one key per render. So:

- MomentaryButton: for multiclick=false buttons emit one CLICK per completed
  release (one per check() call) instead of collapsing — each tap stays a
  discrete key. multiclick=true buttons (double/triple) are unchanged.
- UITask: add a key FIFO; drain each direction fully into it, apply the whole
  queued burst, then redraw once. N taps captured during a refresh become N
  navigation steps at the cost of a single refresh. Also fixes losing a key
  when two buttons fire in the same loop iteration.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
MarekZegare4
2026-06-30 22:10:18 +02:00
parent 57ebd80fa7
commit 8c70acc3ef
3 changed files with 91 additions and 37 deletions

View File

@@ -202,7 +202,22 @@ int MomentaryButton::check(bool repeat_click) {
}
}
if (_pending_click && (millis() - _last_click_time) >= _multi_click_window) {
if (_multi_click_window == 0) {
// No multi-click semantics: every completed press is an independent CLICK.
// When a burst of taps is captured during a blocking refresh (e-ink), all
// their edges replay into _click_count in a single check(); emit them one
// CLICK per call (decrementing) instead of collapsing into a lone
// double/triple event the caller would ignore — so each tap survives as a
// discrete key. Waits for release (down_at == 0) so a held button doesn't
// fire mid-press.
if (_pending_click && down_at == 0) {
event = BUTTON_EVENT_CLICK;
if (--_click_count == 0) {
_last_click_time = 0;
_pending_click = false;
}
}
} else if (_pending_click && (millis() - _last_click_time) >= _multi_click_window) {
if (down_at > 0) {
// still pressed - wait for button release before processing clicks
return event;