From 640ef1901c0b4904d7f55fa85db9350908eb9582 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Wed, 6 Mar 2024 16:56:04 -0800 Subject: [PATCH] port the rest of the 'onNameQuery' implementations over to the mixin --- .../src/kaleidoscope/plugin/CharShift.cpp | 4 ---- .../src/kaleidoscope/plugin/CharShift.h | 9 +++++++-- .../src/kaleidoscope/plugin/Cycle.cpp | 3 --- .../src/kaleidoscope/plugin/Cycle.h | 9 +++++++-- .../kaleidoscope/plugin/DynamicTapDance.cpp | 3 --- .../src/kaleidoscope/plugin/DynamicTapDance.h | 9 +++++++-- .../src/kaleidoscope/plugin/FingerPainter.cpp | 3 --- .../src/kaleidoscope/plugin/FingerPainter.h | 8 ++++++-- .../src/kaleidoscope/plugin/IdleLEDs.cpp | 3 --- .../src/kaleidoscope/plugin/IdleLEDs.h | 9 +++++++-- .../plugin/LEDBrightnessConfig.cpp | 3 --- .../kaleidoscope/plugin/LEDBrightnessConfig.h | 10 ++++++++-- .../src/kaleidoscope/plugin/LayerNames.cpp | 3 --- .../src/kaleidoscope/plugin/LayerNames.h | 9 +++++++-- .../src/kaleidoscope/plugin/Leader.cpp | 4 +--- .../src/kaleidoscope/plugin/Leader.h | 10 ++++++++-- .../src/kaleidoscope/plugin/MacroSupport.cpp | 4 ---- .../src/kaleidoscope/plugin/MacroSupport.h | 10 ++++++++-- .../src/kaleidoscope/plugin/MagicCombo.cpp | 3 --- .../src/kaleidoscope/plugin/MagicCombo.h | 10 ++++++++-- .../src/kaleidoscope/plugin/OneShot.cpp | 4 ---- .../src/kaleidoscope/plugin/OneShot.h | 18 +++++++++++++----- .../src/kaleidoscope/plugin/OneShotConfig.cpp | 3 --- .../kaleidoscope/plugin/OneShotMetaKeys.cpp | 4 +--- .../src/kaleidoscope/plugin/OneShotMetaKeys.h | 9 +++++++-- .../kaleidoscope/plugin/PersistentLEDMode.cpp | 3 --- .../kaleidoscope/plugin/PersistentLEDMode.h | 10 +++++++--- .../src/kaleidoscope/plugin/Redial.h | 1 - 28 files changed, 102 insertions(+), 76 deletions(-) diff --git a/plugins/Kaleidoscope-CharShift/src/kaleidoscope/plugin/CharShift.cpp b/plugins/Kaleidoscope-CharShift/src/kaleidoscope/plugin/CharShift.cpp index 78176d469c..69311487fd 100644 --- a/plugins/Kaleidoscope-CharShift/src/kaleidoscope/plugin/CharShift.cpp +++ b/plugins/Kaleidoscope-CharShift/src/kaleidoscope/plugin/CharShift.cpp @@ -38,10 +38,6 @@ namespace plugin { // ============================================================================= // Event handlers -// ----------------------------------------------------------------------------- -EventHandlerResult CharShift::onNameQuery() { - return ::Focus.sendName(F("CharShift")); -} // ----------------------------------------------------------------------------- EventHandlerResult CharShift::onKeyEvent(KeyEvent &event) { diff --git a/plugins/Kaleidoscope-CharShift/src/kaleidoscope/plugin/CharShift.h b/plugins/Kaleidoscope-CharShift/src/kaleidoscope/plugin/CharShift.h index d407c2c56e..8b269ddfd7 100644 --- a/plugins/Kaleidoscope-CharShift/src/kaleidoscope/plugin/CharShift.h +++ b/plugins/Kaleidoscope-CharShift/src/kaleidoscope/plugin/CharShift.h @@ -25,6 +25,7 @@ #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/key_defs.h" // for Key #include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin namespace kaleidoscope { namespace plugin { @@ -38,10 +39,9 @@ namespace plugin { /// normally produced with the `shift` modifier. Crucially, when `shift` is /// held, and the `Key` to be output does not have the `shift` modifier flag /// applied to it, the held `shift` modifier will be suppressed. -class CharShift : public Plugin { +class CharShift : public Plugin, public FocusPlugin { public: - EventHandlerResult onNameQuery(); EventHandlerResult onKeyEvent(KeyEvent &event); EventHandlerResult beforeReportingState(const KeyEvent &event); @@ -82,6 +82,11 @@ class CharShift : public Plugin { num_keypairs_ = _num_keypairs; } + protected: + const __FlashStringHelper *getPluginName() const override { + return F("CharShift"); + } + private: // A pointer to an array of `KeyPair` objects in PROGMEM KeyPair const *progmem_keypairs_ = nullptr; diff --git a/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.cpp b/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.cpp index 0c298f0cd5..38e95c3610 100644 --- a/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.cpp +++ b/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.cpp @@ -54,9 +54,6 @@ void Cycle::replace(uint8_t cycle_size, const Key cycle_steps[]) { // --- hooks --- -EventHandlerResult Cycle::onNameQuery() { - return ::Focus.sendName(F("Cycle")); -} EventHandlerResult Cycle::onKeyEvent(KeyEvent &event) { if (keyIsInjected(event.state)) diff --git a/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.h b/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.h index f7ba39ab59..87c38459e0 100644 --- a/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.h +++ b/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.h @@ -26,6 +26,7 @@ #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/key_defs.h" // for Key #include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin constexpr Key Key_Cycle = Key(kaleidoscope::ranges::CYCLE); @@ -36,14 +37,18 @@ constexpr Key Key_Cycle = Key(kaleidoscope::ranges::CYCLE); namespace kaleidoscope { namespace plugin { -class Cycle : public kaleidoscope::Plugin { +class Cycle : public kaleidoscope::Plugin, public FocusPlugin { public: void replace(Key key); void replace(uint8_t cycle_size, const Key cycle_steps[]); - EventHandlerResult onNameQuery(); EventHandlerResult onKeyEvent(KeyEvent &event); + protected: + const __FlashStringHelper *getPluginName() const override { + return F("Cycle"); + } + private: uint8_t toModFlag(uint8_t keyCode); Key last_non_cycle_key_; diff --git a/plugins/Kaleidoscope-DynamicTapDance/src/kaleidoscope/plugin/DynamicTapDance.cpp b/plugins/Kaleidoscope-DynamicTapDance/src/kaleidoscope/plugin/DynamicTapDance.cpp index e7d79fcff1..748daf460e 100644 --- a/plugins/Kaleidoscope-DynamicTapDance/src/kaleidoscope/plugin/DynamicTapDance.cpp +++ b/plugins/Kaleidoscope-DynamicTapDance/src/kaleidoscope/plugin/DynamicTapDance.cpp @@ -89,9 +89,6 @@ bool DynamicTapDance::dance(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t t return true; } -EventHandlerResult DynamicTapDance::onNameQuery() { - return ::Focus.sendName(F("DynamicTapDance")); -} EventHandlerResult DynamicTapDance::onFocusEvent(const char *input) { const char *cmd_map = PSTR("tapdance.map"); diff --git a/plugins/Kaleidoscope-DynamicTapDance/src/kaleidoscope/plugin/DynamicTapDance.h b/plugins/Kaleidoscope-DynamicTapDance/src/kaleidoscope/plugin/DynamicTapDance.h index 10362f7565..ec2b02ce71 100644 --- a/plugins/Kaleidoscope-DynamicTapDance/src/kaleidoscope/plugin/DynamicTapDance.h +++ b/plugins/Kaleidoscope-DynamicTapDance/src/kaleidoscope/plugin/DynamicTapDance.h @@ -24,19 +24,24 @@ #include "kaleidoscope/KeyAddr.h" // for KeyAddr #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin namespace kaleidoscope { namespace plugin { -class DynamicTapDance : public kaleidoscope::Plugin { +class DynamicTapDance : public kaleidoscope::Plugin, public FocusPlugin { public: - EventHandlerResult onNameQuery(); EventHandlerResult onFocusEvent(const char *input); void setup(uint8_t dynamic_offset, uint16_t size); bool dance(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, TapDance::ActionType tap_dance_action); + protected: + const __FlashStringHelper *getPluginName() const override { + return F("DynamicTapDance"); + } + private: uint16_t storage_base_; uint16_t storage_size_; diff --git a/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.cpp b/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.cpp index 37ead72e67..55d6c8664a 100644 --- a/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.cpp +++ b/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.cpp @@ -33,9 +33,6 @@ namespace kaleidoscope { namespace plugin { -EventHandlerResult FingerPainter::onNameQuery() { - return ::Focus.sendName(F("FingerPainter")); -} EventHandlerResult FingerPainter::onSetup() { color_base_ = ::LEDPaletteTheme.reserveThemes(1); diff --git a/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.h b/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.h index fc287a974d..e7ba09e8ee 100644 --- a/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.h +++ b/plugins/Kaleidoscope-FingerPainter/src/kaleidoscope/plugin/FingerPainter.h @@ -23,6 +23,7 @@ #include "kaleidoscope/KeyEvent.h" // for KeyEvent #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/plugin/LEDMode.h" // for LEDMode +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin namespace kaleidoscope { namespace plugin { @@ -31,19 +32,22 @@ namespace plugin { // as there is no benefit of transforming it into a dynamic // LED mode in terms of PROGMEM or RAM. // -class FingerPainter : public LEDMode { +class FingerPainter : public LEDMode, public FocusPlugin { public: void toggle(); EventHandlerResult onKeyEvent(KeyEvent &event); EventHandlerResult onFocusEvent(const char *input); EventHandlerResult onSetup(); - EventHandlerResult onNameQuery(); protected: void update() final; void refreshAt(KeyAddr key_addr) final; + const __FlashStringHelper *getPluginName() const override { + return F("FingerPainter"); + } + private: uint16_t color_base_; bool edit_mode_; diff --git a/plugins/Kaleidoscope-IdleLEDs/src/kaleidoscope/plugin/IdleLEDs.cpp b/plugins/Kaleidoscope-IdleLEDs/src/kaleidoscope/plugin/IdleLEDs.cpp index 7e85319f26..dadae71423 100644 --- a/plugins/Kaleidoscope-IdleLEDs/src/kaleidoscope/plugin/IdleLEDs.cpp +++ b/plugins/Kaleidoscope-IdleLEDs/src/kaleidoscope/plugin/IdleLEDs.cpp @@ -70,9 +70,6 @@ EventHandlerResult IdleLEDs::onKeyEvent(KeyEvent &event) { uint16_t PersistentIdleLEDs::settings_base_; -EventHandlerResult PersistentIdleLEDs::onNameQuery() { - return ::Focus.sendName(F("PersistentIdleLEDs")); -} EventHandlerResult PersistentIdleLEDs::onSetup() { uint16_t idle_time; diff --git a/plugins/Kaleidoscope-IdleLEDs/src/kaleidoscope/plugin/IdleLEDs.h b/plugins/Kaleidoscope-IdleLEDs/src/kaleidoscope/plugin/IdleLEDs.h index e2a85e60a8..7250600cec 100644 --- a/plugins/Kaleidoscope-IdleLEDs/src/kaleidoscope/plugin/IdleLEDs.h +++ b/plugins/Kaleidoscope-IdleLEDs/src/kaleidoscope/plugin/IdleLEDs.h @@ -23,6 +23,7 @@ #include "kaleidoscope/KeyEvent.h" // for KeyEvent #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin namespace kaleidoscope { namespace plugin { @@ -42,14 +43,18 @@ class IdleLEDs : public kaleidoscope::Plugin { static uint32_t start_time_; }; -class PersistentIdleLEDs : public IdleLEDs { +class PersistentIdleLEDs : public IdleLEDs, public FocusPlugin { public: EventHandlerResult onSetup(); - EventHandlerResult onNameQuery(); EventHandlerResult onFocusEvent(const char *input); static void setIdleTimeoutSeconds(uint32_t new_limit); + protected: + const __FlashStringHelper *getPluginName() const override { + return F("PersistentIdleLEDs"); + } + private: static uint16_t settings_base_; }; diff --git a/plugins/Kaleidoscope-LEDBrightnessConfig/src/kaleidoscope/plugin/LEDBrightnessConfig.cpp b/plugins/Kaleidoscope-LEDBrightnessConfig/src/kaleidoscope/plugin/LEDBrightnessConfig.cpp index f772371575..5fe993bb5c 100644 --- a/plugins/Kaleidoscope-LEDBrightnessConfig/src/kaleidoscope/plugin/LEDBrightnessConfig.cpp +++ b/plugins/Kaleidoscope-LEDBrightnessConfig/src/kaleidoscope/plugin/LEDBrightnessConfig.cpp @@ -62,9 +62,6 @@ EventHandlerResult LEDBrightnessConfig::onFocusEvent(const char *command) { return EventHandlerResult::EVENT_CONSUMED; } -EventHandlerResult LEDBrightnessConfig::onNameQuery() { - return ::Focus.sendName(F("LEDBrightnessConfig")); -} } // namespace plugin } // namespace kaleidoscope diff --git a/plugins/Kaleidoscope-LEDBrightnessConfig/src/kaleidoscope/plugin/LEDBrightnessConfig.h b/plugins/Kaleidoscope-LEDBrightnessConfig/src/kaleidoscope/plugin/LEDBrightnessConfig.h index 4b83ce87ea..e420489a73 100644 --- a/plugins/Kaleidoscope-LEDBrightnessConfig/src/kaleidoscope/plugin/LEDBrightnessConfig.h +++ b/plugins/Kaleidoscope-LEDBrightnessConfig/src/kaleidoscope/plugin/LEDBrightnessConfig.h @@ -21,16 +21,22 @@ #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin namespace kaleidoscope { namespace plugin { -class LEDBrightnessConfig : public kaleidoscope::Plugin { +class LEDBrightnessConfig : public kaleidoscope::Plugin, public FocusPlugin { public: EventHandlerResult onSetup(); - EventHandlerResult onNameQuery(); EventHandlerResult onFocusEvent(const char *command); + + protected: + const __FlashStringHelper *getPluginName() const override { + return F("LEDBrightnessConfig"); + } + private: static uint16_t settings_base_; static struct settings { diff --git a/plugins/Kaleidoscope-LayerNames/src/kaleidoscope/plugin/LayerNames.cpp b/plugins/Kaleidoscope-LayerNames/src/kaleidoscope/plugin/LayerNames.cpp index 1eaea338a3..8f43aee40f 100644 --- a/plugins/Kaleidoscope-LayerNames/src/kaleidoscope/plugin/LayerNames.cpp +++ b/plugins/Kaleidoscope-LayerNames/src/kaleidoscope/plugin/LayerNames.cpp @@ -27,9 +27,6 @@ namespace plugin { // ============================================================================= -EventHandlerResult LayerNames::onNameQuery() { - return ::Focus.sendName(F("LayerNames")); -} EventHandlerResult LayerNames::onFocusEvent(const char *input) { const char *cmd_layerNames = PSTR("keymap.layerNames"); diff --git a/plugins/Kaleidoscope-LayerNames/src/kaleidoscope/plugin/LayerNames.h b/plugins/Kaleidoscope-LayerNames/src/kaleidoscope/plugin/LayerNames.h index 3bf6b3fa3a..66f2b6403d 100644 --- a/plugins/Kaleidoscope-LayerNames/src/kaleidoscope/plugin/LayerNames.h +++ b/plugins/Kaleidoscope-LayerNames/src/kaleidoscope/plugin/LayerNames.h @@ -20,17 +20,22 @@ #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin namespace kaleidoscope { namespace plugin { -class LayerNames : public kaleidoscope::Plugin { +class LayerNames : public kaleidoscope::Plugin, public FocusPlugin { public: - EventHandlerResult onNameQuery(); EventHandlerResult onFocusEvent(const char *input); void reserve_storage(uint16_t size); + protected: + const __FlashStringHelper *getPluginName() const override { + return F("LayerNames"); + } + private: uint16_t storage_base_; uint16_t storage_size_; diff --git a/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp b/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp index 6438be2d96..f1a90a0825 100644 --- a/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp +++ b/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp @@ -94,9 +94,7 @@ void Leader::inject(Key key, uint8_t key_state) { #endif // --- hooks --- -EventHandlerResult Leader::onNameQuery() { - return ::Focus.sendName(F("Leader")); -} + EventHandlerResult Leader::onKeyswitchEvent(KeyEvent &event) { // If the plugin has already processed and released this event, ignore it. diff --git a/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.h b/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.h index 3c9f9d2a94..da8d7f1a78 100644 --- a/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.h +++ b/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.h @@ -26,6 +26,8 @@ #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/key_defs.h" // for Key, Key_NoKey #include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin + // ----------------------------------------------------------------------------- // Deprecation warning messages #include "kaleidoscope_internal/deprecations.h" // for DEPRECATED @@ -61,7 +63,7 @@ constexpr Key LeaderKey(uint8_t n) { return Key(kaleidoscope::ranges::LEAD_FIRST + n); } -class Leader : public kaleidoscope::Plugin { +class Leader : public kaleidoscope::Plugin, public FocusPlugin { public: typedef void (*action_t)(uint8_t seq_index); struct dictionary_t { @@ -91,10 +93,14 @@ class Leader : public kaleidoscope::Plugin { timeout_ = timeout; } - EventHandlerResult onNameQuery(); EventHandlerResult onKeyswitchEvent(KeyEvent &event); EventHandlerResult afterEachCycle(); + protected: + const __FlashStringHelper *getPluginName() const override { + return F("Leader"); + } + private: Key sequence_[LEADER_MAX_SEQUENCE_LENGTH + 1]; KeyEventTracker event_tracker_; diff --git a/plugins/Kaleidoscope-MacroSupport/src/kaleidoscope/plugin/MacroSupport.cpp b/plugins/Kaleidoscope-MacroSupport/src/kaleidoscope/plugin/MacroSupport.cpp index 27b1722d73..6c9b17ccb0 100644 --- a/plugins/Kaleidoscope-MacroSupport/src/kaleidoscope/plugin/MacroSupport.cpp +++ b/plugins/Kaleidoscope-MacroSupport/src/kaleidoscope/plugin/MacroSupport.cpp @@ -95,10 +95,6 @@ EventHandlerResult MacroSupport::beforeReportingState(const KeyEvent &event) { return EventHandlerResult::OK; } -EventHandlerResult MacroSupport::onNameQuery() { - return ::Focus.sendName(F("MacroSupport")); -} - } // namespace plugin } // namespace kaleidoscope diff --git a/plugins/Kaleidoscope-MacroSupport/src/kaleidoscope/plugin/MacroSupport.h b/plugins/Kaleidoscope-MacroSupport/src/kaleidoscope/plugin/MacroSupport.h index 8358e37bfc..d2ec47d502 100644 --- a/plugins/Kaleidoscope-MacroSupport/src/kaleidoscope/plugin/MacroSupport.h +++ b/plugins/Kaleidoscope-MacroSupport/src/kaleidoscope/plugin/MacroSupport.h @@ -20,6 +20,7 @@ #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/key_defs.h" // for Key #include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin // ============================================================================= // The number of simultaneously-active `Key` values that a macro can have @@ -33,7 +34,7 @@ namespace kaleidoscope { namespace plugin { -class MacroSupport : public Plugin { +class MacroSupport : public Plugin, public FocusPlugin { public: /// Send a key press event from a Macro /// @@ -64,9 +65,14 @@ class MacroSupport : public Plugin { // --------------------------------------------------------------------------- // Event handlers - EventHandlerResult onNameQuery(); EventHandlerResult beforeReportingState(const KeyEvent &event); + + protected: + const __FlashStringHelper *getPluginName() const override { + return F("MacroSupport"); + } + private: // An array of key values that are active while a macro sequence is playing Key active_macro_keys_[MAX_CONCURRENT_MACRO_KEYS]; diff --git a/plugins/Kaleidoscope-MagicCombo/src/kaleidoscope/plugin/MagicCombo.cpp b/plugins/Kaleidoscope-MagicCombo/src/kaleidoscope/plugin/MagicCombo.cpp index e34bf9999a..ba3b017d97 100644 --- a/plugins/Kaleidoscope-MagicCombo/src/kaleidoscope/plugin/MagicCombo.cpp +++ b/plugins/Kaleidoscope-MagicCombo/src/kaleidoscope/plugin/MagicCombo.cpp @@ -32,9 +32,6 @@ namespace plugin { uint16_t MagicCombo::min_interval = 500; #endif -EventHandlerResult MagicCombo::onNameQuery() { - return ::Focus.sendName(F("MagicCombo")); -} EventHandlerResult MagicCombo::afterEachCycle() { for (uint8_t i = 0; i < magiccombo::combos_length; i++) { diff --git a/plugins/Kaleidoscope-MagicCombo/src/kaleidoscope/plugin/MagicCombo.h b/plugins/Kaleidoscope-MagicCombo/src/kaleidoscope/plugin/MagicCombo.h index f5bb540048..5740c2c827 100644 --- a/plugins/Kaleidoscope-MagicCombo/src/kaleidoscope/plugin/MagicCombo.h +++ b/plugins/Kaleidoscope-MagicCombo/src/kaleidoscope/plugin/MagicCombo.h @@ -22,6 +22,8 @@ #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin + // ----------------------------------------------------------------------------- // Deprecation warning messages #include "kaleidoscope_internal/deprecations.h" // for DEPRECATED @@ -49,7 +51,7 @@ namespace kaleidoscope { namespace plugin { -class MagicCombo : public kaleidoscope::Plugin { +class MagicCombo : public kaleidoscope::Plugin, FocusPlugin { public: typedef void (*ComboAction)(uint8_t combo_index); struct Combo { @@ -84,9 +86,13 @@ class MagicCombo : public kaleidoscope::Plugin { #endif } - EventHandlerResult onNameQuery(); EventHandlerResult afterEachCycle(); + protected: + const __FlashStringHelper *getPluginName() const override { + return F("MagicCombo"); + } + private: uint16_t start_time_ = 0; uint16_t min_interval_ = 500; diff --git a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp index b1914c150e..c1ce9f4a9b 100644 --- a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp +++ b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp @@ -184,10 +184,6 @@ void OneShot::cancel(bool cancel_stickies) { // ---------------------------------------------------------------------------- // Plugin hook functions -EventHandlerResult OneShot::onNameQuery() { - return ::Focus.sendName(F("OneShot")); -} - EventHandlerResult OneShot::onKeyEvent(KeyEvent &event) { // Ignore injected key events. This prevents re-processing events that the diff --git a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h index 526d77201a..b4dbd1cff6 100644 --- a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h +++ b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h @@ -27,7 +27,7 @@ #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/key_defs.h" // for Key #include "kaleidoscope/plugin.h" // for Plugin - +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin // IWYU pragma: no_include "HIDAliases.h" // ---------------------------------------------------------------------------- @@ -48,7 +48,7 @@ constexpr Key OneShotLayerKey(uint8_t layer) { return Key(kaleidoscope::ranges::OSL_FIRST + layer); } -class OneShot : public kaleidoscope::Plugin { +class OneShot : public kaleidoscope::Plugin, public FocusPlugin { public: // -------------------------------------------------------------------------- // Configuration functions @@ -193,13 +193,17 @@ class OneShot : public kaleidoscope::Plugin { // -------------------------------------------------------------------------- // Plugin hook functions - EventHandlerResult onNameQuery(); EventHandlerResult onKeyEvent(KeyEvent &event); EventHandlerResult afterReportingState(const KeyEvent &event); EventHandlerResult afterEachCycle(); friend class OneShotConfig; + protected: + const __FlashStringHelper *getPluginName() const override { + return F("OneShot"); + } + private: // -------------------------------------------------------------------------- // Constants @@ -255,12 +259,16 @@ class OneShot : public kaleidoscope::Plugin { // ============================================================================= // Plugin for configuration of OneShot via Focus and persistent storage of // settins in EEPROM (i.e. Chrysalis). -class OneShotConfig : public Plugin { +class OneShotConfig : public Plugin, public FocusPlugin { public: - EventHandlerResult onNameQuery(); EventHandlerResult onSetup(); EventHandlerResult onFocusEvent(const char *command); + protected: + const __FlashStringHelper *getPluginName() const override { + return F("OneShotConfig"); + } + private: // The base address in persistent storage for configuration data: uint16_t settings_base_; diff --git a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShotConfig.cpp b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShotConfig.cpp index ace1b6cc81..5cc024ab3f 100644 --- a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShotConfig.cpp +++ b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShotConfig.cpp @@ -40,9 +40,6 @@ EventHandlerResult OneShotConfig::onSetup() { return EventHandlerResult::OK; } -EventHandlerResult OneShotConfig::onNameQuery() { - return ::Focus.sendName(F("OneShotConfig")); -} EventHandlerResult OneShotConfig::onFocusEvent(const char *input) { enum Command : uint8_t { diff --git a/plugins/Kaleidoscope-OneShotMetaKeys/src/kaleidoscope/plugin/OneShotMetaKeys.cpp b/plugins/Kaleidoscope-OneShotMetaKeys/src/kaleidoscope/plugin/OneShotMetaKeys.cpp index febf4a1fd0..7fee14b760 100644 --- a/plugins/Kaleidoscope-OneShotMetaKeys/src/kaleidoscope/plugin/OneShotMetaKeys.cpp +++ b/plugins/Kaleidoscope-OneShotMetaKeys/src/kaleidoscope/plugin/OneShotMetaKeys.cpp @@ -39,9 +39,7 @@ namespace plugin { // ---------------------------------------------------------------------------- // Plugin hook functions -EventHandlerResult OneShotMetaKeys::onNameQuery() { - return ::Focus.sendName(F("OneShotMetaKeys")); -} + EventHandlerResult OneShotMetaKeys::onKeyEvent(KeyEvent &event) { // Ignore key release and injected events. diff --git a/plugins/Kaleidoscope-OneShotMetaKeys/src/kaleidoscope/plugin/OneShotMetaKeys.h b/plugins/Kaleidoscope-OneShotMetaKeys/src/kaleidoscope/plugin/OneShotMetaKeys.h index e623137f9e..53861aff9b 100644 --- a/plugins/Kaleidoscope-OneShotMetaKeys/src/kaleidoscope/plugin/OneShotMetaKeys.h +++ b/plugins/Kaleidoscope-OneShotMetaKeys/src/kaleidoscope/plugin/OneShotMetaKeys.h @@ -23,6 +23,7 @@ #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/key_defs.h" // for Key #include "kaleidoscope/plugin.h" // for Plugin +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin // ---------------------------------------------------------------------------- // Key constants @@ -32,14 +33,18 @@ constexpr Key OneShot_ActiveStickyKey{kaleidoscope::ranges::OS_ACTIVE_STICKY}; namespace kaleidoscope { namespace plugin { -class OneShotMetaKeys : public kaleidoscope::Plugin { +class OneShotMetaKeys : public kaleidoscope::Plugin, public FocusPlugin { public: // -------------------------------------------------------------------------- // Plugin hook functions - EventHandlerResult onNameQuery(); EventHandlerResult onKeyEvent(KeyEvent &event); + protected: + const __FlashStringHelper *getPluginName() const override { + return F("OneShotMetaKeys"); + } + private: static bool isMetaStickyActive(); }; diff --git a/plugins/Kaleidoscope-PersistentLEDMode/src/kaleidoscope/plugin/PersistentLEDMode.cpp b/plugins/Kaleidoscope-PersistentLEDMode/src/kaleidoscope/plugin/PersistentLEDMode.cpp index eca57e9c55..c90a092198 100644 --- a/plugins/Kaleidoscope-PersistentLEDMode/src/kaleidoscope/plugin/PersistentLEDMode.cpp +++ b/plugins/Kaleidoscope-PersistentLEDMode/src/kaleidoscope/plugin/PersistentLEDMode.cpp @@ -55,9 +55,6 @@ EventHandlerResult PersistentLEDMode::onLEDModeChange() { return EventHandlerResult::OK; } -EventHandlerResult PersistentLEDMode::onNameQuery() { - return ::Focus.sendName(F("PersistentLEDMode")); -} } // namespace plugin } // namespace kaleidoscope diff --git a/plugins/Kaleidoscope-PersistentLEDMode/src/kaleidoscope/plugin/PersistentLEDMode.h b/plugins/Kaleidoscope-PersistentLEDMode/src/kaleidoscope/plugin/PersistentLEDMode.h index 1375429ec9..2936fbee7f 100644 --- a/plugins/Kaleidoscope-PersistentLEDMode/src/kaleidoscope/plugin/PersistentLEDMode.h +++ b/plugins/Kaleidoscope-PersistentLEDMode/src/kaleidoscope/plugin/PersistentLEDMode.h @@ -22,16 +22,20 @@ #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/plugin.h" // for Plugin - +#include "kaleidoscope/plugin/FocusPlugin.h" // for FocusPlugin namespace kaleidoscope { namespace plugin { -class PersistentLEDMode : public kaleidoscope::Plugin { +class PersistentLEDMode : public kaleidoscope::Plugin, public FocusPlugin { public: EventHandlerResult onSetup(); - EventHandlerResult onNameQuery(); EventHandlerResult onLEDModeChange(); + protected: + const __FlashStringHelper *getPluginName() const override { + return F("PersistentLEDMode"); + } + private: static uint16_t settings_base_; static struct settings { diff --git a/plugins/Kaleidoscope-Redial/src/kaleidoscope/plugin/Redial.h b/plugins/Kaleidoscope-Redial/src/kaleidoscope/plugin/Redial.h index b9d34ff7a4..3c35454325 100644 --- a/plugins/Kaleidoscope-Redial/src/kaleidoscope/plugin/Redial.h +++ b/plugins/Kaleidoscope-Redial/src/kaleidoscope/plugin/Redial.h @@ -34,7 +34,6 @@ class Redial : public kaleidoscope::Plugin, public FocusPlugin { public: static bool shouldRemember(Key mappedKey); - EventHandlerResult onNameQuery(); EventHandlerResult onKeyEvent(KeyEvent &event); protected: