From 3227a2dcf408d9ea8852953a3eb680a686909a32 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 1 Jan 2021 23:35:11 -0800 Subject: [PATCH 1/3] Remove deprecated Layer API functions as per the schedule --- docs/UPGRADING.md | 2 +- src/kaleidoscope/layers.h | 10 ---------- src/kaleidoscope_internal/deprecations.h | 13 ------------- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 421c43be..75fd673b 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -338,7 +338,7 @@ The layer system used to be index-ordered, meaning that we'd look keys up on layers based on the _index_ of active layers. Kaleidoscope now uses activation order, which looks up keys based on the order of layer activation. -This means that the following functions are deprecated, and will be removed by **2020-12-31**: +The following functions have been removed as of **2021-01-01**: - `Layer.top()`, which used to return the topmost layer index. Use `Layer.mostRecent()` instead, which returns the most recently activated layer. diff --git a/src/kaleidoscope/layers.h b/src/kaleidoscope/layers.h index 9b6175b9..af8c4563 100644 --- a/src/kaleidoscope/layers.h +++ b/src/kaleidoscope/layers.h @@ -96,24 +96,14 @@ class Layer_ { static void activate(uint8_t layer); static void deactivate(uint8_t layer); static void activateNext(); - static void deactivateTop() DEPRECATED(LAYER_DEACTIVATETOP) { - deactivateMostRecent(); - } static void deactivateMostRecent(); static void move(uint8_t layer); - static uint8_t top(void) DEPRECATED(LAYER_TOP) { - return mostRecent(); - } static uint8_t mostRecent() { return active_layers_[active_layer_count_ - 1]; } static boolean isActive(uint8_t layer); - static uint32_t getLayerState(void) DEPRECATED(LAYER_GETLAYERSTATE) { - return layer_state_; - } - static Key eventHandler(Key mappedKey, KeyAddr key_addr, uint8_t keyState); typedef Key(*GetKeyFunction)(uint8_t layer, KeyAddr key_addr); diff --git a/src/kaleidoscope_internal/deprecations.h b/src/kaleidoscope_internal/deprecations.h index db94108b..40434278 100644 --- a/src/kaleidoscope_internal/deprecations.h +++ b/src/kaleidoscope_internal/deprecations.h @@ -33,16 +33,3 @@ "For further information and examples on how to do that, \n" __NL__ \ "please see UPGRADING.md" -#define _DEPRECATED_MESSAGE_LAYER_DEACTIVATETOP __NL__ \ - "`Layer.deactivateTop()` is deprecated.\n" __NL__ \ - "Please use `Layer.deactivateMostRecent()` instead." - -#define _DEPRECATED_MESSAGE_LAYER_TOP __NL__ \ - "`Layer.top()` is deprecated.\n" __NL__ \ - "Please use `Layer.mostRecent()` instead." - -#define _DEPRECATED_MESSAGE_LAYER_GETLAYERSTATE __NL__ \ - "`Layer.getLayerState()` is deprecated.\n" __NL__ \ - "Layers are now in activation-order, please use" __NL__ \ - "`Layer.forEachActiveLayer()` instead." - From 3bfd045065bdfeb779e5ef6b711beaf5b41ae9b0 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 1 Jan 2021 23:56:32 -0800 Subject: [PATCH 2/3] Remove deprecated Key Masking system on schedule --- docs/UPGRADING.md | 4 +- .../src/kaleidoscope/device/dygma/Raise.cpp | 49 --------------- .../src/kaleidoscope/device/dygma/Raise.h | 8 --- .../src/kaleidoscope/device/ez/ErgoDox.cpp | 22 ------- .../src/kaleidoscope/device/ez/ErgoDox.h | 5 -- .../device/keyboardio/Model01.cpp | 61 ------------------- .../kaleidoscope/device/keyboardio/Model01.h | 8 --- src/kaleidoscope/device/Base.h | 45 -------------- src/kaleidoscope/device/virtual/Virtual.cpp | 25 -------- src/kaleidoscope/device/virtual/Virtual.h | 5 -- src/kaleidoscope/driver/keyscanner/ATmega.h | 21 ------- src/kaleidoscope/driver/keyscanner/Base.h | 5 -- src/kaleidoscope/key_events.cpp | 14 ----- src/kaleidoscope_internal/deprecations.h | 6 -- 14 files changed, 2 insertions(+), 276 deletions(-) diff --git a/docs/UPGRADING.md b/docs/UPGRADING.md index 75fd673b..0a66d5e3 100644 --- a/docs/UPGRADING.md +++ b/docs/UPGRADING.md @@ -548,13 +548,13 @@ Storing the settable settings in EEPROM makes it depend on `Kaleidoscope-EEPROM- Older versions of the plugin required one to set up `Key_Redial` manually, and let the plugin know about it via `Redial.key`. This is no longer required, as the plugin sets up the redial key itself. As such, `Redial.key` was removed, and `Key_Redial` is defined by the plugin itself. To upgrade, simply remove your definition of `Key_Redial` and the `Redial.key` assignment from your sketch. -### Key masking has been deprecated +### Key masking has been removed Key masking was a band-aid introduced to avoid accidentally sending unintended keys when key mapping changes between a key being pressed and released. Since the introduction of keymap caching, this is no longer necessary, as long as we can keep the mapping consistent. Users of key masking are encouraged to find ways to use the caching mechanism instead. As an example, if you had a key event handler that in some cases masked a key, it should now map it to `Key_NoKey` instead, until released. -The masking API has been deprecated, and is scheduled to be removed after **2020-11-25**. +The masking API has been removed on **2021-01-01** ## Deprecated APIs and their replacements diff --git a/plugins/Kaleidoscope-Hardware-Dygma-Raise/src/kaleidoscope/device/dygma/Raise.cpp b/plugins/Kaleidoscope-Hardware-Dygma-Raise/src/kaleidoscope/device/dygma/Raise.cpp index 3d8bc92d..5e6084c0 100644 --- a/plugins/Kaleidoscope-Hardware-Dygma-Raise/src/kaleidoscope/device/dygma/Raise.cpp +++ b/plugins/Kaleidoscope-Hardware-Dygma-Raise/src/kaleidoscope/device/dygma/Raise.cpp @@ -262,8 +262,6 @@ raise::keydata_t RaiseKeyScanner::leftHandState; raise::keydata_t RaiseKeyScanner::rightHandState; raise::keydata_t RaiseKeyScanner::previousLeftHandState; raise::keydata_t RaiseKeyScanner::previousRightHandState; -raise::keydata_t RaiseKeyScanner::leftHandMask; -raise::keydata_t RaiseKeyScanner::rightHandMask; bool RaiseKeyScanner::lastLeftOnline; bool RaiseKeyScanner::lastRightOnline; @@ -337,53 +335,6 @@ void RaiseKeyScanner::scanMatrix() { actOnMatrixScan(); } -void RaiseKeyScanner::maskKey(KeyAddr key_addr) { - if (!key_addr.isValid()) - return; - - auto row = key_addr.row(); - auto col = key_addr.col(); - - if (col >= Props_::left_columns) { - rightHandMask.rows[row] |= 1 << (Props_::right_columns - (col - Props_::left_columns)); - } else { - leftHandMask.rows[row] |= 1 << (Props_::right_columns - col); - } -} - -void RaiseKeyScanner::unMaskKey(KeyAddr key_addr) { - if (!key_addr.isValid()) - return; - - auto row = key_addr.row(); - auto col = key_addr.col(); - - if (col >= Props_::left_columns) { - rightHandMask.rows[row] &= ~(1 << (Props_::right_columns - (col - Props_::left_columns))); - } else { - leftHandMask.rows[row] &= ~(1 << (Props_::right_columns - col)); - } -} - -bool RaiseKeyScanner::isKeyMasked(KeyAddr key_addr) { - if (!key_addr.isValid()) - return false; - - auto row = key_addr.row(); - auto col = key_addr.col(); - - if (col >= 8) { - return rightHandMask.rows[row] & (1 << (7 - (col - 8))); - } else { - return leftHandMask.rows[row] & (1 << (7 - col)); - } -} - -void RaiseKeyScanner::maskHeldKeys() { - memcpy(leftHandMask.rows, leftHandState.rows, sizeof(leftHandMask)); - memcpy(rightHandMask.rows, rightHandState.rows, sizeof(rightHandMask)); -} - bool RaiseKeyScanner::isKeyswitchPressed(KeyAddr key_addr) { auto row = key_addr.row(); auto col = key_addr.col(); diff --git a/plugins/Kaleidoscope-Hardware-Dygma-Raise/src/kaleidoscope/device/dygma/Raise.h b/plugins/Kaleidoscope-Hardware-Dygma-Raise/src/kaleidoscope/device/dygma/Raise.h index 16a4830f..80f1e5ed 100644 --- a/plugins/Kaleidoscope-Hardware-Dygma-Raise/src/kaleidoscope/device/dygma/Raise.h +++ b/plugins/Kaleidoscope-Hardware-Dygma-Raise/src/kaleidoscope/device/dygma/Raise.h @@ -129,11 +129,6 @@ class RaiseKeyScanner : public kaleidoscope::driver::keyscanner::Base { void actOnMatrixScan(void); void setup(); - void maskKey(KeyAddr key_addr); - void unMaskKey(KeyAddr key_addr); - bool isKeyMasked(KeyAddr key_addr); - bool isKeyswitchPressed(KeyAddr key_addr); bool isKeyswitchPressed(uint8_t keyIndex); uint8_t pressedKeyswitchCount(); @@ -90,7 +86,6 @@ class ErgoDox : public kaleidoscope::device::ATmega32U4Keyboard { static ErgoDoxScanner scanner_; static uint8_t previousKeyState_[matrix_rows]; static uint8_t keyState_[matrix_rows]; - static uint8_t masks_[matrix_rows]; static uint8_t debounce_matrix_[matrix_rows][matrix_columns]; static uint8_t debounceMaskForRow(uint8_t row); 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 26473eae..61681091 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 @@ -139,8 +139,6 @@ driver::keyboardio::keydata_t Model01KeyScanner::leftHandState; driver::keyboardio::keydata_t Model01KeyScanner::rightHandState; driver::keyboardio::keydata_t Model01KeyScanner::previousLeftHandState; driver::keyboardio::keydata_t Model01KeyScanner::previousRightHandState; -driver::keyboardio::keydata_t Model01KeyScanner::leftHandMask; -driver::keyboardio::keydata_t Model01KeyScanner::rightHandMask; void Model01KeyScanner::enableScannerPower(void) { // Turn on power to the LED net @@ -197,65 +195,6 @@ void Model01KeyScanner::scanMatrix() { actOnMatrixScan(); } -// In the maskKey(), unMaskKey(), and isKeyMasked() functions, we read and write bits in -// two bitfields -- one for each half of the keyboard. The fourth bit of the column number -// tells us which bitfield (right or left) to access, thus the "8" (B00001000). The row -// number tells us which element of the array to access. The last three bits of the column -// number tell us which of the eight bits to access, thus the "7" (B00000111), and we -// shift a bit starting from the left (B10000000, or 128) by that many places to get -// there. This is all nice and convenient because the keyboard has 64 keys, in symmetric -// halves, with eight keys per logical row. - -constexpr byte HIGH_BIT = B10000000; -constexpr byte HAND_BIT = B00001000; -constexpr byte ROW_BITS = B00110000; -constexpr byte COL_BITS = B00000111; - -void Model01KeyScanner::maskKey(KeyAddr key_addr) { - if (!key_addr.isValid()) - return; - - auto row = key_addr.row(); - auto col = key_addr.col(); - if (col & HAND_BIT) { - rightHandMask.rows[row] |= (HIGH_BIT >> (col & COL_BITS)); - } else { - leftHandMask.rows[row] |= (HIGH_BIT >> (col & COL_BITS)); - } -} - -void Model01KeyScanner::unMaskKey(KeyAddr key_addr) { - if (!key_addr.isValid()) - return; - - auto row = key_addr.row(); - auto col = key_addr.col(); - if (col & HAND_BIT) { - rightHandMask.rows[row] &= ~(HIGH_BIT >> (col & COL_BITS)); - } else { - leftHandMask.rows[row] &= ~(HIGH_BIT >> (col & COL_BITS)); - } -} - -bool Model01KeyScanner::isKeyMasked(KeyAddr key_addr) { - if (!key_addr.isValid()) - return false; - - auto row = key_addr.row(); - auto col = key_addr.col(); - if (col & HAND_BIT) { - return rightHandMask.rows[row] & (HIGH_BIT >> (col & COL_BITS)); - } else { - return leftHandMask.rows[row] & (HIGH_BIT >> (col & COL_BITS)); - } -} - -void Model01KeyScanner::maskHeldKeys() { - memcpy(leftHandMask.rows, leftHandState.rows, sizeof(leftHandMask)); - memcpy(rightHandMask.rows, rightHandState.rows, sizeof(rightHandMask)); -} - - void Model01KeyScanner::setKeyscanInterval(uint8_t interval) { Model01Hands::leftHand.setKeyscanInterval(interval); Model01Hands::rightHand.setKeyscanInterval(interval); diff --git a/plugins/Kaleidoscope-Hardware-Keyboardio-Model01/src/kaleidoscope/device/keyboardio/Model01.h b/plugins/Kaleidoscope-Hardware-Keyboardio-Model01/src/kaleidoscope/device/keyboardio/Model01.h index 81ad8ad9..14f60631 100644 --- a/plugins/Kaleidoscope-Hardware-Keyboardio-Model01/src/kaleidoscope/device/keyboardio/Model01.h +++ b/plugins/Kaleidoscope-Hardware-Keyboardio-Model01/src/kaleidoscope/device/keyboardio/Model01.h @@ -85,11 +85,6 @@ class Model01KeyScanner : public kaleidoscope::driver::keyscanner::Base