Remove deprecated layers code

This removes several vestigial functions from the `Layer` class:

- `.handleKeymapKeyswitchEvent()` & `.eventHandler()`, which have been replaced
with the `.handleLayerKeyEvent()` function that operates on `KeyEvent` objects.

- `.lookup()`, which has been replaced by either `Runtime.lookupKey()` or
`Layer.lookupOnActiveLayer()`, depending on the specific purpose.

- `.updateLiveCompositeKeymap()`, which referred to a structure that has been
replaced.  `live_keys.activate()` serves a similar purpose, but in most cases
shouldn't be called directly by user code.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1115/head
Michael Richters 3 years ago
parent b57daf53a8
commit d0542ac6eb
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -1050,15 +1050,19 @@ The following headers and names have changed:
- [Syster](plugins/Kaleidoscope-Syster.md) had the `kaleidoscope::Syster::action_t` type replaced by `kaleidoscope::plugin::Syster::action_t`. - [Syster](plugins/Kaleidoscope-Syster.md) had the `kaleidoscope::Syster::action_t` type replaced by `kaleidoscope::plugin::Syster::action_t`.
- [TapDance](plugins/Kaleidoscope-TapDance.md) had the `kaleidoscope::TapDance::ActionType` type replaced by `kaleidoscope::plugin::TapDance::ActionType`. - [TapDance](plugins/Kaleidoscope-TapDance.md) had the `kaleidoscope::TapDance::ActionType` type replaced by `kaleidoscope::plugin::TapDance::ActionType`.
### Live Composite Keymap Cache # Removed APIs
The live composite keymap, which contained a lazily-updated version of the current keymap, has been replaced. The `Layer.updateLiveCompositeKeymap()` functions have been deprecated, and depending on the purpose of the caller, it might be appropriate to use `live_keys.activate()` instead. #### Old layer key event handler functions
When `handleKeyswitchEvent()` is looking up a `Key` value for an event, it first checks the value in the active keys cache before calling `Layer.lookup()` to get the value from the keymap. In the vast majority of cases, it won't be necessary to call `live_keys.activate()` manually, however, because simply changing the value of the `Key` parameter of an `onKeyswitchEvent()` handler will have the same effect. The deprecated `Layer.handleKeymapKeyswitchEvent()` function was removed on **2022-03-03**. Any code that called it should now call `Layer.handleLayerKeyEvent()` instead, with `event.addr` set to the appropriate `KeyAddr` value if possible, and `KeyAddr::none()` otherwise.
Second, the `Layer.eventHandler()` function has been deprecated. There wasn't much need for this to be available to plugins, and it's possible to call `Layer.handleKeymapKeyswitchEvent()` directly instead. The deprecated `Layer.eventHandler(key, addr, state)` function was removed on **2022-03-03**. Any code that refers to it should now call call `handleLayerKeyEvent(KeyEvent(addr, state, key))` instead.
# Removed APIs #### Keymap cache functions
The deprecated `Layer.updateLiveCompositeKeymap()` function was removed on **2022-03-03**. Plugin and user code probably shouldn't have been calling this directly, so there's no direct replacement for it. If a plugin needs to make changes to the `live_keys` structure (equivalent in some circumstances to the old "live composite keymap"), it can call `live_keys.activate(addr, key)`, but there are probably better ways to accomplish this goal (e.g. simply changing the value of `event.key` from an `onKeyEvent(event)` handler).
The deprecated `Layer.lookup(addr)` function was removed on **2022-03-03**. Please use `Runtime.lookupKey(addr)` instead in most circumstances. Alternatively, if you need information about the current state of the keymap regardless of any currently active keys (which may have values that override the keymap), use `Layer.lookupOnActiveLayer(addr)` instead.
#### `LEDControl.syncDelay` configuration variable #### `LEDControl.syncDelay` configuration variable

@ -129,19 +129,6 @@ void Layer_::handleLayerKeyEvent(const KeyEvent &event) {
} }
} }
#ifndef NDEPRECATED
void Layer_::handleKeymapKeyswitchEvent(Key key, uint8_t key_state) {
if (key.getFlags() == (SYNTHETIC | SWITCH_TO_KEYMAP))
handleLayerKeyEvent(KeyEvent(KeyAddr::none(), key_state, key));
}
Key Layer_::eventHandler(Key mappedKey, KeyAddr key_addr, uint8_t keyState) {
if (mappedKey.getFlags() == (SYNTHETIC | SWITCH_TO_KEYMAP))
handleLayerKeyEvent(KeyEvent(key_addr, keyState, mappedKey));
return mappedKey;
}
#endif
Key Layer_::getKeyFromPROGMEM(uint8_t layer, KeyAddr key_addr) { Key Layer_::getKeyFromPROGMEM(uint8_t layer, KeyAddr key_addr) {
return keyFromKeymap(layer, key_addr); return keyFromKeymap(layer, key_addr);
} }

@ -26,10 +26,6 @@
#include "kaleidoscope_internal/shortname.h" #include "kaleidoscope_internal/shortname.h"
#include "kaleidoscope_internal/deprecations.h" #include "kaleidoscope_internal/deprecations.h"
#ifndef NDEPRECATED
#include "kaleidoscope/LiveKeys.h"
#endif
#define START_KEYMAPS __NL__ \ #define START_KEYMAPS __NL__ \
constexpr Key keymaps_linear[][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns] PROGMEM = { constexpr Key keymaps_linear[][kaleidoscope_internal::device.matrix_rows * kaleidoscope_internal::device.matrix_columns] PROGMEM = {
@ -81,19 +77,6 @@ class Layer_ {
// The `Runtime.lookupKey()` function replaces this one, for plugins that // The `Runtime.lookupKey()` function replaces this one, for plugins that
// still want to do this same check. // still want to do this same check.
#ifndef NDEPRECATED
DEPRECATED(LAYER_LOOKUP)
static Key lookup(KeyAddr key_addr) {
// First check the keyboard state array
Key key = live_keys[key_addr];
// If that entry is clear, look up the entry from the active keymap layers
if (key == Key_Transparent) {
key = lookupOnActiveLayer(key_addr);
}
return key;
}
#endif
static Key lookupOnActiveLayer(KeyAddr key_addr) { static Key lookupOnActiveLayer(KeyAddr key_addr) {
uint8_t layer = active_layer_keymap_[key_addr.toInt()]; uint8_t layer = active_layer_keymap_[key_addr.toInt()];
return (*getKey)(layer, key_addr); return (*getKey)(layer, key_addr);
@ -115,28 +98,11 @@ class Layer_ {
static void handleLayerKeyEvent(const KeyEvent &event); static void handleLayerKeyEvent(const KeyEvent &event);
#ifndef NDEPRECATED
DEPRECATED(LAYER_HANDLE_KEYMAP_KEYSWITCH_EVENT)
static void handleKeymapKeyswitchEvent(Key keymapEntry, uint8_t keyState);
DEPRECATED(LAYER_EVENTHANDLER)
static Key eventHandler(Key mappedKey, KeyAddr key_addr, uint8_t keyState);
#endif
typedef Key(*GetKeyFunction)(uint8_t layer, KeyAddr key_addr); typedef Key(*GetKeyFunction)(uint8_t layer, KeyAddr key_addr);
static GetKeyFunction getKey; static GetKeyFunction getKey;
static Key getKeyFromPROGMEM(uint8_t layer, KeyAddr key_addr); static Key getKeyFromPROGMEM(uint8_t layer, KeyAddr key_addr);
#ifndef NDEPRECATED
DEPRECATED(LAYER_UPDATELIVECOMPOSITEKEYMAP)
static void updateLiveCompositeKeymap(KeyAddr key_addr, Key mappedKey) {
live_keys.activate(key_addr, mappedKey);
}
DEPRECATED(LAYER_UPDATELIVECOMPOSITEKEYMAP)
static void updateLiveCompositeKeymap(KeyAddr key_addr) {}
#endif
static void updateActiveLayers(void); static void updateActiveLayers(void);
private: private:

@ -29,33 +29,6 @@
/* Messages */ /* Messages */
#define _DEPRECATED_MESSAGE_LAYER_UPDATELIVECOMPOSITEKEYMAP __NL__ \
"`Layer.updateLiveCompositeKeymap()` is deprecated.\n" __NL__ \
"The 'live composite keymap' cache has been replaced with the\n" __NL__ \
"'active keys' cache, which now represents the state of the active\n" __NL__ \
"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.\n" __NL__ \
"This function will be removed after 2021-08-01."
#define _DEPRECATED_MESSAGE_LAYER_EVENTHANDLER __NL__ \
"`Layer.eventHandler()` is deprecated.\n" __NL__ \
"Please use `Layer.handleKeymapKeyswitchEvent()` instead.\n" __NL__ \
"This function will be removed after 2021-08-01."
#define _DEPRECATED_MESSAGE_LAYER_HANDLE_KEYMAP_KEYSWITCH_EVENT __NL__ \
"`Layer.handleKeymapKeyswitchEvent()` is deprecated.\n" __NL__ \
"Please use `Layer.handleLayerKeyEvent()` instead.\n" __NL__ \
"This function will be removed after 2021-08-01."
#define _DEPRECATED_MESSAGE_LAYER_LOOKUP __NL__ \
"`Layer.lookup(key_addr)` is deprecated.\n" __NL__ \
"Please use `Runtime.lookupKey(key_addr)` instead. Alternatively, if you\n" __NL__ \
"need to look up the current keymap entry without regard to current live\n" __NL__ \
"key state(s) (i.e. the `live_keys` array, which normally overrides the\n" __NL__ \
"keymap), you can use `Layer.lookupOnActiveLayer(key_addr)`.\n" __NL__ \
"This function will be removed after 2021-08-01."
#define _DEPRECATED_MESSAGE_HANDLE_KEYSWITCH_EVENT __NL__ \ #define _DEPRECATED_MESSAGE_HANDLE_KEYSWITCH_EVENT __NL__ \
"`handleKeyswitchEvent()` has been deprecated.\n" __NL__ \ "`handleKeyswitchEvent()` has been deprecated.\n" __NL__ \
"Please use `Runtime.handleKeyEvent()` instead.\n" __NL__ \ "Please use `Runtime.handleKeyEvent()` instead.\n" __NL__ \

Loading…
Cancel
Save