Remove deprecated `handleKeyswitchEvent()` function

This removes the `key_events.*` files that once contained the main
`handleKeyswitchEvent()` function, and all references to it.  Because
`key_events.h` was included in the main `Kaleidoscope.h` header file,
`key_defs.h` and `keyswitch_state.h` were added to that header so that other
code that relies on those things being included via `Kaleidoscope.h` will
continue to work.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1115/head
Michael Richters 3 years ago
parent 340d422a24
commit 3152270585
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -1052,6 +1052,10 @@ The following headers and names have changed:
# Removed APIs # Removed APIs
#### `::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)` #### `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. 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.

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

@ -17,7 +17,6 @@
#include "Kaleidoscope-DynamicMacros.h" #include "Kaleidoscope-DynamicMacros.h"
#include "Kaleidoscope-FocusSerial.h" #include "Kaleidoscope-FocusSerial.h"
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h"
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {

@ -19,7 +19,6 @@
#include "Arduino.h" // for PROGMEM #include "Arduino.h" // for PROGMEM
#include "kaleidoscope/device/keyboardio/Model01.h" // for Model01LEDDriver... #include "kaleidoscope/device/keyboardio/Model01.h" // for Model01LEDDriver...
#include "kaleidoscope/key_events.h"
#include "kaleidoscope/driver/keyscanner/Base_Impl.h" #include "kaleidoscope/driver/keyscanner/Base_Impl.h"
#ifndef KALEIDOSCOPE_VIRTUAL_BUILD #ifndef KALEIDOSCOPE_VIRTUAL_BUILD

@ -19,7 +19,6 @@
#include "Arduino.h" // for PROGMEM #include "Arduino.h" // for PROGMEM
#include "kaleidoscope/device/keyboardio/Model100.h" // for Model100LEDDriver... #include "kaleidoscope/device/keyboardio/Model100.h" // for Model100LEDDriver...
#include "kaleidoscope/key_events.h"
#include "kaleidoscope/driver/keyscanner/Base_Impl.h" #include "kaleidoscope/driver/keyscanner/Base_Impl.h"
#include "Wire.h" #include "Wire.h"

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

@ -17,7 +17,6 @@
#include "Kaleidoscope-Macros.h" #include "Kaleidoscope-Macros.h"
#include "Kaleidoscope-FocusSerial.h" #include "Kaleidoscope-FocusSerial.h"
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h"
// ============================================================================= // =============================================================================
// Default `macroAction()` function definitions // Default `macroAction()` function definitions

@ -21,7 +21,6 @@
#include "kaleidoscope/plugin/Macros/MacroKeyDefs.h" #include "kaleidoscope/plugin/Macros/MacroKeyDefs.h"
#include "kaleidoscope/plugin/Macros/MacroSteps.h" #include "kaleidoscope/plugin/Macros/MacroSteps.h"
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h"
// ============================================================================= // =============================================================================
// Define this function in a Kaleidoscope sketch in order to trigger Macros. // Define this function in a Kaleidoscope sketch in order to trigger Macros.

@ -18,7 +18,6 @@
#include <Kaleidoscope-OneShot.h> #include <Kaleidoscope-OneShot.h>
#include <Kaleidoscope-FocusSerial.h> #include <Kaleidoscope-FocusSerial.h>
#include "kaleidoscope/keyswitch_state.h" #include "kaleidoscope/keyswitch_state.h"
#include "kaleidoscope/key_events.h"
#include "kaleidoscope/layers.h" #include "kaleidoscope/layers.h"
namespace kaleidoscope { namespace kaleidoscope {

@ -19,7 +19,6 @@
#include "kaleidoscope/Runtime.h" #include "kaleidoscope/Runtime.h"
#include <Kaleidoscope-Ranges.h> #include <Kaleidoscope-Ranges.h>
#include "kaleidoscope/key_events.h"
#include "kaleidoscope/KeyAddrBitfield.h" #include "kaleidoscope/KeyAddrBitfield.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

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

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

@ -81,7 +81,8 @@ void setup();
#include "kaleidoscope/KeyAddr.h" #include "kaleidoscope/KeyAddr.h"
#include "kaleidoscope/KeyEvent.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/layers.h"
#include "kaleidoscope_internal/sketch_exploration/sketch_exploration.h" #include "kaleidoscope_internal/sketch_exploration/sketch_exploration.h"
#include "kaleidoscope/macro_map.h" #include "kaleidoscope/macro_map.h"

@ -30,9 +30,6 @@ class Key;
// Forward declaration required to enable friend declarations // Forward declaration required to enable friend declarations
// in class Hooks. // in class Hooks.
class kaleidoscope_; class kaleidoscope_;
#ifndef NDEPRECATED
extern void handleKeyswitchEvent(kaleidoscope::Key mappedKey, KeyAddr key_addr, uint8_t keyState);
#endif
namespace kaleidoscope { namespace kaleidoscope {
namespace plugin { namespace plugin {
@ -70,12 +67,6 @@ class Hooks {
friend class ::kaleidoscope::plugin::LEDControl; friend class ::kaleidoscope::plugin::LEDControl;
friend void ::kaleidoscope::sketch_exploration::pluginsExploreSketch(); 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: private:
// The following private functions are just to be called by classes // 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

@ -29,11 +29,6 @@
/* Messages */ /* Messages */
#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__ \ #define _DEPRECATED_MESSAGE_ON_KEYSWITCH_EVENT_V1 __NL__ \
"The `onKeyswitchEvent()` event handler is deprecated.\n" __NL__ \ "The `onKeyswitchEvent()` event handler is deprecated.\n" __NL__ \
"Please replace it with an `onKeyEvent()` handler. See the documentation\n" __NL__ \ "Please replace it with an `onKeyEvent()` handler. See the documentation\n" __NL__ \

Loading…
Cancel
Save