|
|
@ -21,28 +21,28 @@
|
|
|
|
using namespace KaleidoscopePlugins::Ranges;
|
|
|
|
using namespace KaleidoscopePlugins::Ranges;
|
|
|
|
|
|
|
|
|
|
|
|
namespace KaleidoscopePlugins {
|
|
|
|
namespace KaleidoscopePlugins {
|
|
|
|
// --- state ---
|
|
|
|
// --- state ---
|
|
|
|
uint32_t TapDance::endTime;
|
|
|
|
uint32_t TapDance::endTime;
|
|
|
|
uint16_t TapDance::timeOut = 200;
|
|
|
|
uint16_t TapDance::timeOut = 200;
|
|
|
|
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;
|
|
|
|
uint16_t TapDance::releaseNextState;
|
|
|
|
Key TapDance::lastTapDanceKey;
|
|
|
|
Key TapDance::lastTapDanceKey;
|
|
|
|
byte TapDance::lastTapDanceRow;
|
|
|
|
byte TapDance::lastTapDanceRow;
|
|
|
|
byte TapDance::lastTapDanceCol;
|
|
|
|
byte TapDance::lastTapDanceCol;
|
|
|
|
|
|
|
|
|
|
|
|
// --- helpers ---
|
|
|
|
// --- helpers ---
|
|
|
|
|
|
|
|
|
|
|
|
#define isTapDance(k) (k.raw >= TD_FIRST && k.raw <= TD_LAST)
|
|
|
|
#define isTapDance(k) (k.raw >= TD_FIRST && k.raw <= TD_LAST)
|
|
|
|
#define isInSeq(k) (lastTapDanceKey.raw == k.raw)
|
|
|
|
#define isInSeq(k) (lastTapDanceKey.raw == k.raw)
|
|
|
|
#define stillHeld(idx) (tapCount[idx])
|
|
|
|
#define stillHeld(idx) (tapCount[idx])
|
|
|
|
#define isActive() (lastTapDanceKey.raw != Key_NoKey.raw)
|
|
|
|
#define isActive() (lastTapDanceKey.raw != Key_NoKey.raw)
|
|
|
|
|
|
|
|
|
|
|
|
// --- actions ---
|
|
|
|
// --- actions ---
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
TapDance::interrupt (void) {
|
|
|
|
TapDance::interrupt (void) {
|
|
|
|
uint8_t idx = lastTapDanceKey.raw - TD_FIRST;
|
|
|
|
uint8_t idx = lastTapDanceKey.raw - TD_FIRST;
|
|
|
|
|
|
|
|
|
|
|
|
tapDanceAction (idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Interrupt);
|
|
|
|
tapDanceAction (idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Interrupt);
|
|
|
@ -54,10 +54,10 @@ namespace KaleidoscopePlugins {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
release (idx);
|
|
|
|
release (idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
TapDance::timeout (void) {
|
|
|
|
TapDance::timeout (void) {
|
|
|
|
uint8_t idx = lastTapDanceKey.raw - TD_FIRST;
|
|
|
|
uint8_t idx = lastTapDanceKey.raw - TD_FIRST;
|
|
|
|
|
|
|
|
|
|
|
|
tapDanceAction (idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Timeout);
|
|
|
|
tapDanceAction (idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Timeout);
|
|
|
@ -69,10 +69,10 @@ namespace KaleidoscopePlugins {
|
|
|
|
lastTapDanceKey.raw = Key_NoKey.raw;
|
|
|
|
lastTapDanceKey.raw = Key_NoKey.raw;
|
|
|
|
|
|
|
|
|
|
|
|
release (idx);
|
|
|
|
release (idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Key
|
|
|
|
Key
|
|
|
|
TapDance::release (uint8_t tapDanceIndex) {
|
|
|
|
TapDance::release (uint8_t tapDanceIndex) {
|
|
|
|
endTime = 0;
|
|
|
|
endTime = 0;
|
|
|
|
lastTapDanceKey.raw = Key_NoKey.raw;
|
|
|
|
lastTapDanceKey.raw = Key_NoKey.raw;
|
|
|
|
|
|
|
|
|
|
|
@ -80,10 +80,10 @@ namespace KaleidoscopePlugins {
|
|
|
|
bitClear (triggeredState, tapDanceIndex);
|
|
|
|
bitClear (triggeredState, tapDanceIndex);
|
|
|
|
bitWrite (releaseNextState, tapDanceIndex, 1);
|
|
|
|
bitWrite (releaseNextState, tapDanceIndex, 1);
|
|
|
|
return Key_NoKey;
|
|
|
|
return Key_NoKey;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Key
|
|
|
|
Key
|
|
|
|
TapDance::tap (void) {
|
|
|
|
TapDance::tap (void) {
|
|
|
|
uint8_t idx = lastTapDanceKey.raw - TD_FIRST;
|
|
|
|
uint8_t idx = lastTapDanceKey.raw - TD_FIRST;
|
|
|
|
|
|
|
|
|
|
|
|
tapCount[idx]++;
|
|
|
|
tapCount[idx]++;
|
|
|
@ -92,22 +92,22 @@ namespace KaleidoscopePlugins {
|
|
|
|
tapDanceAction (idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Tap);
|
|
|
|
tapDanceAction (idx, lastTapDanceRow, lastTapDanceCol, tapCount[idx], Tap);
|
|
|
|
|
|
|
|
|
|
|
|
return Key_NoKey;
|
|
|
|
return Key_NoKey;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --- api ---
|
|
|
|
// --- api ---
|
|
|
|
|
|
|
|
|
|
|
|
TapDance::TapDance (void) {
|
|
|
|
TapDance::TapDance (void) {
|
|
|
|
lastTapDanceKey.raw = Key_NoKey.raw;
|
|
|
|
lastTapDanceKey.raw = Key_NoKey.raw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
TapDance::begin (void) {
|
|
|
|
TapDance::begin (void) {
|
|
|
|
event_handler_hook_use (this->eventHandlerHook);
|
|
|
|
event_handler_hook_use (this->eventHandlerHook);
|
|
|
|
loop_hook_use (this->loopHook);
|
|
|
|
loop_hook_use (this->loopHook);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
TapDance::actionKeys (uint8_t tapCount, ActionType tapDanceAction, uint8_t maxKeys, const Key tapKeys[]) {
|
|
|
|
TapDance::actionKeys (uint8_t tapCount, ActionType tapDanceAction, uint8_t maxKeys, const Key tapKeys[]) {
|
|
|
|
if (tapCount > maxKeys)
|
|
|
|
if (tapCount > maxKeys)
|
|
|
|
tapCount = maxKeys;
|
|
|
|
tapCount = maxKeys;
|
|
|
|
|
|
|
|
|
|
|
@ -129,12 +129,12 @@ namespace KaleidoscopePlugins {
|
|
|
|
handle_keyswitch_event (key, lastTapDanceRow, lastTapDanceCol, WAS_PRESSED | INJECTED);
|
|
|
|
handle_keyswitch_event (key, lastTapDanceRow, lastTapDanceCol, WAS_PRESSED | INJECTED);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --- hooks ---
|
|
|
|
// --- hooks ---
|
|
|
|
|
|
|
|
|
|
|
|
Key
|
|
|
|
Key
|
|
|
|
TapDance::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
TapDance::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
if (keyState & INJECTED)
|
|
|
|
if (keyState & INJECTED)
|
|
|
|
return mappedKey;
|
|
|
|
return mappedKey;
|
|
|
|
|
|
|
|
|
|
|
@ -200,10 +200,10 @@ namespace KaleidoscopePlugins {
|
|
|
|
tapDanceAction (tapDanceIndex, row, col, tapCount[tapDanceIndex], Hold);
|
|
|
|
tapDanceAction (tapDanceIndex, row, col, tapCount[tapDanceIndex], Hold);
|
|
|
|
|
|
|
|
|
|
|
|
return Key_NoKey;
|
|
|
|
return Key_NoKey;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
TapDance::loopHook (bool postClear) {
|
|
|
|
TapDance::loopHook (bool postClear) {
|
|
|
|
if (!postClear)
|
|
|
|
if (!postClear)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
@ -221,7 +221,7 @@ namespace KaleidoscopePlugins {
|
|
|
|
|
|
|
|
|
|
|
|
if (endTime && millis () > endTime)
|
|
|
|
if (endTime && millis () > endTime)
|
|
|
|
timeout();
|
|
|
|
timeout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
__attribute__((weak))
|
|
|
|
__attribute__((weak))
|
|
|
|