From abba88125720ff1b4d0600ad303e95dff32e303f Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 6 Apr 2021 18:48:17 -0500 Subject: [PATCH] Adapt ShapeShifter plugin to KeyEvent handlers Signed-off-by: Michael Richters --- .../src/kaleidoscope/plugin/ShapeShifter.cpp | 12 +++++------- .../src/kaleidoscope/plugin/ShapeShifter.h | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/plugins/Kaleidoscope-ShapeShifter/src/kaleidoscope/plugin/ShapeShifter.cpp b/plugins/Kaleidoscope-ShapeShifter/src/kaleidoscope/plugin/ShapeShifter.cpp index 3692c8c3..0890fc0e 100644 --- a/plugins/Kaleidoscope-ShapeShifter/src/kaleidoscope/plugin/ShapeShifter.cpp +++ b/plugins/Kaleidoscope-ShapeShifter/src/kaleidoscope/plugin/ShapeShifter.cpp @@ -22,12 +22,10 @@ namespace kaleidoscope { 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) { - // Only act on keys that toggle on to prevent cycles (if the dictionary has - // two keys mapped to each other). - if (!keyToggledOn(key_state)) +EventHandlerResult ShapeShifter::onKeyEvent(KeyEvent &event) { + if (dictionary == nullptr) return EventHandlerResult::OK; if (!dictionary) @@ -41,7 +39,7 @@ EventHandlerResult ShapeShifter::onKeyswitchEvent(Key &mapped_key, KeyAddr key_a orig = dictionary[i].original.readFromProgmem(); i++; } while (orig != Key_NoKey && - orig != mapped_key); + orig != event.key); i--; // If not found, bail out. @@ -60,7 +58,7 @@ EventHandlerResult ShapeShifter::onKeyswitchEvent(Key &mapped_key, KeyAddr key_a repl = dictionary[i].replacement.readFromProgmem(); // If found, handle the alternate key instead - mapped_key = repl; + event.key = repl; return EventHandlerResult::OK; } diff --git a/plugins/Kaleidoscope-ShapeShifter/src/kaleidoscope/plugin/ShapeShifter.h b/plugins/Kaleidoscope-ShapeShifter/src/kaleidoscope/plugin/ShapeShifter.h index 3b8ad7da..b113cf49 100644 --- a/plugins/Kaleidoscope-ShapeShifter/src/kaleidoscope/plugin/ShapeShifter.h +++ b/plugins/Kaleidoscope-ShapeShifter/src/kaleidoscope/plugin/ShapeShifter.h @@ -32,7 +32,7 @@ class ShapeShifter : public kaleidoscope::Plugin { static const dictionary_t *dictionary; - EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state); + EventHandlerResult onKeyEvent(KeyEvent &event); }; }