Adapt ShapeShifter plugin to KeyEvent handlers

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1024/head
Michael Richters 4 years ago
parent 9352117e74
commit abba881257
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -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;
}

@ -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);
};
}

Loading…
Cancel
Save