From 577e7154dc362a1d1cde6173ee8c4f2c8d9350f0 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Fri, 15 May 2026 21:08:19 +0200 Subject: [PATCH] Make detection winow for double clicks smaller --- src/util/ButtonNavigator.cpp | 7 ++++++- src/util/ButtonNavigator.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/util/ButtonNavigator.cpp b/src/util/ButtonNavigator.cpp index 28e6eeab..e170c86a 100644 --- a/src/util/ButtonNavigator.cpp +++ b/src/util/ButtonNavigator.cpp @@ -270,6 +270,12 @@ void ButtonNavigator::onListNav(const Buttons& buttons, const bool forward, int& return; } + const bool wasPressed = std::any_of(buttons.begin(), buttons.end(), + [](const MappedInputManager::Button b) { return mappedInput->wasPressed(b); }); + if (wasPressed) { + lastPressMs = millis(); + } + const bool wasReleased = std::any_of(buttons.begin(), buttons.end(), [](const MappedInputManager::Button b) { return mappedInput->wasReleased(b); }); if (!wasReleased) return; @@ -283,7 +289,6 @@ void ButtonNavigator::onListNav(const Buttons& buttons, const bool forward, int& const uint32_t now = millis(); const bool isDouble = (now - lastPressMs) < listDoubleClickMs; - lastPressMs = now; if (isDouble) { // Restore to position before the first press so the total movement is exactly listJumpCount. diff --git a/src/util/ButtonNavigator.h b/src/util/ButtonNavigator.h index c47adc25..8c37a96a 100644 --- a/src/util/ButtonNavigator.h +++ b/src/util/ButtonNavigator.h @@ -22,7 +22,7 @@ class ButtonNavigator final { bool longPressPreviousFired = false; int indexBeforePress = 0; - static constexpr uint16_t listDoubleClickMs = 350; + static constexpr uint16_t listDoubleClickMs = 200; static constexpr uint32_t listLongPressMs = 1500; static constexpr int listJumpCount = 10;