From 7f4090f126cbcfc7959024a2be62ecaeb83ebea0 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 15 Sep 2022 17:59:20 +0200 Subject: [PATCH] SpaceCadet: Drop the deprecated public member variables Signed-off-by: Gergely Nagy --- .../src/kaleidoscope/plugin/SpaceCadet.cpp | 28 +++-------------- .../src/kaleidoscope/plugin/SpaceCadet.h | 31 ++----------------- tests/plugins/SpaceCadet/basic/basic.ino | 4 +-- .../plugins/SpaceCadet/no-delay/no-delay.ino | 4 +-- 4 files changed, 11 insertions(+), 56 deletions(-) diff --git a/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.cpp b/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.cpp index 9c43b72e..4105e0ec 100644 --- a/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.cpp +++ b/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.cpp @@ -42,17 +42,6 @@ SpaceCadet::KeyBinding::KeyBinding(Key input, Key output) SpaceCadet::KeyBinding::KeyBinding(Key input, Key output, uint16_t timeout) : input(input), output(output), timeout(timeout) {} -// ============================================================================= -// Space Cadet class variables - -// ----------------------------------------------------------------------------- -// Plugin configuration variables - -#ifndef NDEPRECATED -SpaceCadet::KeyBinding *SpaceCadet::map; -uint16_t SpaceCadet::time_out = 200; -#endif - // ============================================================================= // SpaceCadet functions @@ -163,16 +152,9 @@ EventHandlerResult SpaceCadet::afterEachCycle() { return EventHandlerResult::OK; // Get timeout value for the pending key. -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - uint16_t pending_timeout = time_out; -#pragma GCC diagnostic pop -#else uint16_t pending_timeout = timeout_; -#endif - if (map[pending_map_index_].timeout != 0) - pending_timeout = map[pending_map_index_].timeout; + if (map_[pending_map_index_].timeout != 0) + pending_timeout = map_[pending_map_index_].timeout; uint16_t start_time = event_queue_.timestamp(0); if (Runtime.hasTimeExpired(start_time, pending_timeout)) { @@ -186,8 +168,8 @@ EventHandlerResult SpaceCadet::afterEachCycle() { // Private helper function(s) int8_t SpaceCadet::getSpaceCadetKeyIndex(Key key) const { - for (uint8_t i = 0; !map[i].isEmpty(); ++i) { - if (map[i].input == key) { + for (uint8_t i = 0; !map_[i].isEmpty(); ++i) { + if (map_[i].input == key) { return i; } } @@ -208,7 +190,7 @@ void SpaceCadet::flushEvent(bool is_tap) { if (mode_ == Mode::NO_DELAY) { Runtime.handleKeyEvent(KeyEvent(event.addr, WAS_PRESSED)); } - event.key = map[pending_map_index_].output; + event.key = map_[pending_map_index_].output; } event_queue_.shift(); Runtime.handleKeyswitchEvent(event); diff --git a/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.h b/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.h index 224c1240..45958dea 100644 --- a/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.h +++ b/plugins/Kaleidoscope-SpaceCadet/src/kaleidoscope/plugin/SpaceCadet.h @@ -27,15 +27,6 @@ #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/key_defs.h" // for Key, Key_NoKey #include "kaleidoscope/plugin.h" // for Plugin -// ----------------------------------------------------------------------------- -// Deprecation warning messages -#include "kaleidoscope_internal/deprecations.h" // for DEPRECATED - -#define _DEPRECATED_MESSAGE_SPACECADET_TIME_OUT \ - "The `SpaceCadet.time_out` variable is deprecated. Please use the\n" \ - "`SpaceCadet.setTimeout()` function instead.\n" \ - "This variable will be removed after 2022-09-01." -// ----------------------------------------------------------------------------- #ifndef SPACECADET_MAP_END #define SPACECADET_MAP_END \ @@ -88,26 +79,12 @@ class SpaceCadet : public kaleidoscope::Plugin { return (mode_ == Mode::ON || mode_ == Mode::NO_DELAY); } -#ifndef NDEPRECATED - // Publically accessible variables - DEPRECATED(SPACECADET_TIME_OUT) - static uint16_t time_out; // The global timeout in milliseconds - static SpaceCadet::KeyBinding *map; // The map of key bindings -#endif - void setTimeout(uint16_t timeout) { -#ifndef NDEPRECATED -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - time_out = timeout; -#pragma GCC diagnostic pop -#else timeout_ = timeout; -#endif } void setMap(KeyBinding *bindings) { - map = bindings; + map_ = bindings; } EventHandlerResult onNameQuery(); @@ -122,15 +99,11 @@ class SpaceCadet : public kaleidoscope::Plugin { }; uint8_t mode_; -#ifdef NDEPRECATED // Global timeout in milliseconds uint16_t timeout_ = 200; // The map of keybindings - KeyBinding *map = nullptr; - // When DEPRECATED public `map[]` variable is removed, this variable name - // should be given a trailing underscore to conform to code style guide. -#endif + KeyBinding *map_ = nullptr; KeyEventTracker event_tracker_; diff --git a/tests/plugins/SpaceCadet/basic/basic.ino b/tests/plugins/SpaceCadet/basic/basic.ino index ea934f33..bce2fc13 100644 --- a/tests/plugins/SpaceCadet/basic/basic.ino +++ b/tests/plugins/SpaceCadet/basic/basic.ino @@ -59,8 +59,8 @@ void setup() { SPACECADET_MAP_END }; //Set the map. - SpaceCadet.map = spacecadetmap; - SpaceCadet.time_out = 20; + SpaceCadet.setMap(spacecadetmap); + SpaceCadet.setTimeout(20); } void loop() { diff --git a/tests/plugins/SpaceCadet/no-delay/no-delay.ino b/tests/plugins/SpaceCadet/no-delay/no-delay.ino index 7881a202..06a2382d 100644 --- a/tests/plugins/SpaceCadet/no-delay/no-delay.ino +++ b/tests/plugins/SpaceCadet/no-delay/no-delay.ino @@ -57,8 +57,8 @@ void setup() { SPACECADET_MAP_END }; //Set the map. - SpaceCadet.map = spacecadetmap; - SpaceCadet.time_out = 20; + SpaceCadet.setMap(spacecadetmap); + SpaceCadet.setTimeout(20); SpaceCadet.enableWithoutDelay(); }