diff --git a/src/Kaleidoscope/Leader.cpp b/src/Kaleidoscope/Leader.cpp index 0adcb044..2bb8e704 100644 --- a/src/Kaleidoscope/Leader.cpp +++ b/src/Kaleidoscope/Leader.cpp @@ -24,7 +24,7 @@ namespace KaleidoscopePlugins { // --- state --- Key Leader::sequence[LEADER_MAX_SEQUENCE_LENGTH + 1]; uint8_t Leader::sequencePos; - uint32_t Leader::startTime; + uint32_t Leader::endTime; uint16_t Leader::timeOut = 1000; const Leader::dictionary_t *Leader::dictionary; @@ -89,7 +89,6 @@ namespace KaleidoscopePlugins { void Leader::reset (void) { - startTime = 0; sequencePos = 0; sequence[0].raw = Key_NoKey.raw; } @@ -119,7 +118,7 @@ namespace KaleidoscopePlugins { if (key_toggled_off (keyState)) { // not active, but a leader key = start the sequence on key release! - startTime = millis (); + endTime = millis () + timeOut; sequencePos = 0; sequence[sequencePos].raw = mappedKey.raw; } @@ -138,7 +137,7 @@ namespace KaleidoscopePlugins { return mappedKey; } - startTime = millis (); + endTime = millis () + timeOut; sequence[sequencePos].raw = mappedKey.raw; actionIndex = lookup (); @@ -170,7 +169,7 @@ namespace KaleidoscopePlugins { if (!isActive ()) return; - if ((millis () - startTime) >= timeOut) + if (millis () >= endTime) reset (); } }; diff --git a/src/Kaleidoscope/Leader.h b/src/Kaleidoscope/Leader.h index e7fce5f2..4b6fdf24 100644 --- a/src/Kaleidoscope/Leader.h +++ b/src/Kaleidoscope/Leader.h @@ -50,7 +50,7 @@ namespace KaleidoscopePlugins { private: static Key sequence[LEADER_MAX_SEQUENCE_LENGTH + 1]; static uint8_t sequencePos; - static uint32_t startTime; + static uint32_t endTime; static const Leader::dictionary_t *dictionary; static Key eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState);