Merge pull request #1115 from gedankenexperimenter/deprecations-2021

Remove deprecated code dated 2021-08-01
pull/1119/head
Jesse Vincent 3 years ago committed by GitHub
commit 48d43ae259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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`
@ -1061,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.
@ -1082,23 +1056,107 @@ 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.
### Removed on 2022-03-03
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.
#### Pre-`KeyEvent` event handler hooks
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 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).
# Removed APIs
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.
#### `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.
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.
#### 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
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.
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:
- 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:
- 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.
#### `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.
### 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.

@ -19,7 +19,6 @@
#include <Kaleidoscope-Cycle.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h"
namespace kaleidoscope {
namespace plugin {

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

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

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

@ -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"

@ -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:

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

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

@ -19,7 +19,6 @@
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h"
#include "kaleidoscope/KeyEventTracker.h"
namespace kaleidoscope {
@ -30,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 ---
@ -83,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() {
@ -142,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;
}

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

@ -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
@ -26,22 +25,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 +36,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 +285,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);

@ -21,69 +21,11 @@
#include "kaleidoscope/plugin/Macros/MacroKeyDefs.h"
#include "kaleidoscope/plugin/Macros/MacroSteps.h"
#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 +103,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

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

@ -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 <jesse@keyboard.io>
url=https://github.com/keyboardio/Kaleidoscope
author=Keyboardio
paragraph=

@ -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 <http://www.gnu.org/licenses/>.
*/
#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"

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD
#error "Model01 testmode not available for virtual builds"
#else
#ifdef ARDUINO_AVR_MODEL01
#include <Arduino.h>
#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

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

@ -18,7 +18,6 @@
#include <Kaleidoscope-OneShot.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h"
#include "kaleidoscope/layers.h"
namespace kaleidoscope {
@ -31,13 +30,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 +325,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 +399,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

@ -19,49 +19,8 @@
#include "kaleidoscope/Runtime.h"
#include <Kaleidoscope-Ranges.h>
#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 +154,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

@ -19,7 +19,6 @@
#include <Kaleidoscope-SpaceCadet.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h"
//#include <Kaleidoscope-Devel-ArduinoTrace.h>

@ -18,7 +18,6 @@
#include <Kaleidoscope-Syster.h>
#include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h"
#undef SYSTER

@ -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"

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

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

@ -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__ \

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

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <Arduino.h>
#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

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

@ -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:

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

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

@ -28,61 +28,3 @@
"------------------------------------------------------------------------\n" \
/* 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__ \
"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__ \
"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."
#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."

Loading…
Cancel
Save