|
|
@ -22,12 +22,10 @@
|
|
|
|
namespace kaleidoscope {
|
|
|
|
namespace kaleidoscope {
|
|
|
|
namespace plugin {
|
|
|
|
namespace plugin {
|
|
|
|
|
|
|
|
|
|
|
|
const ShapeShifter::dictionary_t *ShapeShifter::dictionary = NULL;
|
|
|
|
const ShapeShifter::dictionary_t *ShapeShifter::dictionary = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
EventHandlerResult ShapeShifter::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state) {
|
|
|
|
EventHandlerResult ShapeShifter::onKeyEvent(KeyEvent &event) {
|
|
|
|
// Only act on keys that toggle on to prevent cycles (if the dictionary has
|
|
|
|
if (dictionary == nullptr)
|
|
|
|
// two keys mapped to each other).
|
|
|
|
|
|
|
|
if (!keyToggledOn(key_state))
|
|
|
|
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
|
|
|
|
|
|
|
|
if (!dictionary)
|
|
|
|
if (!dictionary)
|
|
|
@ -41,7 +39,7 @@ EventHandlerResult ShapeShifter::onKeyswitchEvent(Key &mapped_key, KeyAddr key_a
|
|
|
|
orig = dictionary[i].original.readFromProgmem();
|
|
|
|
orig = dictionary[i].original.readFromProgmem();
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
} while (orig != Key_NoKey &&
|
|
|
|
} while (orig != Key_NoKey &&
|
|
|
|
orig != mapped_key);
|
|
|
|
orig != event.key);
|
|
|
|
i--;
|
|
|
|
i--;
|
|
|
|
|
|
|
|
|
|
|
|
// If not found, bail out.
|
|
|
|
// If not found, bail out.
|
|
|
@ -60,7 +58,7 @@ EventHandlerResult ShapeShifter::onKeyswitchEvent(Key &mapped_key, KeyAddr key_a
|
|
|
|
repl = dictionary[i].replacement.readFromProgmem();
|
|
|
|
repl = dictionary[i].replacement.readFromProgmem();
|
|
|
|
|
|
|
|
|
|
|
|
// If found, handle the alternate key instead
|
|
|
|
// If found, handle the alternate key instead
|
|
|
|
mapped_key = repl;
|
|
|
|
event.key = repl;
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
return EventHandlerResult::OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|