Instead of releasing immediately, delay it until loop()

When releasing immediately, other keys that may affect us (such as Shift) may
not be handled yet. So lets wait with the release until the next loop.

Addresses #6, at least partially.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/389/head
Gergely Nagy 8 years ago
parent 51f0e4bcd6
commit f184177ec3

@ -27,6 +27,7 @@ namespace KaleidoscopePlugins {
uint8_t TapDance::tapCount[16]; uint8_t TapDance::tapCount[16];
uint16_t TapDance::pressedState; uint16_t TapDance::pressedState;
uint16_t TapDance::triggeredState; uint16_t TapDance::triggeredState;
uint16_t TapDance::releaseNextState;
Key TapDance::lastTapDanceKey; Key TapDance::lastTapDanceKey;
byte TapDance::lastTapDanceRow; byte TapDance::lastTapDanceRow;
byte TapDance::lastTapDanceCol; byte TapDance::lastTapDanceCol;
@ -72,14 +73,12 @@ namespace KaleidoscopePlugins {
Key Key
TapDance::release (uint8_t tapDanceIndex) { TapDance::release (uint8_t tapDanceIndex) {
tapDanceAction (tapDanceIndex, lastTapDanceRow, lastTapDanceCol, tapCount[tapDanceIndex], Release);
endTime = 0; endTime = 0;
tapCount[tapDanceIndex] = 0;
lastTapDanceKey.raw = Key_NoKey.raw; lastTapDanceKey.raw = Key_NoKey.raw;
bitClear (pressedState, tapDanceIndex); bitClear (pressedState, tapDanceIndex);
bitClear (triggeredState, tapDanceIndex); bitClear (triggeredState, tapDanceIndex);
bitWrite (releaseNextState, tapDanceIndex, 1);
return Key_NoKey; return Key_NoKey;
} }
@ -208,6 +207,15 @@ namespace KaleidoscopePlugins {
if (!postClear) if (!postClear)
return; return;
for (uint8_t i = 0; i < 16; i++) {
if (!bitRead (releaseNextState, i))
continue;
tapDanceAction (i, lastTapDanceRow, lastTapDanceCol, tapCount[i], Release);
tapCount[i] = 0;
bitClear (releaseNextState, i);
}
if (!isActive ()) if (!isActive ())
return; return;

@ -52,6 +52,7 @@ namespace KaleidoscopePlugins {
static uint8_t tapCount[16]; static uint8_t tapCount[16];
static uint16_t pressedState; static uint16_t pressedState;
static uint16_t triggeredState; static uint16_t triggeredState;
static uint16_t releaseNextState;
static Key lastTapDanceKey; static Key lastTapDanceKey;
static byte lastTapDanceRow; static byte lastTapDanceRow;
static byte lastTapDanceCol; static byte lastTapDanceCol;

Loading…
Cancel
Save