From f2bca33a7c7ba9e988343ca03c48f1c1af61afac Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 25 Jun 2018 21:12:27 +0200 Subject: [PATCH] Improve the compatibility layer When the V1 plugin API is enabled, we need to override `onSetup`, to not call `setup()` twice: once via the v2 default `onSetup`, and once via the legacy API. Take special attention to call `LEDControl.mode_add`, so that the effect does register as a LED mode. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/AlphaSquare-Effect.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Kaleidoscope/AlphaSquare-Effect.h b/src/Kaleidoscope/AlphaSquare-Effect.h index 34381df2..ff5bd386 100644 --- a/src/Kaleidoscope/AlphaSquare-Effect.h +++ b/src/Kaleidoscope/AlphaSquare-Effect.h @@ -29,6 +29,15 @@ class AlphaSquareEffect : public LEDMode { static uint16_t length; EventHandlerResult onKeyswitchEvent(Key &mappedKey, byte row, byte col, uint8_t keyState); + +#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API + kaleidoscope::EventHandlerResult onSetup() { + ::LEDControl.mode_add(this); + + return kaleidoscope::EventHandlerResult::OK; + } +#endif + protected: void update(void) final;