From 48e1130dced6557f4bcf4bb6237deb2fe267af1f Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 6 Apr 2021 18:57:37 -0500 Subject: [PATCH] Adapt EEPROM-Keymap-Programmer plugin to KeyEvent handlers Signed-off-by: Michael Richters --- .../plugin/EEPROM-Keymap-Programmer.cpp | 26 +++++++++---------- .../plugin/EEPROM-Keymap-Programmer.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/Kaleidoscope-EEPROM-Keymap-Programmer/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.cpp b/plugins/Kaleidoscope-EEPROM-Keymap-Programmer/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.cpp index 07fa56e6..bbc6a578 100644 --- a/plugins/Kaleidoscope-EEPROM-Keymap-Programmer/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.cpp +++ b/plugins/Kaleidoscope-EEPROM-Keymap-Programmer/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.cpp @@ -53,27 +53,27 @@ void EEPROMKeymapProgrammer::cancel(void) { state_ = INACTIVE; } -EventHandlerResult EEPROMKeymapProgrammer::onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state) { +EventHandlerResult EEPROMKeymapProgrammer::onKeyEvent(KeyEvent &event) { if (state_ == INACTIVE) return EventHandlerResult::OK; if (state_ == WAIT_FOR_KEY) { - if (keyToggledOn(key_state)) { - update_position_ = Layer.mostRecent() * Runtime.device().numKeys() + key_addr.toInt(); + if (keyToggledOn(event.state)) { + update_position_ = Layer.mostRecent() * Runtime.device().numKeys() + event.addr.toInt(); } - if (keyToggledOff(key_state)) { - if ((uint16_t)(Layer.mostRecent() * Runtime.device().numKeys() + key_addr.toInt()) == update_position_) + if (keyToggledOff(event.state)) { + if ((uint16_t)(Layer.mostRecent() * Runtime.device().numKeys() + event.addr.toInt()) == update_position_) nextState(); } return EventHandlerResult::EVENT_CONSUMED; } if (state_ == WAIT_FOR_SOURCE_KEY) { - if (keyToggledOn(key_state)) { - new_key_ = Layer.getKeyFromPROGMEM(Layer.mostRecent(), key_addr); + if (keyToggledOn(event.state)) { + new_key_ = Layer.getKeyFromPROGMEM(Layer.mostRecent(), event.addr); } - if (keyToggledOff(key_state)) { - if (new_key_ == Layer.getKeyFromPROGMEM(Layer.mostRecent(), key_addr)) + if (keyToggledOff(event.state)) { + if (new_key_ == Layer.getKeyFromPROGMEM(Layer.mostRecent(), event.addr)) nextState(); } return EventHandlerResult::EVENT_CONSUMED; @@ -81,18 +81,18 @@ EventHandlerResult EEPROMKeymapProgrammer::onKeyswitchEvent(Key &mapped_key, Key // WAIT_FOR_CODE state - if (mapped_key < Key_1 || mapped_key > Key_0) + if (event.key < Key_1 || event.key > Key_0) return EventHandlerResult::OK; - if (!keyToggledOn(key_state)) { + if (!keyToggledOn(event.state)) { return EventHandlerResult::EVENT_CONSUMED; } uint8_t n; - if (mapped_key.getKeyCode() == Key_0.getKeyCode()) + if (event.key.getKeyCode() == Key_0.getKeyCode()) n = 0; else - n = mapped_key.getKeyCode() - Key_1.getKeyCode() + 1; + n = event.key.getKeyCode() - Key_1.getKeyCode() + 1; new_key_.setRaw(new_key_.getRaw() * 10 + n); diff --git a/plugins/Kaleidoscope-EEPROM-Keymap-Programmer/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.h b/plugins/Kaleidoscope-EEPROM-Keymap-Programmer/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.h index 79823164..1b6aa02b 100644 --- a/plugins/Kaleidoscope-EEPROM-Keymap-Programmer/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.h +++ b/plugins/Kaleidoscope-EEPROM-Keymap-Programmer/src/kaleidoscope/plugin/EEPROM-Keymap-Programmer.h @@ -38,7 +38,7 @@ class EEPROMKeymapProgrammer : public kaleidoscope::Plugin { static void nextState(void); static void cancel(void); - EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state); + EventHandlerResult onKeyEvent(KeyEvent &event); EventHandlerResult onFocusEvent(const char *command); private: