|
|
@ -25,21 +25,21 @@ namespace KaleidoscopePlugins {
|
|
|
|
const Key *TopsyTurvy::topsyTurvyList = NULL;
|
|
|
|
const Key *TopsyTurvy::topsyTurvyList = NULL;
|
|
|
|
uint8_t TopsyTurvy::topsyTurvyModState;
|
|
|
|
uint8_t TopsyTurvy::topsyTurvyModState;
|
|
|
|
|
|
|
|
|
|
|
|
TopsyTurvy::TopsyTurvy (void) {
|
|
|
|
TopsyTurvy::TopsyTurvy(void) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
TopsyTurvy::begin (void) {
|
|
|
|
TopsyTurvy::begin(void) {
|
|
|
|
event_handler_hook_use (this->eventHandlerHook);
|
|
|
|
event_handler_hook_use(this->eventHandlerHook);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
TopsyTurvy::configure (const Key list[]) {
|
|
|
|
TopsyTurvy::configure(const Key list[]) {
|
|
|
|
topsyTurvyList = (const Key *)list;
|
|
|
|
topsyTurvyList = (const Key *)list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Key
|
|
|
|
Key
|
|
|
|
TopsyTurvy::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
TopsyTurvy::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyState) {
|
|
|
|
if (keyState & TOPSYTURVY)
|
|
|
|
if (keyState & TOPSYTURVY)
|
|
|
|
return mappedKey;
|
|
|
|
return mappedKey;
|
|
|
|
|
|
|
|
|
|
|
@ -47,18 +47,18 @@ TopsyTurvy::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyStat
|
|
|
|
return mappedKey;
|
|
|
|
return mappedKey;
|
|
|
|
|
|
|
|
|
|
|
|
if (mappedKey.raw == Key_LeftShift.raw)
|
|
|
|
if (mappedKey.raw == Key_LeftShift.raw)
|
|
|
|
bitWrite (topsyTurvyModState, 0, key_is_pressed (keyState));
|
|
|
|
bitWrite(topsyTurvyModState, 0, key_is_pressed(keyState));
|
|
|
|
if (mappedKey.raw == Key_RightShift.raw)
|
|
|
|
if (mappedKey.raw == Key_RightShift.raw)
|
|
|
|
bitWrite (topsyTurvyModState, 1, key_is_pressed (keyState));
|
|
|
|
bitWrite(topsyTurvyModState, 1, key_is_pressed(keyState));
|
|
|
|
|
|
|
|
|
|
|
|
if (!key_is_pressed (keyState) && !key_was_pressed (keyState))
|
|
|
|
if (!key_is_pressed(keyState) && !key_was_pressed(keyState))
|
|
|
|
return mappedKey;
|
|
|
|
return mappedKey;
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t idx = 0;
|
|
|
|
uint8_t idx = 0;
|
|
|
|
Key newKey;
|
|
|
|
Key newKey;
|
|
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
newKey.raw = pgm_read_word (&(topsyTurvyList[idx].raw));
|
|
|
|
newKey.raw = pgm_read_word(&(topsyTurvyList[idx].raw));
|
|
|
|
idx++;
|
|
|
|
idx++;
|
|
|
|
} while (newKey.raw != mappedKey.raw && newKey.raw != Key_NoKey.raw);
|
|
|
|
} while (newKey.raw != mappedKey.raw && newKey.raw != Key_NoKey.raw);
|
|
|
|
|
|
|
|
|
|
|
@ -68,23 +68,23 @@ TopsyTurvy::eventHandlerHook (Key mappedKey, byte row, byte col, uint8_t keyStat
|
|
|
|
// invert the shift state
|
|
|
|
// invert the shift state
|
|
|
|
|
|
|
|
|
|
|
|
if (!topsyTurvyModState) {
|
|
|
|
if (!topsyTurvyModState) {
|
|
|
|
if (key_is_pressed (keyState))
|
|
|
|
if (key_is_pressed(keyState))
|
|
|
|
Keyboard.press (Key_LeftShift.keyCode);
|
|
|
|
Keyboard.press(Key_LeftShift.keyCode);
|
|
|
|
handle_keyswitch_event (mappedKey, row, col, keyState | TOPSYTURVY);
|
|
|
|
handle_keyswitch_event(mappedKey, row, col, keyState | TOPSYTURVY);
|
|
|
|
Keyboard.sendReport ();
|
|
|
|
Keyboard.sendReport();
|
|
|
|
if (key_toggled_off (keyState))
|
|
|
|
if (key_toggled_off(keyState))
|
|
|
|
Keyboard.release (Key_LeftShift.keyCode);
|
|
|
|
Keyboard.release(Key_LeftShift.keyCode);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Keyboard.release (Key_LeftShift.keyCode);
|
|
|
|
Keyboard.release(Key_LeftShift.keyCode);
|
|
|
|
Keyboard.release (Key_RightShift.keyCode);
|
|
|
|
Keyboard.release(Key_RightShift.keyCode);
|
|
|
|
Keyboard.sendReport ();
|
|
|
|
Keyboard.sendReport();
|
|
|
|
handle_keyswitch_event (mappedKey, row, col, keyState | TOPSYTURVY);
|
|
|
|
handle_keyswitch_event(mappedKey, row, col, keyState | TOPSYTURVY);
|
|
|
|
Keyboard.sendReport ();
|
|
|
|
Keyboard.sendReport();
|
|
|
|
|
|
|
|
|
|
|
|
if (bitRead (topsyTurvyModState, 0))
|
|
|
|
if (bitRead(topsyTurvyModState, 0))
|
|
|
|
Keyboard.press (Key_LeftShift.keyCode);
|
|
|
|
Keyboard.press(Key_LeftShift.keyCode);
|
|
|
|
if (bitRead (topsyTurvyModState, 1))
|
|
|
|
if (bitRead(topsyTurvyModState, 1))
|
|
|
|
Keyboard.press (Key_RightShift.keyCode);
|
|
|
|
Keyboard.press(Key_RightShift.keyCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Key_NoKey;
|
|
|
|
return Key_NoKey;
|
|
|
|