mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-03 20:30:43 +00:00
Add long press repeat interval.
This commit is contained in:
parent
2fcb08a20a
commit
af91b78721
@ -73,12 +73,17 @@ int32_t TrackballInterruptBase::runOnce()
|
||||
// Reset state
|
||||
pressDetected = false;
|
||||
pressStartTime = 0;
|
||||
lastLongPressEventTime = 0;
|
||||
this->action = TB_ACTION_NONE;
|
||||
} else if (pressDuration >= LONG_PRESS_DURATION) {
|
||||
// Long press detected
|
||||
uint32_t currentTime = millis();
|
||||
// Only trigger long press event if enough time has passed since the last one
|
||||
if (lastLongPressEventTime == 0 || (currentTime - lastLongPressEventTime) >= LONG_PRESS_REPEAT_INTERVAL) {
|
||||
e.inputEvent = this->_eventPressedLong;
|
||||
lastLongPressEventTime = currentTime;
|
||||
}
|
||||
this->action = TB_ACTION_PRESSED_LONG;
|
||||
// Keep pressDetected true to avoid repeated long press events
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,9 @@ class TrackballInterruptBase : public Observable<const InputEvent *>, public con
|
||||
// Long press detection for press button
|
||||
uint32_t pressStartTime = 0;
|
||||
bool pressDetected = false;
|
||||
uint32_t lastLongPressEventTime = 0;
|
||||
static const uint32_t LONG_PRESS_DURATION = 500; // ms
|
||||
static const uint32_t LONG_PRESS_REPEAT_INTERVAL = 500; // ms - interval between repeated long press events
|
||||
|
||||
private:
|
||||
input_broker_event _eventDown = INPUT_BROKER_NONE;
|
||||
|
Loading…
Reference in New Issue
Block a user