SpaceCadet: Drop the deprecated public member variables

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/1234/head
Gergely Nagy 2 years ago
parent 63bcf212f3
commit 7f4090f126
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -42,17 +42,6 @@ SpaceCadet::KeyBinding::KeyBinding(Key input, Key output)
SpaceCadet::KeyBinding::KeyBinding(Key input, Key output, uint16_t timeout) SpaceCadet::KeyBinding::KeyBinding(Key input, Key output, uint16_t timeout)
: input(input), output(output), timeout(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 // SpaceCadet functions
@ -163,16 +152,9 @@ EventHandlerResult SpaceCadet::afterEachCycle() {
return EventHandlerResult::OK; return EventHandlerResult::OK;
// Get timeout value for the pending key. // 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_; uint16_t pending_timeout = timeout_;
#endif if (map_[pending_map_index_].timeout != 0)
if (map[pending_map_index_].timeout != 0) pending_timeout = map_[pending_map_index_].timeout;
pending_timeout = map[pending_map_index_].timeout;
uint16_t start_time = event_queue_.timestamp(0); uint16_t start_time = event_queue_.timestamp(0);
if (Runtime.hasTimeExpired(start_time, pending_timeout)) { if (Runtime.hasTimeExpired(start_time, pending_timeout)) {
@ -186,8 +168,8 @@ EventHandlerResult SpaceCadet::afterEachCycle() {
// Private helper function(s) // Private helper function(s)
int8_t SpaceCadet::getSpaceCadetKeyIndex(Key key) const { int8_t SpaceCadet::getSpaceCadetKeyIndex(Key key) const {
for (uint8_t i = 0; !map[i].isEmpty(); ++i) { for (uint8_t i = 0; !map_[i].isEmpty(); ++i) {
if (map[i].input == key) { if (map_[i].input == key) {
return i; return i;
} }
} }
@ -208,7 +190,7 @@ void SpaceCadet::flushEvent(bool is_tap) {
if (mode_ == Mode::NO_DELAY) { if (mode_ == Mode::NO_DELAY) {
Runtime.handleKeyEvent(KeyEvent(event.addr, WAS_PRESSED)); Runtime.handleKeyEvent(KeyEvent(event.addr, WAS_PRESSED));
} }
event.key = map[pending_map_index_].output; event.key = map_[pending_map_index_].output;
} }
event_queue_.shift(); event_queue_.shift();
Runtime.handleKeyswitchEvent(event); Runtime.handleKeyswitchEvent(event);

@ -27,15 +27,6 @@
#include "kaleidoscope/event_handler_result.h" // for EventHandlerResult #include "kaleidoscope/event_handler_result.h" // for EventHandlerResult
#include "kaleidoscope/key_defs.h" // for Key, Key_NoKey #include "kaleidoscope/key_defs.h" // for Key, Key_NoKey
#include "kaleidoscope/plugin.h" // for Plugin #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 #ifndef SPACECADET_MAP_END
#define SPACECADET_MAP_END \ #define SPACECADET_MAP_END \
@ -88,26 +79,12 @@ class SpaceCadet : public kaleidoscope::Plugin {
return (mode_ == Mode::ON || mode_ == Mode::NO_DELAY); 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) { 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; timeout_ = timeout;
#endif
} }
void setMap(KeyBinding *bindings) { void setMap(KeyBinding *bindings) {
map = bindings; map_ = bindings;
} }
EventHandlerResult onNameQuery(); EventHandlerResult onNameQuery();
@ -122,15 +99,11 @@ class SpaceCadet : public kaleidoscope::Plugin {
}; };
uint8_t mode_; uint8_t mode_;
#ifdef NDEPRECATED
// Global timeout in milliseconds // Global timeout in milliseconds
uint16_t timeout_ = 200; uint16_t timeout_ = 200;
// The map of keybindings // The map of keybindings
KeyBinding *map = nullptr; 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
KeyEventTracker event_tracker_; KeyEventTracker event_tracker_;

@ -59,8 +59,8 @@ void setup() {
SPACECADET_MAP_END SPACECADET_MAP_END
}; };
//Set the map. //Set the map.
SpaceCadet.map = spacecadetmap; SpaceCadet.setMap(spacecadetmap);
SpaceCadet.time_out = 20; SpaceCadet.setTimeout(20);
} }
void loop() { void loop() {

@ -57,8 +57,8 @@ void setup() {
SPACECADET_MAP_END SPACECADET_MAP_END
}; };
//Set the map. //Set the map.
SpaceCadet.map = spacecadetmap; SpaceCadet.setMap(spacecadetmap);
SpaceCadet.time_out = 20; SpaceCadet.setTimeout(20);
SpaceCadet.enableWithoutDelay(); SpaceCadet.enableWithoutDelay();
} }

Loading…
Cancel
Save