From 2d8ff952391d7e797c17b9248d7e0c284ba191b6 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 5 Oct 2018 14:21:08 +0200 Subject: [PATCH] Migrate to the new onFocusEvent API Signed-off-by: Gergely Nagy --- src/Kaleidoscope/EEPROM-Keymap-Programmer.cpp | 13 +++++++++---- src/Kaleidoscope/EEPROM-Keymap-Programmer.h | 6 +----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Kaleidoscope/EEPROM-Keymap-Programmer.cpp b/src/Kaleidoscope/EEPROM-Keymap-Programmer.cpp index 9504b323..5225b0e5 100644 --- a/src/Kaleidoscope/EEPROM-Keymap-Programmer.cpp +++ b/src/Kaleidoscope/EEPROM-Keymap-Programmer.cpp @@ -94,16 +94,21 @@ EventHandlerResult EEPROMKeymapProgrammer::onKeyswitchEvent(Key &mapped_key, byt return EventHandlerResult::EVENT_CONSUMED; } -bool EEPROMKeymapProgrammer::focusHook(const char *command) { - if (strcmp_P(command, PSTR("keymap.toggleProgrammer")) != 0) - return false; +EventHandlerResult EEPROMKeymapProgrammer::onFocusEvent(const char *command) { + const char *cmd = PSTR("keymap.toggleProgrammer"); + + if (::Focus.handleHelp(command, cmd)) + return EventHandlerResult::OK; + + if (strcmp_P(command, cmd) != 0) + return EventHandlerResult::OK; if (state_ == INACTIVE) activate(); else cancel(); - return true; + return EventHandlerResult::EVENT_CONSUMED; } } diff --git a/src/Kaleidoscope/EEPROM-Keymap-Programmer.h b/src/Kaleidoscope/EEPROM-Keymap-Programmer.h index c4a70658..dcc20cf0 100644 --- a/src/Kaleidoscope/EEPROM-Keymap-Programmer.h +++ b/src/Kaleidoscope/EEPROM-Keymap-Programmer.h @@ -37,9 +37,8 @@ class EEPROMKeymapProgrammer : public kaleidoscope::Plugin { static void nextState(void); static void cancel(void); - static bool focusHook(const char *command); - EventHandlerResult onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state); + EventHandlerResult onFocusEvent(const char *command); private: typedef enum { @@ -56,6 +55,3 @@ class EEPROMKeymapProgrammer : public kaleidoscope::Plugin { } extern kaleidoscope::EEPROMKeymapProgrammer EEPROMKeymapProgrammer; - -#define FOCUS_HOOK_KEYMAP_PROGRAMMER FOCUS_HOOK(EEPROMKeymapProgrammer.focusHook, \ - "keymap.toggleProgrammer")