When interrupting a tap-dance sequence, make sure no extras are sent

When interrupting, we send a report, release all keys, and mask the interrupting
key to avoid issues like sending too many of the interrupting keys. Later on, we
unmask the interrupting key if it has been masked.

This fixes #9, but requires the masking patches to be merged first.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/389/head
Gergely Nagy 7 years ago
parent 64f9fe2a53
commit a31d686911

@ -41,7 +41,7 @@ byte TapDance::last_tap_dance_col_;
// --- actions ---
void TapDance::interrupt(void) {
void TapDance::interrupt(byte row, byte col) {
uint8_t idx = last_tap_dance_key_.raw - ranges::TD_FIRST;
tapDanceAction(idx, last_tap_dance_row_, last_tap_dance_col_, tap_count_[idx], Interrupt);
@ -49,6 +49,10 @@ void TapDance::interrupt(void) {
end_time_ = 0;
KeyboardHardware.maskKey(row, col);
kaleidoscope::hid::sendKeyboardReport();
kaleidoscope::hid::releaseAllKeys();
if (bitRead(pressed_state_, idx))
return;
@ -133,6 +137,7 @@ Key TapDance::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_s
if (!keyIsPressed(key_state) && !keyWasPressed(key_state)) {
if (isTapDance(mapped_key))
return Key_NoKey;
return mapped_key;
}
@ -141,8 +146,12 @@ Key TapDance::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_s
return mapped_key;
if (keyToggledOn(key_state))
interrupt();
interrupt(row, col);
if (KeyboardHardware.isKeyMasked(row, col)) {
KeyboardHardware.unMaskKey(row, col);
return Key_NoKey;
}
return mapped_key;
}
@ -171,7 +180,7 @@ Key TapDance::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_s
if (!keyToggledOn(key_state))
return Key_NoKey;
interrupt();
interrupt(row, col);
}
}

@ -61,7 +61,7 @@ class TapDance : public KaleidoscopePlugin {
static void loopHook(bool is_post_clear);
static Key tap(void);
static void interrupt(void);
static void interrupt(byte row, byte col);
static void timeout(void);
static Key release(uint8_t tap_dance_index);
};

Loading…
Cancel
Save