Use standard timeout checker for SpaceCadet

Also, change timestamp from four bytes to two.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/642/head
Michael Richters 6 years ago
parent 0b0e061563
commit afcbb83bae

@ -119,7 +119,7 @@ EventHandlerResult SpaceCadet::onKeyswitchEvent(Key &mapped_key, byte row, byte
if (mapped_key.raw == map[i].input.raw) {
//The keypress was valid and a match. Mark it as flagged and reset the counter
map[i].flagged = true;
map[i].start_time = millis();
map[i].start_time = Kaleidoscope.millisAtCycleStart();
//yes, we found a valid key
valid_key = true;
@ -199,7 +199,7 @@ EventHandlerResult SpaceCadet::onKeyswitchEvent(Key &mapped_key, byte row, byte
}
//Check to determine if we have surpassed our timeout for holding this key
if ((millis() - map[index].start_time) >= current_timeout) {
if (Kaleidoscope.hasTimeExpired(map[index].start_time, current_timeout)) {
// if we timed out, that means we need to keep pressing the mapped
// key, but we won't need to send the alternative key in the end
map[index].flagged = false;

@ -52,7 +52,7 @@ class SpaceCadet : public kaleidoscope::Plugin {
//The flag (set to 0)
bool flagged = false;
//the start time for this key press
uint32_t start_time = 0;
uint16_t start_time = 0;
};
SpaceCadet(void);

Loading…
Cancel
Save