Make detection winow for double clicks smaller
This commit is contained in:
@@ -270,6 +270,12 @@ void ButtonNavigator::onListNav(const Buttons& buttons, const bool forward, int&
|
|||||||
return;
|
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 bool wasReleased = std::any_of(buttons.begin(), buttons.end(),
|
||||||
[](const MappedInputManager::Button b) { return mappedInput->wasReleased(b); });
|
[](const MappedInputManager::Button b) { return mappedInput->wasReleased(b); });
|
||||||
if (!wasReleased) return;
|
if (!wasReleased) return;
|
||||||
@@ -283,7 +289,6 @@ void ButtonNavigator::onListNav(const Buttons& buttons, const bool forward, int&
|
|||||||
|
|
||||||
const uint32_t now = millis();
|
const uint32_t now = millis();
|
||||||
const bool isDouble = (now - lastPressMs) < listDoubleClickMs;
|
const bool isDouble = (now - lastPressMs) < listDoubleClickMs;
|
||||||
lastPressMs = now;
|
|
||||||
|
|
||||||
if (isDouble) {
|
if (isDouble) {
|
||||||
// Restore to position before the first press so the total movement is exactly listJumpCount.
|
// Restore to position before the first press so the total movement is exactly listJumpCount.
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class ButtonNavigator final {
|
|||||||
bool longPressPreviousFired = false;
|
bool longPressPreviousFired = false;
|
||||||
int indexBeforePress = 0;
|
int indexBeforePress = 0;
|
||||||
|
|
||||||
static constexpr uint16_t listDoubleClickMs = 350;
|
static constexpr uint16_t listDoubleClickMs = 200;
|
||||||
static constexpr uint32_t listLongPressMs = 1500;
|
static constexpr uint32_t listLongPressMs = 1500;
|
||||||
static constexpr int listJumpCount = 10;
|
static constexpr int listJumpCount = 10;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user