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)
: 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);

@ -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_;

@ -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() {

@ -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();
}

Loading…
Cancel
Save