From 07f65584d267b6df8877460d789fe352986e804e Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 10:40:01 -0600 Subject: [PATCH 01/14] Remove deprecated Model01-TestMode plugin Signed-off-by: Michael Richters --- docs/UPGRADING.md | 4 ++ .../library.properties | 8 ---- .../src/Kaleidoscope-Model01-TestMode.h | 23 --------- .../kaleidoscope/plugin/Model01-TestMode.h | 47 ------------------- 4 files changed, 4 insertions(+), 78 deletions(-) delete mode 100644 plugins/Kaleidoscope-Model01-TestMode/library.properties delete mode 100644 plugins/Kaleidoscope-Model01-TestMode/src/Kaleidoscope-Model01-TestMode.h delete mode 100644 plugins/Kaleidoscope-Model01-TestMode/src/kaleidoscope/plugin/Model01-TestMode.h diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 9c7ac354..a1b7d495 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1092,6 +1092,10 @@ Second, the `Layer.eventHandler()` function has been deprecated. There wasn't mu # Removed APIs +#### Model01-TestMode plugin + +This deprecated plugin was removed on **2022-03-03**. Please use the more generic HardwareTestMode plugin instead. + ### Removed on 2020-10-10 ### Deprecation of the HID facade diff --git a/plugins/Kaleidoscope-Model01-TestMode/library.properties b/plugins/Kaleidoscope-Model01-TestMode/library.properties deleted file mode 100644 index 1b6bc46d..00000000 --- a/plugins/Kaleidoscope-Model01-TestMode/library.properties +++ /dev/null @@ -1,8 +0,0 @@ -name=Kaleidoscope-Model01-TestMode -version=0.0.0 -sentence=A factory test mode for the Model 01. -#error The Kaleidoscope-Model01-TestMode plugin was designed for the Keyboardio Model01, and does not work with any other hardware. -maintainer=Kaleidoscope's Developers -url=https://github.com/keyboardio/Kaleidoscope -author=Keyboardio -paragraph= diff --git a/plugins/Kaleidoscope-Model01-TestMode/src/Kaleidoscope-Model01-TestMode.h b/plugins/Kaleidoscope-Model01-TestMode/src/Kaleidoscope-Model01-TestMode.h deleted file mode 100644 index f28c1bd4..00000000 --- a/plugins/Kaleidoscope-Model01-TestMode/src/Kaleidoscope-Model01-TestMode.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Kaleidoscope-Model01-TestMode -- A factory test mode for the Model 01. - * Copyright (C) 2017-2018 Keyboard.io, Inc. - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#pragma once - -#ifndef ARDUINO_AVR_MODEL01 -#error The Kaleidoscope-Model01-TestMode plugin was designed for the Keyboardio Model01, and does not work with any other hardware. -#endif - -#include "kaleidoscope/plugin/Model01-TestMode.h" diff --git a/plugins/Kaleidoscope-Model01-TestMode/src/kaleidoscope/plugin/Model01-TestMode.h b/plugins/Kaleidoscope-Model01-TestMode/src/kaleidoscope/plugin/Model01-TestMode.h deleted file mode 100644 index ac308cea..00000000 --- a/plugins/Kaleidoscope-Model01-TestMode/src/kaleidoscope/plugin/Model01-TestMode.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Kaleidoscope-Model01-TestMode - A factory test mode for the Model 01. - * Copyright (C) 2017-2018 Keyboard.io, Inc. - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#pragma once - -#ifdef KALEIDOSCOPE_VIRTUAL_BUILD -#error "Model01 testmode not available for virtual builds" -#else - -#ifdef ARDUINO_AVR_MODEL01 - -#include -#include "kaleidoscope/Runtime.h" -#include "kaleidoscope_internal/deprecations.h" - -#define _DEPRECATED_MESSAGE_MODEL01_TESTMODE \ - "The Model01-specific TestMode plugin has been deprecated in favour of\n" __NL__ \ - "the more generic HardwareTestMode. Please migrate to the new one." - -namespace kaleidoscope { -namespace plugin { - -class TestMode : public kaleidoscope::Plugin { - public: - DEPRECATED(MODEL01_TESTMODE) EventHandlerResult beforeReportingState() {} -}; -} -} - -extern kaleidoscope::plugin::TestMode TestMode; - -#endif - -#endif From f833b8f87957ef2917355b82d7c9d13399cfa81e Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 10:40:56 -0600 Subject: [PATCH 02/14] Remove deprecated EEPROM-Settings code Signed-off-by: Michael Richters --- docs/UPGRADING.md | 4 ++++ .../src/kaleidoscope/plugin/EEPROM-Settings.h | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index a1b7d495..8cf89a15 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1092,6 +1092,10 @@ Second, the `Layer.eventHandler()` function has been deprecated. There wasn't mu # Removed APIs +#### `EEPROMSettings.version(uint8_t version)` + +This deprecated function was removed on **2022-03-03**. The information stored is not longer intended for user code to set, but instead is used internally. + #### Model01-TestMode plugin This deprecated plugin was removed on **2022-03-03**. Please use the more generic HardwareTestMode plugin instead. diff --git a/plugins/Kaleidoscope-EEPROM-Settings/src/kaleidoscope/plugin/EEPROM-Settings.h b/plugins/Kaleidoscope-EEPROM-Settings/src/kaleidoscope/plugin/EEPROM-Settings.h index 566dfe79..18e0c07b 100644 --- a/plugins/Kaleidoscope-EEPROM-Settings/src/kaleidoscope/plugin/EEPROM-Settings.h +++ b/plugins/Kaleidoscope-EEPROM-Settings/src/kaleidoscope/plugin/EEPROM-Settings.h @@ -19,10 +19,6 @@ #include "kaleidoscope/Runtime.h" -#define _DEPRECATED_MESSAGE_EEPROMSETTINGS_VERSION_SET \ - "The EEPROMSettings.version(uint8_t version) method has been deprecated,\n" \ - "and is a no-op now. Please see the NEWS file for more information." - namespace kaleidoscope { namespace plugin { class EEPROMSettings : public kaleidoscope::Plugin { @@ -50,7 +46,6 @@ class EEPROMSettings : public kaleidoscope::Plugin { static uint8_t version(void) { return settings_.version; } - static void version(uint8_t) DEPRECATED(EEPROMSETTINGS_VERSION_SET) {} static uint16_t requestSlice(uint16_t size); static void seal(void); From c8ab42103a5c481ab51b3a01463ad033c68ca81d Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 10:07:18 -0600 Subject: [PATCH 03/14] Remove deprecated HostPowerManagement code Signed-off-by: Michael Richters --- docs/UPGRADING.md | 4 ++++ .../src/kaleidoscope/plugin/HostPowerManagement.h | 8 -------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 8cf89a15..93f2cc89 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1092,6 +1092,10 @@ Second, the `Layer.eventHandler()` function has been deprecated. There wasn't mu # Removed APIs +#### `HostPowerManagement.enableWakeup()` + +This deprecated function was removed on **2022-03-03**. The firmware now supports wakeup by default, so any references to it can be safely removed. + #### `EEPROMSettings.version(uint8_t version)` This deprecated function was removed on **2022-03-03**. The information stored is not longer intended for user code to set, but instead is used internally. diff --git a/plugins/Kaleidoscope-HostPowerManagement/src/kaleidoscope/plugin/HostPowerManagement.h b/plugins/Kaleidoscope-HostPowerManagement/src/kaleidoscope/plugin/HostPowerManagement.h index 6b8b9676..1540bc23 100644 --- a/plugins/Kaleidoscope-HostPowerManagement/src/kaleidoscope/plugin/HostPowerManagement.h +++ b/plugins/Kaleidoscope-HostPowerManagement/src/kaleidoscope/plugin/HostPowerManagement.h @@ -19,12 +19,6 @@ #include "kaleidoscope/Runtime.h" -#define _DEPRECATED_MESSAGE_ENABLEWAKEUP \ - "The HostPowerManagement.enableWakeup() call is not necessary anymore,\n" \ - "the firmware supports wakeup by default now. The line can be safely\n" \ - "removed.\n" \ - "This function will be removed after 2021-08-01." - namespace kaleidoscope { namespace plugin { class HostPowerManagement : public kaleidoscope::Plugin { @@ -37,8 +31,6 @@ class HostPowerManagement : public kaleidoscope::Plugin { HostPowerManagement(void) {} - void enableWakeup(void) DEPRECATED(ENABLEWAKEUP) {} - EventHandlerResult beforeEachCycle(); private: From 729431784648c4bb87dc25f3a6f711624f42c4f2 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 10:06:20 -0600 Subject: [PATCH 04/14] Remove deprecated OneShot code Signed-off-by: Michael Richters --- docs/UPGRADING.md | 54 +++++------ plugins/Kaleidoscope-OneShot/README.md | 36 -------- .../src/kaleidoscope/plugin/OneShot.cpp | 79 ---------------- .../src/kaleidoscope/plugin/OneShot.h | 90 ------------------- 4 files changed, 22 insertions(+), 237 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 93f2cc89..da28bef9 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -983,38 +983,6 @@ Older versions of the plugin were based on `Key` values; OneShot is now based on `KeyAddr` coordinates instead, in order to improve reliability and functionality. -The following deprecated functions and variables will be removed after -**2021-04-31**. - -#### Deprecated functions - -- `OneShot.inject(key, key_state)`: This `Key`-based function still works, but - because OneShot keys are now required to have a valid `KeyAddr`, it will now - look for an idle key, and use that, masking whatever value was mapped to that - key. Most of the reasons for using this function are better addressed by using - the newer features of the plugin, such as automatic one-shot modifiers. Use is - very strongly discouraged. -- `OneShot.isActive(key)`: This `Key`-based function no longer makes sense now - that OneShot is `KeyAddr`-based. There is a `OneShot.isActive(key_addr)` - function that should be used instead. The deprecated function still works, but - its use is discouraged. -- `OneShot.isSticky(key)`: This `Key`-based function no longer makes sense now - that OneShot is `KeyAddr`-based. There is a `OneShot.isSticky(key_addr)` - function that should be used instead. The deprecated function still works, but - its use is discouraged. -- `OneShot.isPressed()`: This function no longer has any reason for existing. In - older versions, the Escape-OneShot companion plugin used it to solve a problem - that no longer exists. It now always returns `false`. -- `OneShot.isModifierActive(key)`: This function still works, but is not - perfectly reliable, because it now returns positive results for keys other - than OneShot modifiers. It should not be used. - -#### Deprecated variables - -- `OneShot.time_out`: Use `OneShot.setTimeout()` instead. -- `OneShot.hold_time_out`: Use `OneShot.setHoldTimeout()` instead. -- `OneShot.double_tap_time_out`: Use `OneShot.setDoubleTapTimeout()` instead. - ### Qukeys Older versions of the plugin used `row` and `col` indexing for defining `Qukey` @@ -1092,6 +1060,28 @@ Second, the `Layer.eventHandler()` function has been deprecated. There wasn't mu # Removed APIs +#### OneShot public variables + +The following deprecated `OneShot` public variables were removed on **2022-03-03**. Please use the following methods instead: + + - For `OneShot.time_out`, use `OneShot.setTimeout(ms)` + - For `OneShot.hold_time_out`, use `OneShot.setHoldTimeout(ms)` + - For `OneShot.double_tap_time_out`, use `OneShot.setDoubleTapTimeout(ms)` + +#### Deprecated OneShot API functions + +OneShot was completely rewritten in early 2021, and now is based on `KeyAddr` values (as if it keeps physical keys pressed) rather than `Key` values (with no corresponding physical key location). This allows it to operate on any `Key` value, not just modifiers and layer shifts. + +The deprecated `OneShot.inject(key, key_state)` function was removed on **2022-03-03**. Its use was very strongly discouraged, and is now unavailable. See below for alternatives. + +The deprecated `OneShot.isActive(key)` function was removed on **2022-03-03**. There is a somewhat equivalent `OneShot.isActive(KeyAddr addr)` function to use when the address of a key that might be currently held active by OneShot is known. Any code that needs information about active keys is better served by not querying OneShot specifically. + +The deprecated `OneShot.isSticky(key)` function was removed on **2022-03-03**. There is a somewhat equivalent `OneShot.isStick(KeyAddr addr)` function to use when the address of a key that may be in the one-shot sticky state is known. + +The deprecated `OneShot.isPressed()` function was removed on **2022-03-03**. It was already devoid of functionality, and references to it can be safely removed. + +The deprecated `OneShot.isModifierActive(key)` function was removed on **2022-03-03**. OneShot modifiers are now indistinguishable from other modifier keys, so it is better for client code to do a more general search of `live_keys` or to use another mechanism for tracking this state. + #### `HostPowerManagement.enableWakeup()` This deprecated function was removed on **2022-03-03**. The firmware now supports wakeup by default, so any references to it can be safely removed. diff --git a/plugins/Kaleidoscope-OneShot/README.md b/plugins/Kaleidoscope-OneShot/README.md index 0b3e2725..c103a8c0 100644 --- a/plugins/Kaleidoscope-OneShot/README.md +++ b/plugins/Kaleidoscope-OneShot/README.md @@ -275,42 +275,6 @@ based on `Key` values; it has since be rewritten to be based on > not a one-shot key is still pressed any more. This function was > mainly used by LED-ActiveModColor, which no longer needs it. -## Plugin properties **[DEPRECATED]** - -Along with the methods listed above, the `OneShot` object has the -following properties, too. [Note: these have all been deprecated, -please use the `.set*Timeout()` methods above instead.] - -### `.time_out` - -> Set this property to the number of milliseconds to wait before timing out and -> cancelling the one-shot effect (unless interrupted or cancelled before by any -> other means). -> -> Defaults to 2500. - -### `.hold_time_out` - -> Set this property to the number of milliseconds to wait before considering a -> held one-shot key as intentionally held. In this case, the one-shot effect -> will not trigger when the key is released. In other words, holding a one-shot -> key at least this long, and then releasing it, will not trigger the one-shot -> effect. -> -> Defaults to 200. - -### `.double_tap_time_out` - -> Set this property to the number of milliseconds within which a second -> uninterrupted tap of the same one-shot key will be treated as a sticky-tap. -> Only takes effect when `.double_tap_sticky` is set. -> -> -> Setting the property to `-1` will make the double-tap timeout use `.time_out` -> for its calculations. -> -> Defaults to -1. - ## Dependencies * [Kaleidoscope-Ranges](Kaleidoscope-Ranges.md) diff --git a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp index eb239591..16e7c9ea 100644 --- a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp +++ b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp @@ -31,13 +31,6 @@ uint16_t OneShot::timeout_ = 2500; uint16_t OneShot::hold_timeout_ = 250; int16_t OneShot::double_tap_timeout_ = -1; -// Deprecated -#ifndef NDEPRECATED -uint16_t OneShot::time_out = 2500; -uint16_t OneShot::hold_time_out = 250; -int16_t OneShot::double_tap_time_out = -1; -#endif - // ---------------------------------------------------------------------------- // State variables @@ -333,16 +326,6 @@ EventHandlerResult OneShot::afterEachCycle() { start_time_ = Runtime.millisAtCycleStart(); } - // Temporary fix for deprecated variables -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - timeout_ = time_out; - hold_timeout_ = hold_time_out; - double_tap_timeout_ = double_tap_time_out; -#pragma GCC diagnostic pop -#endif - return EventHandlerResult::OK; } @@ -417,68 +400,6 @@ void OneShot::releaseKey(KeyAddr key_addr) { Runtime.handleKeyEvent(event); } -// ------------------------------------------------------------------------------ -// Deprecated functions -#ifndef NDEPRECATED -void OneShot::inject(Key key, uint8_t key_state) { - if (isOneShotKey(key)) { - key = decodeOneShotKey(key); - } - // Find an idle keyswitch to use for the injected OneShot key and activate - // it. This is an ugly hack, but it will work. It does mean that whatever key - // is used will be unavailable for its normal function until the injected - // OneShot key is deactivated, so use of `inject()` is strongly discouraged. - for (KeyAddr key_addr : KeyAddr::all()) { - if (live_keys[key_addr] == Key_Transparent) { - pressKey(key_addr, key); - glue_addrs_.set(key_addr); - break; - } - } -} - -bool OneShot::isModifierActive(Key key) { - // This actually works for any `Key` value, not just modifiers. Because we're - // just searching the keymap cache, it's also possible to return a false - // positive (a plugin might have altered the cache for an idle `KeyAddr`), or - // a false negative (a plugin might be inserting a modifier without a valid - // `KeyAddr`), but as this is a deprecated function, I think this is good - // enough. - for (KeyAddr key_addr : KeyAddr::all()) { - if (live_keys[key_addr] == key) { - return true; - } - } - return false; -} - -bool OneShot::isActive(Key key) { - if (isOneShotKey(key)) { - key = decodeOneShotKey(key); - } - for (KeyAddr key_addr : glue_addrs_) { - if (live_keys[key_addr] == key) { - return true; - } - } - return false; -} - -bool OneShot::isSticky(Key key) { - if (isOneShotKey(key)) { - key = decodeOneShotKey(key); - } - for (KeyAddr key_addr : glue_addrs_) { - if (live_keys[key_addr] == key && - !temp_addrs_.read(key_addr)) { - return true; - } - } - return false; -} -#endif - - } // namespace plugin } // namespace kaleidoscope diff --git a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h index 034dec5b..dbafc29b 100644 --- a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h +++ b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h @@ -22,46 +22,6 @@ #include "kaleidoscope/key_events.h" #include "kaleidoscope/KeyAddrBitfield.h" -// ---------------------------------------------------------------------------- -// Deprecation warning messages -#define _DEPRECATED_MESSAGE_ONESHOT_TIMEOUT \ - "The `OneShot.time_out` variable is deprecated. Please use the\n" \ - "`OneShot.setTimeout()` function instead.\n" \ - "This variable will be removed after 2021-08-01." - -#define _DEPRECATED_MESSAGE_ONESHOT_HOLD_TIMEOUT \ - "The `OneShot.hold_time_out` variable is deprecated. Please use the\n" \ - "`OneShot.setHoldTimeout()` function instead.\n" \ - "This variable will be removed after 2021-08-01." - -#define _DEPRECATED_MESSAGE_ONESHOT_DOUBLE_TAP_TIMEOUT \ - "The `OneShot.double_tap_time_out` variable is deprecated. Please use the\n" \ - "`OneShot.setDoubleTapTimeout()` function instead.\n" \ - "This variable will be removed after 2021-08-01." - -#define _DEPRECATED_MESSAGE_ONESHOT_INJECT \ - "The `OneShot.inject(key, key_state)` function has been deprecated.\n" \ - "This function will be removed after 2021-08-01." - -#define _DEPRECATED_MESSAGE_ONESHOT_ISACTIVE_KEY \ - "The `OneShot.isActive(key)` function is deprecated. Please use\n" \ - "`OneShot.isActive(key_addr)` instead, if possible.\n" \ - "This function will be removed after 2021-08-01." - -#define _DEPRECATED_MESSAGE_ONESHOT_ISSTICKY_KEY \ - "The `OneShot.isSticky(key)` function is deprecated. Please use\n" \ - "`OneShot.isSticky(key_addr)` instead, if possible.\n" \ - "This function will be removed after 2021-08-01." - -#define _DEPRECATED_MESSAGE_ONESHOT_ISPRESSED \ - "The `OneShot.isPressed()` function is deprecated. This function now\n" \ - "always returns false.\n" \ - "This function will be removed after 2021-08-01." - -#define _DEPRECATED_MESSAGE_ONESHOT_ISMODIFIERACTIVE \ - "The `OneShot.isModifierActive()` function is deprecated.\n" \ - "This function will be removed after 2021-08-01." - // ---------------------------------------------------------------------------- // Keymap macros @@ -195,68 +155,18 @@ class OneShot : public kaleidoscope::Plugin { // Utility function for other plugins to cancel OneShot keys static void cancel(bool with_stickies = false); - // -------------------------------------------------------------------------- - // Deprecated functions -#ifndef NDEPRECATED - DEPRECATED(ONESHOT_INJECT) - void inject(Key key, uint8_t key_state); - - DEPRECATED(ONESHOT_ISMODIFIERACTIVE) - static bool isModifierActive(Key key); - - DEPRECATED(ONESHOT_ISACTIVE_KEY) - static bool isActive(Key oneshot_key); - - DEPRECATED(ONESHOT_ISSTICKY_KEY) - static bool isSticky(Key oneshot_key); - - DEPRECATED(ONESHOT_ISPRESSED) - static bool isPressed() { - return false; - } -#endif - // -------------------------------------------------------------------------- // Timeout onfiguration functions static void setTimeout(uint16_t ttl) { timeout_ = ttl; -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - time_out = ttl; -#pragma GCC diagnostic pop -#endif } static void setHoldTimeout(uint16_t ttl) { hold_timeout_ = ttl; -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - hold_time_out = ttl; -#pragma GCC diagnostic pop -#endif } static void setDoubleTapTimeout(int16_t ttl) { double_tap_timeout_ = ttl; -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - double_tap_time_out = ttl; -#pragma GCC diagnostic pop -#endif } - // -------------------------------------------------------------------------- - // Configuration variables (should probably be private) -#ifndef NDEPRECATED - DEPRECATED(ONESHOT_TIMEOUT) - static uint16_t time_out; - DEPRECATED(ONESHOT_HOLD_TIMEOUT) - static uint16_t hold_time_out; - DEPRECATED(ONESHOT_DOUBLE_TAP_TIMEOUT) - static int16_t double_tap_time_out; -#endif - // -------------------------------------------------------------------------- // Plugin hook functions From 7b1d45d1fba849095aef1aef2e16090e7aee9c03 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 10:06:52 -0600 Subject: [PATCH 05/14] Remove deprecated LED-ActiveModColor code Signed-off-by: Michael Richters --- docs/UPGRADING.md | 8 ++++ .../plugin/LED-ActiveModColor.cpp | 16 +++----- .../kaleidoscope/plugin/LED-ActiveModColor.h | 38 ++++--------------- 3 files changed, 21 insertions(+), 41 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index da28bef9..d41f23be 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1060,6 +1060,14 @@ Second, the `Layer.eventHandler()` function has been deprecated. There wasn't mu # Removed APIs +#### ActiveModColor public variables + +The following deprecated `ActiveModColorEffect` public variables were removed on **2022-03-03**. Please use the following methods instead: + + - For `ActiveModColor.highlight_color`, use `ActiveModColor.setHighlightColor(color)` + - For `ActiveModColor.oneshot_color`, use `ActiveModColor.setOneShotColor(color)` + - For `ActiveModColor.sticky_color`, use `ActiveModColor.setStickyColor(color)` + #### OneShot public variables The following deprecated `OneShot` public variables were removed on **2022-03-03**. Please use the following methods instead: diff --git a/plugins/Kaleidoscope-LED-ActiveModColor/src/kaleidoscope/plugin/LED-ActiveModColor.cpp b/plugins/Kaleidoscope-LED-ActiveModColor/src/kaleidoscope/plugin/LED-ActiveModColor.cpp index ac1e55a8..f0891d70 100644 --- a/plugins/Kaleidoscope-LED-ActiveModColor/src/kaleidoscope/plugin/LED-ActiveModColor.cpp +++ b/plugins/Kaleidoscope-LED-ActiveModColor/src/kaleidoscope/plugin/LED-ActiveModColor.cpp @@ -28,9 +28,9 @@ namespace plugin { KeyAddrBitfield ActiveModColorEffect::mod_key_bits_; bool ActiveModColorEffect::highlight_normal_modifiers_ = true; -cRGB ActiveModColorEffect::highlight_color = CRGB(160, 160, 160); -cRGB ActiveModColorEffect::oneshot_color = CRGB(160, 160, 0); -cRGB ActiveModColorEffect::sticky_color = CRGB(160, 0, 0); +cRGB ActiveModColorEffect::highlight_color_ = CRGB(160, 160, 160); +cRGB ActiveModColorEffect::oneshot_color_ = CRGB(160, 160, 0); +cRGB ActiveModColorEffect::sticky_color_ = CRGB(160, 0, 0); // ----------------------------------------------------------------------------- EventHandlerResult ActiveModColorEffect::onKeyEvent(KeyEvent &event) { @@ -81,20 +81,16 @@ EventHandlerResult ActiveModColorEffect::beforeSyncingLeds() { // This loop iterates through only the `key_addr`s that have their bits in the // `mod_key_bits_` bitfield set. for (KeyAddr key_addr : mod_key_bits_) { - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" if (::OneShot.isTemporary(key_addr)) { // Temporary OneShot keys get one color: - ::LEDControl.setCrgbAt(key_addr, oneshot_color); + ::LEDControl.setCrgbAt(key_addr, oneshot_color_); } else if (::OneShot.isSticky(key_addr)) { // Sticky OneShot keys get another color: - ::LEDControl.setCrgbAt(key_addr, sticky_color); + ::LEDControl.setCrgbAt(key_addr, sticky_color_); } else if (highlight_normal_modifiers_) { // Normal modifiers get a third color: - ::LEDControl.setCrgbAt(key_addr, highlight_color); + ::LEDControl.setCrgbAt(key_addr, highlight_color_); } -#pragma GCC diagnostic pop } return EventHandlerResult::OK; diff --git a/plugins/Kaleidoscope-LED-ActiveModColor/src/kaleidoscope/plugin/LED-ActiveModColor.h b/plugins/Kaleidoscope-LED-ActiveModColor/src/kaleidoscope/plugin/LED-ActiveModColor.h index 3e5124b1..3f127869 100644 --- a/plugins/Kaleidoscope-LED-ActiveModColor/src/kaleidoscope/plugin/LED-ActiveModColor.h +++ b/plugins/Kaleidoscope-LED-ActiveModColor/src/kaleidoscope/plugin/LED-ActiveModColor.h @@ -23,48 +23,20 @@ #define MAX_MODS_PER_LAYER 16 -// ============================================================================= -#define _DEPRECATED_MESSAGE_ACTIVEMODCOLOR_COLORS \ - "The `ActiveModColorEffect` public class variables have been deprecated. \n" \ - "Please use the following methods instead: \n" \ - " - for `highlight_color` => `setHighlightColor(color)` \n" \ - " - for `oneshot_color` => `setOneShotColor(color)` \n" \ - " - for `sticky_color` => `setStickyColor(color)` \n" \ - "These variables will be removed after 2021-08-01." - namespace kaleidoscope { namespace plugin { class ActiveModColorEffect : public kaleidoscope::Plugin { public: ActiveModColorEffect(void) {} - // When removing access to these variables, don't delete them. Instead, make - // them private, and add trailing underscores here and in - // LED-ActiveModColor.cpp. - DEPRECATED(ACTIVEMODCOLOR_COLORS) - static cRGB highlight_color; - DEPRECATED(ACTIVEMODCOLOR_COLORS) - static cRGB oneshot_color; - DEPRECATED(ACTIVEMODCOLOR_COLORS) - static cRGB sticky_color; - static void setHighlightColor(cRGB color) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - highlight_color = color; -#pragma GCC diagnostic pop + highlight_color_ = color; } static void setOneShotColor(cRGB color) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - oneshot_color = color; -#pragma GCC diagnostic pop + oneshot_color_ = color; } static void setOnestickyColor(cRGB color) { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - sticky_color = color; -#pragma GCC diagnostic pop + sticky_color_ = color; } static void highlightNormalModifiers(bool value) { @@ -77,6 +49,10 @@ class ActiveModColorEffect : public kaleidoscope::Plugin { private: static bool highlight_normal_modifiers_; static KeyAddrBitfield mod_key_bits_; + + static cRGB highlight_color_; + static cRGB oneshot_color_; + static cRGB sticky_color_; }; } } From 6ee45396544306ba2042d8826e3c45939ea012b6 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 10:41:20 -0600 Subject: [PATCH 06/14] Remove deprecated Macros code Signed-off-by: Michael Richters --- docs/UPGRADING.md | 18 +++++ .../src/kaleidoscope/plugin/Macros.cpp | 49 ------------- .../src/kaleidoscope/plugin/Macros.h | 68 ------------------- .../kaleidoscope/plugin/Macros/MacroSteps.h | 5 -- 4 files changed, 18 insertions(+), 122 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index d41f23be..1a282eaa 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1060,6 +1060,24 @@ Second, the `Layer.eventHandler()` function has been deprecated. There wasn't mu # Removed APIs +#### Obsolete active macros array removed + +The deprecated `Macros.active_macro_count` variable was removed on **2022-03-03**. Any references to it are obsolete, and can simply be removed. + +The deprecated `Macros.active_macros[]` array was removed on **2022-03-03**. Any references to it are obsolete, and can simply be removed. + +The deprecated `Macros.addActiveMacroKey()` function was removed on **2022-03-03**. Any references to it are obsolete, and can simply be removed. + +#### Pre-`KeyEvent` Macros API + +This is a brief summary of specific elements that were removed. There is a more comprehensive guide to upgrading existing Macros user code in the [Breaking Changes](#breaking-changes) section, under [Macros](#macros). + +Support for deprecated form of the `macroAction(uint8_t macro_id, uint8_t key_state)` function was removed on **2022-03-03**. This old form must be replaced with the new `macroAction(uint8_t macro_id, KeyEvent &event)` for macros to continue working. + +The `Macros.key_addr` public variable was removed on **2022-03-03**. To get access to the key address of a Macros key event, simply refer to `event.addr` from within the new `macroAction(macro_id, event)` function. + +The deprecated `MACRODOWN()` preprocessor macro was removed on **2022-03-03**. Since most macros are meant to be triggered only by keypress events (not key release), and because `macroAction()` does not get called every cycle for held keys, it's better to simply do one test for `keyToggledOn(event.state)` first, then use `MACRO()` instead. + #### ActiveModColor public variables The following deprecated `ActiveModColorEffect` public variables were removed on **2022-03-03**. Please use the following methods instead: diff --git a/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.cpp b/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.cpp index c70e936f..7cbc000b 100644 --- a/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.cpp +++ b/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.cpp @@ -26,22 +26,6 @@ const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { return MACRO_NONE; } -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -__attribute__((weak)) -const macro_t *macroAction(uint8_t macro_id, uint8_t key_state) { - return MACRO_NONE; -} - -const macro_t* deprecatedMacroDown(uint8_t key_state, const macro_t* macro_p) { - if (keyToggledOn(key_state)) - return macro_p; - return MACRO_NONE; -} -#pragma GCC diagnostic pop -#endif - // ============================================================================= // `Macros` plugin code namespace kaleidoscope { @@ -53,15 +37,6 @@ constexpr uint8_t release_state = WAS_PRESSED | INJECTED; // Initialized to zeroes (i.e. `Key_NoKey`) Key Macros::active_macro_keys_[]; -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -MacroKeyEvent Macros::active_macros[]; -byte Macros::active_macro_count; -KeyAddr Macros::key_addr = KeyAddr::none(); -#pragma GCC diagnostic pop -#endif - // ----------------------------------------------------------------------------- // Public helper functions @@ -311,36 +286,12 @@ EventHandlerResult Macros::onKeyEvent(KeyEvent &event) { if (!isMacrosKey(event.key)) return EventHandlerResult::OK; -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - // Set `Macros.key_addr` so that code in the `macroAction()` function can have - // access to it. This is not such a good solution, but it's done this way for - // backwards compatability. At some point, we should introduce a new - // `macroAction(KeyEvent)` function. - if (event.addr.isValid()) { - key_addr = event.addr; - } else { - key_addr = KeyAddr::none(); - } -#pragma GCC diagnostic pop -#endif - // Decode the macro ID from the Macros `Key` value. uint8_t macro_id = event.key.getRaw() - ranges::MACRO_FIRST; // Call the new `macroAction(event)` function. const macro_t* macro_ptr = macroAction(macro_id, event); -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - // If the new `macroAction()` returned nothing, try the legacy version. - if (macro_ptr == MACRO_NONE) - macro_ptr = macroAction(macro_id, event.state); -#pragma GCC diagnostic pop -#endif - // Play back the macro pointed to by `macroAction()` play(macro_ptr); diff --git a/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.h b/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.h index 3847ebef..d6e2ad8d 100644 --- a/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.h +++ b/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.h @@ -23,67 +23,10 @@ #include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/key_events.h" -// ============================================================================= -// Deprecated Macros code -#ifndef NDEPRECATED - -#define _DEPRECATED_MESSAGE_MACROS_ACTIVE_MACRO_COUNT __NL__ \ - "The `Macros.active_macro_count` variable is deprecated. It no longer has\n" __NL__ \ - "any functional purpose, and can be safely removed from your code." - -#define _DEPRECATED_MESSAGE_MACROS_ACTIVE_MACROS __NL__ \ - "The `Macros.active_macros` array is deprecated. It no longer serves any\n" __NL__ \ - "functional purpose, and can be safely removed from your code." - -#define _DEPRECATED_MESSAGE_MACROS_ADD_ACTIVE_MACRO_KEY __NL__ \ - "The `Macros.addActiveMacroKey()` function is deprecated. It no longer\n" __NL__ \ - "has any functional purpose, and can be safely removed from your code." - -#define _DEPRECATED_MESSAGE_MACRO_ACTION_FUNCTION_V1 __NL__ \ - "The old `macroAction(macro_id, key_state)` is deprecated.\n" __NL__ \ - "Please define the new `macroAction()` function instead:\n" __NL__ \ - "\n" __NL__ \ - "const macro_t* macroAction(uint8_t macro_id, KeyEvent &event);\n" __NL__ \ - "\n" __NL__ \ - "In the body of the new function, replace the `key_state` value with\n" __NL__ \ - "`event.state`. Also, note that the new function gives you access to the\n" __NL__ \ - "`KeyAddr` of the Macros key event (`event.addr`), and the `Key` value\n" __NL__ \ - "(`event.key`). Because the event is passed by reference, it is now\n" __NL__ \ - "possible to assign to `event.key` on a toggled-on event, causing that\n" __NL__ \ - "`Key` value to persist after the macro finishes playing, leaving that\n" __NL__ \ - "value active until the key is released." - -#define _DEPRECATED_MESSAGE_MACROS_KEY_ADDR __NL__ \ - "The `Macros.key_addr` public variable is deprecated.\n" __NL__ \ - "Instead of using this to get the `KeyAddr` of the current macro from\n" __NL__ \ - "`macroAction()`, please use the new version of `macroAction()`, which\n" __NL__ \ - "uses a `KeyEvent` as its second parameter, giving access to the address\n" __NL__ \ - "of the event in the `event.addr` member variable." - -#define _DEPRECATED_MESSAGE_MACROS_MACRODOWN __NL__ \ - "The `MACRODOWN()` preprocessor macro is deprecated. Please use `MACRO()`\n" __NL__ \ - "with a test for `keyToggledOn(event.state)` instead." - -DEPRECATED(MACROS_MACRODOWN) -const macro_t* deprecatedMacroDown(uint8_t key_state, const macro_t* macro_p); - -#endif - // ============================================================================= // Define this function in a Kaleidoscope sketch in order to trigger Macros. const macro_t* macroAction(uint8_t macro_id, KeyEvent &event); -#ifndef NDEPRECATED -DEPRECATED(MACRO_ACTION_FUNCTION_V1) -const macro_t* macroAction(uint8_t macro_id, uint8_t key_state); - -struct MacroKeyEvent { - byte key_code; - byte key_id; - byte key_state; -}; -#endif - // The number of simultaneously-active `Key` values that a macro can have // running during a call to `Macros.play()`. I don't know if it's actually // possible to override this by defining it in a sketch before including @@ -161,17 +104,6 @@ class Macros : public kaleidoscope::Plugin { return false; } -#ifndef NDEPRECATED - public: - DEPRECATED(MACROS_ACTIVE_MACROS) - static MacroKeyEvent active_macros[0]; - DEPRECATED(MACROS_ACTIVE_MACRO_COUNT) - static uint8_t active_macro_count; - DEPRECATED(MACROS_ADD_ACTIVE_MACRO_KEY) - static void addActiveMacroKey(uint8_t macro_id, KeyAddr key_addr, uint8_t key_state) {} - DEPRECATED(MACROS_KEY_ADDR) - static KeyAddr key_addr; -#endif }; } // namespace plugin diff --git a/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros/MacroSteps.h b/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros/MacroSteps.h index 549c4108..dbf8ae97 100644 --- a/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros/MacroSteps.h +++ b/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros/MacroSteps.h @@ -52,11 +52,6 @@ typedef uint8_t macro_t; &__m[0]; \ }) -#ifndef NDEPRECATED -#define MACRODOWN(...) \ - deprecatedMacroDown(event.state, MACRO(__VA_ARGS__)); -#endif - #define I(n) MACRO_ACTION_STEP_INTERVAL, n #define W(n) MACRO_ACTION_STEP_WAIT, n From b57daf53a82dde35f618ae2f8850c759b2565f0e Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 14:35:41 -0600 Subject: [PATCH 07/14] Remove deprecated LEDControl code Signed-off-by: Michael Richters --- docs/UPGRADING.md | 4 ++++ src/kaleidoscope/plugin/LEDControl.cpp | 11 ----------- src/kaleidoscope/plugin/LEDControl.h | 19 ------------------- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 1a282eaa..3af85881 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1060,6 +1060,10 @@ Second, the `Layer.eventHandler()` function has been deprecated. There wasn't mu # Removed APIs +#### `LEDControl.syncDelay` configuration variable + +Direct access to this configuration variable was removed on **2022-03-03**. Please use `LEDControl.setInterval()` to set the interval between LED updates instead. + #### Obsolete active macros array removed The deprecated `Macros.active_macro_count` variable was removed on **2022-03-03**. Any references to it are obsolete, and can simply be removed. diff --git a/src/kaleidoscope/plugin/LEDControl.cpp b/src/kaleidoscope/plugin/LEDControl.cpp index 18a0d67a..98ff2720 100644 --- a/src/kaleidoscope/plugin/LEDControl.cpp +++ b/src/kaleidoscope/plugin/LEDControl.cpp @@ -37,11 +37,6 @@ LEDControl::LEDControl(void) { uint8_t LEDControl::sync_interval_ = 32; uint16_t LEDControl::last_sync_time_ = 0; -#ifndef NDEPRECATED -uint8_t LEDControl::syncDelay = LEDControl::sync_interval_; -#endif - - void LEDControl::next_mode() { ++mode_id_; @@ -203,12 +198,6 @@ EventHandlerResult LEDControl::afterEachCycle() { return EventHandlerResult::OK; if (Runtime.hasTimeExpired(last_sync_time_, sync_interval_)) { -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - sync_interval_ = syncDelay; -#pragma GCC diagnostic pop -#endif syncLeds(); last_sync_time_ += sync_interval_; update(); diff --git a/src/kaleidoscope/plugin/LEDControl.h b/src/kaleidoscope/plugin/LEDControl.h index 99ba7a0c..a3f04b6e 100644 --- a/src/kaleidoscope/plugin/LEDControl.h +++ b/src/kaleidoscope/plugin/LEDControl.h @@ -19,14 +19,6 @@ #include "kaleidoscope/Runtime.h" #include "kaleidoscope/plugin/LEDMode.h" -#ifndef NDEPRECATED - -#define _DEPRECATED_MESSAGE_LEDCONTROL_SYNCDELAY __NL__ \ - "The `LEDControl.syncDelay` variable has been deprecated.\n" __NL__ \ - "Please use the `LEDControl.setInterval()` function instead." - -#endif - #define LED_TOGGLE 0b00000001 // Synthetic, internal #define Key_LEDEffectNext Key(0, KEY_FLAGS | SYNTHETIC | IS_INTERNAL | LED_TOGGLE) @@ -100,19 +92,8 @@ class LEDControl : public kaleidoscope::Plugin { // static void activate(LEDModeInterface *plugin); -#ifndef NDEPRECATED - DEPRECATED(LEDCONTROL_SYNCDELAY) - static uint8_t syncDelay; -#endif - static void setSyncInterval(uint8_t interval) { sync_interval_ = interval; -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - syncDelay = interval; -#pragma GCC diagnostic pop -#endif } EventHandlerResult onSetup(); From d0542ac6ebb7a663c14ca3e5c03b9b8e579a8cdb Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 23:11:51 -0600 Subject: [PATCH 08/14] 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 --- docs/UPGRADING.md | 14 ++++++---- src/kaleidoscope/layers.cpp | 13 --------- src/kaleidoscope/layers.h | 34 ------------------------ src/kaleidoscope_internal/deprecations.h | 27 ------------------- 4 files changed, 9 insertions(+), 79 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 3af85881..6de349c1 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -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`. - [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 diff --git a/src/kaleidoscope/layers.cpp b/src/kaleidoscope/layers.cpp index 68676e61..b7ff8c55 100644 --- a/src/kaleidoscope/layers.cpp +++ b/src/kaleidoscope/layers.cpp @@ -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) { return keyFromKeymap(layer, key_addr); } diff --git a/src/kaleidoscope/layers.h b/src/kaleidoscope/layers.h index 3f38cdd2..9428cc28 100644 --- a/src/kaleidoscope/layers.h +++ b/src/kaleidoscope/layers.h @@ -26,10 +26,6 @@ #include "kaleidoscope_internal/shortname.h" #include "kaleidoscope_internal/deprecations.h" -#ifndef NDEPRECATED -#include "kaleidoscope/LiveKeys.h" -#endif - #define START_KEYMAPS __NL__ \ 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 // 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) { uint8_t layer = active_layer_keymap_[key_addr.toInt()]; return (*getKey)(layer, key_addr); @@ -115,28 +98,11 @@ class Layer_ { 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); static GetKeyFunction getKey; 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); private: diff --git a/src/kaleidoscope_internal/deprecations.h b/src/kaleidoscope_internal/deprecations.h index 09748cd9..fa6e9402 100644 --- a/src/kaleidoscope_internal/deprecations.h +++ b/src/kaleidoscope_internal/deprecations.h @@ -29,33 +29,6 @@ /* 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__ \ "`handleKeyswitchEvent()` has been deprecated.\n" __NL__ \ "Please use `Runtime.handleKeyEvent()` instead.\n" __NL__ \ From 340d422a242213aede81ef3cc384316aa27a4a06 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 23:05:44 -0600 Subject: [PATCH 09/14] Remove deprecated `pressKey(key, toggled_on)` function This function was mainly intended for internal use by Kaleidoscope's event handling functions. The logic that it used to provide is now handled by `Runtime.handleKeyEvent()`, and it is not generally necessary or recommended for plugin or sketch code to directly modify HID reports any longer. Signed-off-by: Michael Richters --- docs/UPGRADING.md | 4 ++++ src/kaleidoscope/driver/hid/base/Keyboard.h | 5 ----- src/kaleidoscope_internal/deprecations.h | 8 -------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 6de349c1..6071c48c 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1052,6 +1052,10 @@ The following headers and names have changed: # Removed APIs +#### `Keyboard::pressKey(Key key, bool toggled_on)` + +This deprecated function was removed on **2022-03-03**. Its purpose was to handle rollover events for keys that include modifier flags, and that handling is now done elsewhere. Any code that called it should now simply call `Keyboard::pressKey(Key key)` instead, dropping the second argument. + #### Old layer key event handler functions 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. diff --git a/src/kaleidoscope/driver/hid/base/Keyboard.h b/src/kaleidoscope/driver/hid/base/Keyboard.h index ede60f4d..c7aac2a8 100644 --- a/src/kaleidoscope/driver/hid/base/Keyboard.h +++ b/src/kaleidoscope/driver/hid/base/Keyboard.h @@ -178,11 +178,6 @@ class Keyboard { } } - DEPRECATED(HID_KEYBOARD_PRESSKEY_TOGGLEDON) - void pressKey(Key pressed_key, bool toggled_on) __attribute__((noinline)) { - pressKey(pressed_key); - } - void pressKey(Key pressed_key) __attribute__((noinline)) { pressModifiers(pressed_key); pressRawKey(pressed_key); diff --git a/src/kaleidoscope_internal/deprecations.h b/src/kaleidoscope_internal/deprecations.h index fa6e9402..b5e31ddd 100644 --- a/src/kaleidoscope_internal/deprecations.h +++ b/src/kaleidoscope_internal/deprecations.h @@ -51,11 +51,3 @@ "every scan cycle, it should be moved to the `afterEachCycle()` event\n" __NL__ \ "handler instead.\n" __NL__ \ "This function will be removed after 2021-08-01." - -#define _DEPRECATED_MESSAGE_HID_KEYBOARD_PRESSKEY_TOGGLEDON __NL__ \ - "The `Keyboard::pressKey(key, toggled_on)` function is deprecated.\n" __NL__ \ - "Please use `Keyboard::pressKey(key)` without the second argument\n" __NL__ \ - "instead. The version with two arguments handled rollover events, and\n" __NL__ \ - "this is now handled more completely by the event handling functions in\n" __NL__ \ - "`Runtime`.\n" __NL__ \ - "This function will be removed after 2021-08-01." From 3152270585563e8477a9c1fe89ac2c1efa1fc8fd Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 14:26:52 -0600 Subject: [PATCH 10/14] Remove deprecated `handleKeyswitchEvent()` function This removes the `key_events.*` files that once contained the main `handleKeyswitchEvent()` function, and all references to it. Because `key_events.h` was included in the main `Kaleidoscope.h` header file, `key_defs.h` and `keyswitch_state.h` were added to that header so that other code that relies on those things being included via `Kaleidoscope.h` will continue to work. Signed-off-by: Michael Richters --- docs/UPGRADING.md | 4 + .../src/kaleidoscope/plugin/Cycle.cpp | 1 - .../src/kaleidoscope/plugin/DynamicMacros.cpp | 1 - .../device/keyboardio/Model01.cpp | 1 - .../device/keyboardio/Model100.cpp | 1 - .../src/kaleidoscope/plugin/Leader.cpp | 1 - .../src/kaleidoscope/plugin/Macros.cpp | 1 - .../src/kaleidoscope/plugin/Macros.h | 1 - .../src/kaleidoscope/plugin/OneShot.cpp | 1 - .../src/kaleidoscope/plugin/OneShot.h | 1 - .../src/kaleidoscope/plugin/SpaceCadet.cpp | 1 - .../src/kaleidoscope/plugin/Syster.cpp | 1 - src/Kaleidoscope.h | 3 +- src/kaleidoscope/hooks.h | 9 --- src/kaleidoscope/key_events.cpp | 34 --------- src/kaleidoscope/key_events.h | 74 ------------------- src/kaleidoscope_internal/deprecations.h | 5 -- 17 files changed, 6 insertions(+), 134 deletions(-) delete mode 100644 src/kaleidoscope/key_events.cpp delete mode 100644 src/kaleidoscope/key_events.h diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 6071c48c..a3aa5d03 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1052,6 +1052,10 @@ The following headers and names have changed: # Removed APIs +#### `::handleKeyswitchEvent(Key key, KeyAddr key_addr, uint8_t state)` + +The old master function for processing key "events" was removed on **2022-03-03**. Functions that were calling this function should be rewritten to call `kaleidoscope::Runtime.handleKeyEvent(KeyEvent event)` instead. + #### `Keyboard::pressKey(Key key, bool toggled_on)` This deprecated function was removed on **2022-03-03**. Its purpose was to handle rollover events for keys that include modifier flags, and that handling is now done elsewhere. Any code that called it should now simply call `Keyboard::pressKey(Key key)` instead, dropping the second argument. diff --git a/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.cpp b/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.cpp index 31a6211d..bbfad444 100644 --- a/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.cpp +++ b/plugins/Kaleidoscope-Cycle/src/kaleidoscope/plugin/Cycle.cpp @@ -19,7 +19,6 @@ #include #include #include "kaleidoscope/keyswitch_state.h" -#include "kaleidoscope/key_events.h" namespace kaleidoscope { namespace plugin { diff --git a/plugins/Kaleidoscope-DynamicMacros/src/kaleidoscope/plugin/DynamicMacros.cpp b/plugins/Kaleidoscope-DynamicMacros/src/kaleidoscope/plugin/DynamicMacros.cpp index 9b4a6e43..2285a857 100644 --- a/plugins/Kaleidoscope-DynamicMacros/src/kaleidoscope/plugin/DynamicMacros.cpp +++ b/plugins/Kaleidoscope-DynamicMacros/src/kaleidoscope/plugin/DynamicMacros.cpp @@ -17,7 +17,6 @@ #include "Kaleidoscope-DynamicMacros.h" #include "Kaleidoscope-FocusSerial.h" #include "kaleidoscope/keyswitch_state.h" -#include "kaleidoscope/key_events.h" namespace kaleidoscope { namespace plugin { diff --git a/plugins/Kaleidoscope-Hardware-Keyboardio-Model01/src/kaleidoscope/device/keyboardio/Model01.cpp b/plugins/Kaleidoscope-Hardware-Keyboardio-Model01/src/kaleidoscope/device/keyboardio/Model01.cpp index 61681091..0fb2e820 100644 --- a/plugins/Kaleidoscope-Hardware-Keyboardio-Model01/src/kaleidoscope/device/keyboardio/Model01.cpp +++ b/plugins/Kaleidoscope-Hardware-Keyboardio-Model01/src/kaleidoscope/device/keyboardio/Model01.cpp @@ -19,7 +19,6 @@ #include "Arduino.h" // for PROGMEM #include "kaleidoscope/device/keyboardio/Model01.h" // for Model01LEDDriver... -#include "kaleidoscope/key_events.h" #include "kaleidoscope/driver/keyscanner/Base_Impl.h" #ifndef KALEIDOSCOPE_VIRTUAL_BUILD diff --git a/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.cpp b/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.cpp index f13b5fdd..ea0f2a8e 100644 --- a/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.cpp +++ b/plugins/Kaleidoscope-Hardware-Keyboardio-Model100/src/kaleidoscope/device/keyboardio/Model100.cpp @@ -19,7 +19,6 @@ #include "Arduino.h" // for PROGMEM #include "kaleidoscope/device/keyboardio/Model100.h" // for Model100LEDDriver... -#include "kaleidoscope/key_events.h" #include "kaleidoscope/driver/keyscanner/Base_Impl.h" #include "Wire.h" diff --git a/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp b/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp index edad67b5..3e7c833c 100644 --- a/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp +++ b/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp @@ -19,7 +19,6 @@ #include #include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h" -#include "kaleidoscope/key_events.h" #include "kaleidoscope/KeyEventTracker.h" namespace kaleidoscope { diff --git a/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.cpp b/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.cpp index 7cbc000b..f34c0271 100644 --- a/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.cpp +++ b/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.cpp @@ -17,7 +17,6 @@ #include "Kaleidoscope-Macros.h" #include "Kaleidoscope-FocusSerial.h" #include "kaleidoscope/keyswitch_state.h" -#include "kaleidoscope/key_events.h" // ============================================================================= // Default `macroAction()` function definitions diff --git a/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.h b/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.h index d6e2ad8d..b3ecf060 100644 --- a/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.h +++ b/plugins/Kaleidoscope-Macros/src/kaleidoscope/plugin/Macros.h @@ -21,7 +21,6 @@ #include "kaleidoscope/plugin/Macros/MacroKeyDefs.h" #include "kaleidoscope/plugin/Macros/MacroSteps.h" #include "kaleidoscope/keyswitch_state.h" -#include "kaleidoscope/key_events.h" // ============================================================================= // Define this function in a Kaleidoscope sketch in order to trigger Macros. diff --git a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp index 16e7c9ea..2b4bc94f 100644 --- a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp +++ b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp @@ -18,7 +18,6 @@ #include #include #include "kaleidoscope/keyswitch_state.h" -#include "kaleidoscope/key_events.h" #include "kaleidoscope/layers.h" namespace kaleidoscope { diff --git a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h index dbafc29b..a8961991 100644 --- a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h +++ b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.h @@ -19,7 +19,6 @@ #include "kaleidoscope/Runtime.h" #include -#include "kaleidoscope/key_events.h" #include "kaleidoscope/KeyAddrBitfield.h" // ---------------------------------------------------------------------------- diff --git a/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.cpp b/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.cpp index 4bdcb951..d377bd75 100644 --- a/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.cpp +++ b/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.cpp @@ -19,7 +19,6 @@ #include #include #include "kaleidoscope/keyswitch_state.h" -#include "kaleidoscope/key_events.h" //#include diff --git a/plugins/Kaleidoscope-Syster/src/kaleidoscope/plugin/Syster.cpp b/plugins/Kaleidoscope-Syster/src/kaleidoscope/plugin/Syster.cpp index 070e0245..59d42728 100644 --- a/plugins/Kaleidoscope-Syster/src/kaleidoscope/plugin/Syster.cpp +++ b/plugins/Kaleidoscope-Syster/src/kaleidoscope/plugin/Syster.cpp @@ -18,7 +18,6 @@ #include #include #include "kaleidoscope/keyswitch_state.h" -#include "kaleidoscope/key_events.h" #undef SYSTER diff --git a/src/Kaleidoscope.h b/src/Kaleidoscope.h index bf457698..6f18da6c 100644 --- a/src/Kaleidoscope.h +++ b/src/Kaleidoscope.h @@ -81,7 +81,8 @@ void setup(); #include "kaleidoscope/KeyAddr.h" #include "kaleidoscope/KeyEvent.h" -#include "kaleidoscope/key_events.h" +#include "kaleidoscope/key_defs.h" +#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/layers.h" #include "kaleidoscope_internal/sketch_exploration/sketch_exploration.h" #include "kaleidoscope/macro_map.h" diff --git a/src/kaleidoscope/hooks.h b/src/kaleidoscope/hooks.h index cda1710e..58faed8e 100644 --- a/src/kaleidoscope/hooks.h +++ b/src/kaleidoscope/hooks.h @@ -30,9 +30,6 @@ class Key; // Forward declaration required to enable friend declarations // in class Hooks. class kaleidoscope_; -#ifndef NDEPRECATED -extern void handleKeyswitchEvent(kaleidoscope::Key mappedKey, KeyAddr key_addr, uint8_t keyState); -#endif namespace kaleidoscope { namespace plugin { @@ -70,12 +67,6 @@ class Hooks { friend class ::kaleidoscope::plugin::LEDControl; friend void ::kaleidoscope::sketch_exploration::pluginsExploreSketch(); -#ifndef NDEPRECATED - // ::handleKeyswitchEvent(...) calls Hooks::onKeyswitchEvent. - friend void ::handleKeyswitchEvent(kaleidoscope::Key mappedKey, - KeyAddr key_addr, uint8_t keyState); -#endif - private: // The following private functions are just to be called by classes diff --git a/src/kaleidoscope/key_events.cpp b/src/kaleidoscope/key_events.cpp deleted file mode 100644 index eae4a95b..00000000 --- a/src/kaleidoscope/key_events.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* Kaleidoscope - Firmware for computer input devices - * Copyright (C) 2013-2018 Keyboard.io, Inc. - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#ifndef NDEPRECATED -#include "kaleidoscope/Runtime.h" -#include "kaleidoscope/LiveKeys.h" -#include "kaleidoscope/hooks.h" -#include "kaleidoscope/keyswitch_state.h" -#include "kaleidoscope/layers.h" -#include "kaleidoscope/event_handler_result.h" - -// Deprecated. See `Runtime.handleKeyEvent()` -void handleKeyswitchEvent(Key key, KeyAddr key_addr, uint8_t key_state) { - // Perhaps we should call deprecated plugin event handlers here? - auto result = kaleidoscope::Hooks::onKeyswitchEvent(key, key_addr, key_state); - if (result == kaleidoscope::EventHandlerResult::ABORT) - return; - if (keyIsPressed(key_state)) - kaleidoscope::Runtime.addToReport(key); -} -#endif diff --git a/src/kaleidoscope/key_events.h b/src/kaleidoscope/key_events.h deleted file mode 100644 index 3a0ade75..00000000 --- a/src/kaleidoscope/key_events.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Kaleidoscope - Firmware for computer input devices - * Copyright (C) 2013-2018 Keyboard.io, Inc. - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#pragma once -#include - -#include "kaleidoscope/driver/keyscanner/Base.h" -#include "kaleidoscope/device/device.h" -#include "kaleidoscope/key_defs.h" -#include "kaleidoscope/keyswitch_state.h" -#include "kaleidoscope/KeyAddr.h" - -// UnknownKeyswitchLocation represents an invalid (as default constructed) -// key address. Note: This is not a constexpr as it turned out -// that the compiler would instanciate it and store it in RAM if -// not made a temporary. -// -#define UnknownKeyswitchLocation KeyAddr(KeyAddr::invalid_state) - -// Conversely, if an injected event *is* tied to a physical keyswitch and should -// be resolved by the current keymap, code can use Key_NoKey on the injected event -// with a real key address - -// sending events to the computer -/* The event handling starts with the Scanner calling handleKeyswitchEvent() for - * every non-idle key in the matrix, and it is the task of this method to figure - * out what to do, it is the main entry point. Keys that were off in the - * previous scan cycle, and are still off now, are considered idle, and - * handleKeyswitchEvent() is *not* called on them. - * - * This function will iterate through an array of handler functions, and stop as - * soon as one of them signals that the event has been handled. To make it - * possible to inject synthetic events, one can call handleKeyswitchEvent from - * within a custom handler (making the event handling recursive), with a - * different keycode. - * - * This is useful for example for one-shot modifiers, where we would like to - * temporarily disable the one-shot functionality, and have them work as a - * normal modifier instead. In this case, the keymap would contain a key with - * OSM flags set, and the event handler would remove the OSM flags, and let the - * system handle the key as it would have, without the OSM flags. So we simply - * clear the flags, and call handleKeyswitchEvent again, with the modifier keycode - * as the first argument. This way, we could insert an event, and have the whole - * chain re-process it, instead of registering the keycode ourselves with HID - * ourselves. Injecting allows any and all custom handlers to have a chance, - * too. - * - * For this reason, the handleKeyswitchEvent receives four arguments: the mapped key - * (or Key_NoKey if we do not want to override what is in the keymap), the matrix - * address of the key, so we can look up the code for it, and the current and - * previous state of the key, so we can determine what the event is. The - * currentState may be flagged INJECTED, which signals that the event was - * injected, and is not a direct result of a keypress, coming from the scanner. - */ - -#ifndef NDEPRECATED - -DEPRECATED(HANDLE_KEYSWITCH_EVENT) -void handleKeyswitchEvent(Key mappedKey, kaleidoscope::Device::Props::KeyScannerProps::KeyAddr key_addr, uint8_t keyState); - -#endif diff --git a/src/kaleidoscope_internal/deprecations.h b/src/kaleidoscope_internal/deprecations.h index b5e31ddd..6024f206 100644 --- a/src/kaleidoscope_internal/deprecations.h +++ b/src/kaleidoscope_internal/deprecations.h @@ -29,11 +29,6 @@ /* Messages */ -#define _DEPRECATED_MESSAGE_HANDLE_KEYSWITCH_EVENT __NL__ \ - "`handleKeyswitchEvent()` has been deprecated.\n" __NL__ \ - "Please use `Runtime.handleKeyEvent()` instead.\n" __NL__ \ - "This function will be removed after 2021-08-01." - #define _DEPRECATED_MESSAGE_ON_KEYSWITCH_EVENT_V1 __NL__ \ "The `onKeyswitchEvent()` event handler is deprecated.\n" __NL__ \ "Please replace it with an `onKeyEvent()` handler. See the documentation\n" __NL__ \ From f2d8e91332a1fda637b06bc9cce2c6f5434f068b Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 23:21:01 -0600 Subject: [PATCH 11/14] Remove deprecated code from `Runtime` object This removes all the core code that called the pre-`KeyEvent` hook functions `onKeyswitchEvent(key, addr, state)` and `beforeReportingState()`. Any plugins that were still using these functions should use the newer equivalents instead: `onKeyEvent(event)` & `beforeReportingState(event)`. Signed-off-by: Michael Richters --- src/kaleidoscope/Runtime.cpp | 51 ------------------------------------ 1 file changed, 51 deletions(-) diff --git a/src/kaleidoscope/Runtime.cpp b/src/kaleidoscope/Runtime.cpp index 3218a64a..d96fc82c 100644 --- a/src/kaleidoscope/Runtime.cpp +++ b/src/kaleidoscope/Runtime.cpp @@ -58,19 +58,6 @@ Runtime_::loop(void) { kaleidoscope::Hooks::beforeEachCycle(); -#ifndef NDEPRECATED - // For backwards compatibility. Some plugins rely on the handler for - // `beforeReportingState()` being called every cycle. In most cases, they can - // simply switch to using `afterEachCycle()`, but we don't want to simply - // break those plugins. - kaleidoscope::Hooks::beforeReportingState(); - // Also for backwards compatibility. If user code calls any code that directly - // changes the HID report(s) at any point between an event being detected and - // the end of `handleKeyEvent()` (most likely from `beforeReportingState()`), - // we need to make sure that report doesn't just get discarded. - hid().keyboard().sendReport(); -#endif - // Next, we scan the keyswitches. Any toggle-on or toggle-off events will // trigger a call to `handleKeyswitchEvent()`, which in turn will // (conditionally) result in a HID report. Note that each event gets handled @@ -186,21 +173,6 @@ Runtime_::handleKeyEvent(KeyEvent event) { // one, based on the contents of the `live_keys` state array. prepareKeyboardReport(event); -#ifndef NDEPRECATED - // Deprecated handlers might depend on values in the report, so we wait until - // the new report is otherwise complete before calling them. - auto old_result = Hooks::onKeyswitchEvent(event.key, event.addr, event.state); - if (old_result == EventHandlerResult::ABORT) - return; - - if (old_result != EventHandlerResult::OK || - event.key == Key_Masked || - event.key == Key_NoKey || - event.key == Key_Undefined || - event.key == Key_Transparent) - return; -#endif - // Finally, send the new keyboard report sendKeyboardReport(event); @@ -235,24 +207,6 @@ Runtime_::prepareKeyboardReport(const KeyEvent &event) { if (key == Key_Inactive || key == Key_Masked) continue; -#ifndef NDEPRECATED - // Only run hooks for plugin keys. If a plugin needs to do something every - // cycle, it can use one of the every-cycle hooks and search for active keys - // of interest. - auto result = Hooks::onKeyswitchEvent(key, key_addr, IS_PRESSED | WAS_PRESSED); - if (result == EventHandlerResult::ABORT) - continue; - - if (key_addr == event.addr) { - // update active keys cache? - if (keyToggledOn(event.state)) { - live_keys.activate(event.addr, key); - } else { - live_keys.clear(event.addr); - } - } -#endif - addToReport(key); } } @@ -322,11 +276,6 @@ Runtime_::sendKeyboardReport(const KeyEvent &event) { addToReport(event.key); } -#ifndef NDEPRECATED - // Call old pre-report handlers: - Hooks::beforeReportingState(); -#endif - // Call new pre-report handlers: if (Hooks::beforeReportingState(event) == EventHandlerResult::ABORT) return; From 2c40e908d54a6b3cb3ef33e1b370da39505b526e Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 23:26:16 -0600 Subject: [PATCH 12/14] Remove deprecated event handler hooks This removes the pre-`KeyEvent` handler hooks for `onKeyswitchEvent()` and `beforeReportingState()`. Any third-party plugins that still use either should be updated to use the new handlers instead. Signed-off-by: Michael Richters --- docs/UPGRADING.md | 8 +++++ src/kaleidoscope/event_handlers.h | 40 ++++-------------------- src/kaleidoscope_internal/deprecations.h | 18 ----------- 3 files changed, 14 insertions(+), 52 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index a3aa5d03..c047ae5a 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1052,6 +1052,14 @@ The following headers and names have changed: # Removed APIs +### Removed on 2022-03-03 + +#### Pre-`KeyEvent` event handler hooks + +The old event handler `onKeyswitchEvent(Key &key, KeyAddr addr, uint8_t state)` was removed on **2022-03-03**. It has been replaced with the new `onKeyEvent(KeyEvent &event)` handler (and, in some special cases the `onKeyswitchEvent(KeyEvent &event)` handler). Plugins using the deprecated handler will need to be rewritten to use the new one(s). + +The old event handler `beforeReportingState()` was removed on **2022-03-03**. It has been replaced with the new `beforeReportingState(KeyEvent &event)` handler. However, the new handler will be called only when a report is being sent (generally in response to a key event), not every cycle, like the old one. It was common practice in the past for plugins to rely on `beforeReportingState()` being called every cycle, so when adapting to the `KeyEvent` API, it's important to check for code that should be moved to `afterEachCycle()` instead. + #### `::handleKeyswitchEvent(Key key, KeyAddr key_addr, uint8_t state)` The old master function for processing key "events" was removed on **2022-03-03**. Functions that were calling this function should be rewritten to call `kaleidoscope::Runtime.handleKeyEvent(KeyEvent event)` instead. diff --git a/src/kaleidoscope/event_handlers.h b/src/kaleidoscope/event_handlers.h index 11ca03e9..806f89d2 100644 --- a/src/kaleidoscope/event_handlers.h +++ b/src/kaleidoscope/event_handlers.h @@ -139,22 +139,6 @@ class SignatureCheckDummy {}; (),(),(), /* non template */ __NL__ \ (), (), ##__VA_ARGS__) __NL__ \ __NL__ \ - /* DEPRECATED */ __NL__ \ - /* Function called for every non-idle key, every cycle, so it */ __NL__ \ - /* can decide what to do with it. It can modify the key (which is */ __NL__ \ - /* passed by reference for this reason), and decide whether */ __NL__ \ - /* further handles should be tried. If it returns */ __NL__ \ - /* EventHandlerResult::OK, other handlers will also get a chance */ __NL__ \ - /* to react to the event. If it returns anything else, Kaleidoscope */ __NL__ \ - /* will stop processing there. */ __NL__ \ - OPERATION(onKeyswitchEvent, __NL__ \ - 1, __NL__ \ - DEPRECATED(ON_KEYSWITCH_EVENT_V1), __NL__ \ - _ABORTABLE, __NL__ \ - (),(),(), /* non template */ __NL__ \ - (Key &mappedKey, KeyAddr key_addr, uint8_t keyState), __NL__ \ - (mappedKey, key_addr, keyState), ##__VA_ARGS__) __NL__ \ - __NL__ \ /* Function called for every physical keyswitch event (toggle on or */ __NL__ \ /* off). The `event` parameter is passed by reference so its key */ __NL__ \ /* value can be modified. If it returns EventHandlerResult::OK, the */ __NL__ \ @@ -166,7 +150,7 @@ class SignatureCheckDummy {}; /* plugin that does so must release events in ascending order, */ __NL__ \ /* counting by ones. */ __NL__ \ OPERATION(onKeyswitchEvent, __NL__ \ - 2, __NL__ \ + 1, __NL__ \ _CURRENT_IMPLEMENTATION, __NL__ \ _ABORTABLE, __NL__ \ (),(),(), /* non template */ __NL__ \ @@ -242,22 +226,12 @@ class SignatureCheckDummy {}; _NOT_ABORTABLE, __NL__ \ (),(),(), /* non template */ __NL__ \ (), (), ##__VA_ARGS__) __NL__ \ - /* DEPRECATED */ __NL__ \ - /* Called before reporting our state to the host. This is the */ __NL__ \ - /* last point in a cycle where a plugin can alter what gets */ __NL__ \ - /* reported to the host. */ __NL__ \ - OPERATION(beforeReportingState, __NL__ \ - 1, __NL__ \ - DEPRECATED(BEFORE_REPORTING_STATE_V1), __NL__ \ - _NOT_ABORTABLE, __NL__ \ - (),(),(), /* non template */ __NL__ \ - (),(),##__VA_ARGS__) __NL__ \ __NL__ \ /* Called before reporting our state to the host. This is the */ __NL__ \ /* last point in a cycle where a plugin can alter what gets */ __NL__ \ /* reported to the host. */ __NL__ \ OPERATION(beforeReportingState, __NL__ \ - 2, __NL__ \ + 1, __NL__ \ _CURRENT_IMPLEMENTATION, __NL__ \ _ABORTABLE, __NL__ \ (),(),(), /* non template */ __NL__ \ @@ -330,10 +304,9 @@ class SignatureCheckDummy {}; OP(beforeEachCycle, 1) __NL__ \ END(beforeEachCycle, 1) __NL__ \ __NL__ \ - START(onKeyswitchEvent, 1, 2) __NL__ \ + START(onKeyswitchEvent, 1) __NL__ \ OP(onKeyswitchEvent, 1) __NL__ \ - OP(onKeyswitchEvent, 2) __NL__ \ - END(onKeyswitchEvent, 1, 2) __NL__ \ + END(onKeyswitchEvent, 1) __NL__ \ __NL__ \ START(onKeyEvent, 1) __NL__ \ OP(onKeyEvent, 1) __NL__ \ @@ -359,10 +332,9 @@ class SignatureCheckDummy {}; OP(beforeSyncingLeds, 1) __NL__ \ END(beforeSyncingLeds, 1) __NL__ \ __NL__ \ - START(beforeReportingState, 1, 2) __NL__ \ + START(beforeReportingState, 1) __NL__ \ OP(beforeReportingState, 1) __NL__ \ - OP(beforeReportingState, 2) __NL__ \ - END(beforeReportingState, 1, 2) __NL__ \ + END(beforeReportingState, 1) __NL__ \ __NL__ \ START(afterReportingState, 1) __NL__ \ OP(afterReportingState, 1) __NL__ \ diff --git a/src/kaleidoscope_internal/deprecations.h b/src/kaleidoscope_internal/deprecations.h index 6024f206..5cedea76 100644 --- a/src/kaleidoscope_internal/deprecations.h +++ b/src/kaleidoscope_internal/deprecations.h @@ -28,21 +28,3 @@ "------------------------------------------------------------------------\n" \ /* Messages */ - -#define _DEPRECATED_MESSAGE_ON_KEYSWITCH_EVENT_V1 __NL__ \ - "The `onKeyswitchEvent()` event handler is deprecated.\n" __NL__ \ - "Please replace it with an `onKeyEvent()` handler. See the documentation\n" __NL__ \ - "in UPGRADING.md and docs/api-reference/event-handler-hooks.md for more\n" __NL__ \ - "information on what changes are needed to adapt old plugins to the new\n" __NL__ \ - "event handler API.\n" __NL__ \ - "This function will be removed after 2021-08-01." - -#define _DEPRECATED_MESSAGE_BEFORE_REPORTING_STATE_V1 __NL__ \ - "This `beforeReportingState()` event handler version is deprecated.\n" __NL__ \ - "There is a new `beforeReportingState(KeyEvent)` handler that can be used\n" __NL__ \ - "instead, for plugins that need to execute code before each new HID\n" __NL__ \ - "report is sent. However, the new handler does not run every cycle, but\n" __NL__ \ - "only in response to key events. If you have code that is intended to run\n" __NL__ \ - "every scan cycle, it should be moved to the `afterEachCycle()` event\n" __NL__ \ - "handler instead.\n" __NL__ \ - "This function will be removed after 2021-08-01." From ce31989a9cb48e244329d522add3293ade68a48f Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 1 Mar 2022 13:48:23 -0600 Subject: [PATCH 13/14] Deprecate old Leader code properly Signed-off-by: Michael Richters --- docs/UPGRADING.md | 6 ++++ .../src/kaleidoscope/plugin/Leader.cpp | 14 ++++++++- .../src/kaleidoscope/plugin/Leader.h | 29 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index c047ae5a..01baae1f 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1029,6 +1029,12 @@ The masking API has been removed on **2021-01-01** ## Deprecated APIs and their replacements +### Leader plugin + +The `Leader.inject()` function is deprecated. Please call `Runtime.handleKeyEvent()` directly instead. + +Direct access to the `Leader.time_out` configuration variable is deprecated. Please use the `Leader.setTimeout(ms)` function instead. + ### Source code and namespace rearrangement With the move towards a monorepo-based source, some headers have moved to a new location, and plenty of plugins moved to a new namespace (`kaleidoscope::plugin`). This means that the old headers, and some old names are deprecated. The old names no longer work. diff --git a/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp b/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp index 3e7c833c..ea737802 100644 --- a/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp +++ b/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.cpp @@ -29,7 +29,10 @@ Key Leader::sequence_[LEADER_MAX_SEQUENCE_LENGTH + 1]; KeyEventTracker Leader::event_tracker_; uint8_t Leader::sequence_pos_; uint16_t Leader::start_time_ = 0; +#ifndef NDEPRECATED uint16_t Leader::time_out = 1000; +#endif +uint16_t Leader::timeout_ = 1000; const Leader::dictionary_t *Leader::dictionary; // --- helpers --- @@ -82,10 +85,11 @@ void Leader::reset(void) { sequence_[0] = Key_NoKey; } -// DEPRECATED +#ifndef NDEPRECATED void Leader::inject(Key key, uint8_t key_state) { Runtime.handleKeyEvent(KeyEvent(KeyAddr::none(), key_state | INJECTED, key)); } +#endif // --- hooks --- EventHandlerResult Leader::onNameQuery() { @@ -141,8 +145,16 @@ EventHandlerResult Leader::afterEachCycle() { if (!isActive()) return EventHandlerResult::OK; +#ifndef NDEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" if (Runtime.hasTimeExpired(start_time_, time_out)) reset(); +#pragma GCC diagnostic pop +#else + if (Runtime.hasTimeExpired(start_time_, timeout_)) + reset(); +#endif return EventHandlerResult::OK; } diff --git a/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.h b/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.h index f84b4752..0b730cbf 100644 --- a/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.h +++ b/plugins/Kaleidoscope-Leader/src/kaleidoscope/plugin/Leader.h @@ -21,6 +21,19 @@ #include "kaleidoscope/KeyEventTracker.h" #include "kaleidoscope/plugin.h" +// ----------------------------------------------------------------------------- +// Deprecation warning messages +#define _DEPRECATED_MESSAGE_LEADER_INJECT \ + "The `Leader.inject()` function is deprecated. Please call\n" \ + "`kaleidoscope::Runtime.handleKeyEvent()` directly instead.\n" \ + "This function will be removed after 2022-09-01." + +#define _DEPRECATED_MESSAGE_LEADER_TIME_OUT \ + "The `Leader.time_out` variable is deprecated. Please use the\n" \ + "`Leader.setTimeout()` function instead.\n" \ + "This variable will be removed after 2022-09-01." +// ----------------------------------------------------------------------------- + #define LEADER_MAX_SEQUENCE_LENGTH 4 #define LEAD(n) Key(kaleidoscope::ranges::LEAD_FIRST + n) @@ -43,9 +56,24 @@ class Leader : public kaleidoscope::Plugin { static const dictionary_t *dictionary; static void reset(void); + +#ifndef NDEPRECATED + DEPRECATED(LEADER_TIME_OUT) static uint16_t time_out; + DEPRECATED(LEADER_INJECT) void inject(Key key, uint8_t key_state); +#endif + + static void setTimeout(uint16_t timeout) { +#ifndef NDEPRECATED +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + time_out = timeout; +#pragma GCC diagnostic pop +#endif + timeout_ = timeout; + } EventHandlerResult onNameQuery(); EventHandlerResult onKeyswitchEvent(KeyEvent &event); @@ -56,6 +84,7 @@ class Leader : public kaleidoscope::Plugin { static KeyEventTracker event_tracker_; static uint8_t sequence_pos_; static uint16_t start_time_; + static uint16_t timeout_; static int8_t lookup(void); }; From 419f317bbc35d664a7f8e0b571f8cb0413c7b277 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Thu, 3 Mar 2022 12:03:26 -0600 Subject: [PATCH 14/14] Correct some heading levels in UPGRADING doc Signed-off-by: Michael Richters --- docs/UPGRADING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 01baae1f..83548e73 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -1152,11 +1152,11 @@ This deprecated plugin was removed on **2022-03-03**. Please use the more gener ### Removed on 2020-10-10 -### Deprecation of the HID facade +#### Deprecation of the HID facade With the new Device APIs it became possible to replace the HID facade (the `kaleidoscope::hid` family of functions) with a driver. As such, the old APIs are deprecated, and was removed on 2020-10-10. Please use `Kaleidoscope.hid()` instead. -### Implementation of type Key internally changed from C++ union to class +#### Implementation of type Key internally changed from C++ union to class The deprecated functions were removed on 2020-10-10.