feat(ui): UI_ENTER_DOUBLE_BACK - double-click Enter goes back, off by default

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
MarekZegare4
2026-10-19 12:58:04 +02:00
co-authored by Claude Sonnet 5.5
parent 5bee64ef3b
commit e2c50062b6
3 changed files with 26 additions and 3 deletions
+20 -2
View File
@@ -1261,8 +1261,7 @@ void UITask::loop() {
#if FEAT_DISPLAY_ROTATION_SETTING && defined(JOYSTICK_UPRIGHT_ROTATION)
if (_node_prefs) joy_rot += (JOYSTICK_UPRIGHT_ROTATION - _node_prefs->display_rotation) & 3;
#endif
int ev = user_btn.check();
if (ev == BUTTON_EVENT_CLICK) {
auto enterClick = [&]() {
if (back_btn.isPressed() && !_unlock_kb) {
// Enter clicked while Back is held — lock/unlock sequence
if (_display && !_display->isOn()) {
@@ -1287,6 +1286,25 @@ void UITask::loop() {
}
enqueueKey(checkDisplayOn(KEY_ENTER));
}
};
int ev = user_btn.check();
#ifdef UI_ENTER_DOUBLE_BACK
// For a joystick without a reachable Back button: a double click on Enter goes
// back. Multi-click delays a single Enter by the click window. Where text is
// typed (on-screen keyboard, PIN pad) or the lock sequence is counting, a
// double is just two Enters, so a repeated letter still works.
if (ev == BUTTON_EVENT_DOUBLE_CLICK || ev == BUTTON_EVENT_TRIPLE_CLICK) {
int n = (ev == BUTTON_EVENT_DOUBLE_CLICK) ? 2 : 3;
if (_unlock_kb || _kb.isVisible() || back_btn.isPressed()) {
for (int i = 0; i < n; i++) enterClick();
} else {
enqueueKey(checkDisplayOn(KEY_CANCEL));
}
ev = BUTTON_EVENT_NONE;
}
#endif
if (ev == BUTTON_EVENT_CLICK) {
enterClick();
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
enqueueKey(handleLongPress(KEY_ENTER)); // REVISIT: could be mapped to different key code
}