From 65f54d63d765f5d24e60e24b18da7934350b92fc Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Fri, 13 Nov 2020 23:18:30 -0600 Subject: [PATCH] Deprecate `Layer.eventHandler()` Signed-off-by: Michael Richters --- src/kaleidoscope/key_events.cpp | 3 +-- src/kaleidoscope/layers.h | 5 +++-- src/kaleidoscope_internal/deprecations.h | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/kaleidoscope/key_events.cpp b/src/kaleidoscope/key_events.cpp index 6d2aaf46..55987049 100644 --- a/src/kaleidoscope/key_events.cpp +++ b/src/kaleidoscope/key_events.cpp @@ -41,7 +41,7 @@ static bool handleSyntheticKeyswitchEvent(Key mappedKey, uint8_t keyState) { } else if (mappedKey.getFlags() & IS_INTERNAL) { return false; } else if (mappedKey.getFlags() & SWITCH_TO_KEYMAP) { - // Should not happen, handled elsewhere. + Layer.handleKeymapKeyswitchEvent(mappedKey, keyState); } return true; @@ -124,6 +124,5 @@ void handleKeyswitchEvent(Key mappedKey, KeyAddr key_addr, uint8_t keyState) { return; // Handle all built-in key types. - Layer.eventHandler(mappedKey, key_addr, keyState); handleKeyswitchEventDefault(mappedKey, key_addr, keyState); } diff --git a/src/kaleidoscope/layers.h b/src/kaleidoscope/layers.h index 101d499b..d12fbdf1 100644 --- a/src/kaleidoscope/layers.h +++ b/src/kaleidoscope/layers.h @@ -111,6 +111,9 @@ class Layer_ { } static boolean isActive(uint8_t layer); + static void handleKeymapKeyswitchEvent(Key keymapEntry, uint8_t keyState); + + DEPRECATED(LAYER_EVENTHANDLER) static Key eventHandler(Key mappedKey, KeyAddr key_addr, uint8_t keyState); typedef Key(*GetKeyFunction)(uint8_t layer, KeyAddr key_addr); @@ -137,8 +140,6 @@ class Layer_ { static uint8_t active_layer_count_; static int8_t active_layers_[31]; static uint8_t active_layer_keymap_[kaleidoscope_internal::device.numKeys()]; - - static void handleKeymapKeyswitchEvent(Key keymapEntry, uint8_t keyState); }; } diff --git a/src/kaleidoscope_internal/deprecations.h b/src/kaleidoscope_internal/deprecations.h index 7776fc2f..5cae97ee 100644 --- a/src/kaleidoscope_internal/deprecations.h +++ b/src/kaleidoscope_internal/deprecations.h @@ -34,3 +34,7 @@ "keys at any given time. It is probably not necessary to directly\n" __NL__ \ "update that cache from a plugin, but if you need to, please use\n" __NL__ \ "the `live_keys.activate(key_addr, key)` function instead." + +#define _DEPRECATED_MESSAGE_LAYER_EVENTHANDLER __NL__ \ + "`Layer.eventHandler()` is deprecated.\n" __NL__ \ + "Please use `Layer.handleKeymapKeyswitchEvent()` instead."