From 98563a7afd66e1667d5ad19e84511150f7a1cdcb Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 17 Jun 2018 11:13:37 +0200 Subject: [PATCH] Override onSetup when using a compatibility layer The default `onSetup` will call `.begin`, to support initializing plugins using the V1 plugins while using `KALEIDOSCOPE_INIT_PLUGINS`. However, plugins that implement a compatibility layer so that they can be used with both the new API, and with `Kaleidoscope.use()` will have a `.begin` method too. Which the default `onSetup` will call, and we'll register the compatibility layer too, in addition to the new-style event handlers. This results in many things running twice, which leads to all kinds of problems. For this reason, override `onSetup`, so that it does not call `begin`. When used with `Kaleidoscope.use()`, the plugin will still work, so compatibility is maintained. But the bug is now gone. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/LED-Stalker.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Kaleidoscope/LED-Stalker.h b/src/Kaleidoscope/LED-Stalker.h index 9f5041f9..56419c2a 100644 --- a/src/Kaleidoscope/LED-Stalker.h +++ b/src/Kaleidoscope/LED-Stalker.h @@ -37,6 +37,13 @@ class StalkerEffect : public LEDMode { static uint16_t step_length; EventHandlerResult onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t keyState); + +#if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API + kaleidoscope::EventHandlerResult onSetup() { + return kaleidoscope::EventHandlerResult::OK; + } +#endif + protected: void onActivate(void) final; void update(void) final;