Introduced key address version of handler onKeyswitchEvent

Signed-off-by: Florian Fleissner <florian.fleissner@inpartik.de>
pull/640/head
Florian Fleissner 6 years ago committed by Jesse Vincent
parent 359ac67391
commit 00552193e9

@ -54,6 +54,7 @@ typedef HARDWARE_IMPLEMENTATION::KeyAddr KeyAddr;
#define COLS (KeyboardHardware.matrix_columns)
#define LED_COUNT (KeyboardHardware.led_count)
#include "kaleidoscope/KeyAddr.h"
#include "kaleidoscope/key_events.h"
#include "kaleidoscope/hid.h"
#include "kaleidoscope/layers.h"

@ -0,0 +1,23 @@
/* 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 KALEIDOSCOPE_HARDWARE_H
extern HARDWARE_IMPLEMENTATION KeyboardHardware;
typedef HARDWARE_IMPLEMENTATION::KeyAddr KeyAddr;

@ -84,6 +84,15 @@
// The list of parameters as they would be passed to a call to the handler.
// Parameter names must match the names assigned to the call arguments.
#define _DEPRECATED_MESSAGE_ON_KEYSWITCH_EVENT_HANDLER_V1 \
"The event handler signature\n" __NL__ \
"EventHandlerResult onKeyswitchEvent(Key &mappedKey, byte row, byte col, \n" __NL__ \
" uint8_t keyState)\n" __NL__ \
"has been deprecated. Please use the new signature\n" __NL__ \
"EventHandlerResult onKeyswitchEvent(Key &mappedKey, KeyAddr key_addr, \n" __NL__ \
" uint8_t keyState)\n" __NL__ \
"instead."
#define _FOR_EACH_EVENT_HANDLER(OPERATION, ...) __NL__ \
__NL__ \
OPERATION(onSetup, __NL__ \
@ -100,6 +109,7 @@
_NOT_ABORTABLE, __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__ \
@ -109,11 +119,26 @@
/* will stop processing there. */ __NL__ \
OPERATION(onKeyswitchEvent, __NL__ \
1, __NL__ \
_CURRENT_IMPLEMENTATION, __NL__ \
DEPRECATED(ON_KEYSWITCH_EVENT_HANDLER_V1), __NL__ \
_ABORTABLE, __NL__ \
(Key &mappedKey, byte row, byte col, uint8_t keyState), __NL__ \
(mappedKey, row, col, keyState), ##__VA_ARGS__) __NL__ \
__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__ \
2, __NL__ \
_CURRENT_IMPLEMENTATION, __NL__ \
_ABORTABLE, __NL__ \
(Key &mappedKey, KeyAddr key_addr, uint8_t keyState), __NL__ \
(mappedKey, key_addr, keyState), ##__VA_ARGS__) __NL__ \
__NL__ \
__NL__ \
/* Called by an external plugin (such as Kaleidoscope-FocusSerial) */ __NL__ \
/* via Kaleidoscope::onFocusEvent. This is where Focus events can */ __NL__ \
/* be handled. The function can return EventHandlerResult::OK, and */ __NL__ \
@ -181,9 +206,10 @@
OP(beforeEachCycle, 1) __NL__ \
END(beforeEachCycle, 1) __NL__ \
__NL__ \
START(onKeyswitchEvent, 1) __NL__ \
START(onKeyswitchEvent, 1, 2) __NL__ \
OP(onKeyswitchEvent, 1) __NL__ \
END(onKeyswitchEvent, 1) __NL__ \
OP(onKeyswitchEvent, 2) __NL__ \
END(onKeyswitchEvent, 1, 2) __NL__ \
__NL__ \
START(onFocusEvent, 1) __NL__ \
OP(onFocusEvent, 1) __NL__ \

@ -14,6 +14,7 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Kaleidoscope.h"
#include "kaleidoscope/hooks.h"
namespace kaleidoscope {

@ -22,6 +22,7 @@ namespace kaleidoscope {
union Key;
}
#include "kaleidoscope/KeyAddr.h"
#include "kaleidoscope/plugin.h"
#include "kaleidoscope/event_handlers.h"

@ -48,6 +48,10 @@
#define __STRINGIZE(S) #S
#define STRINGIZE(S) __STRINGIZE(S)
#define GLUE2(A, B) A##B
#define GLUE3(A, B, C) A##B##C
#define GLUE4(A, B, C, D) A##B##C##D
// Allow for the creation of verbose messages in static_asserts
//
#define VERBOSE_STATIC_ASSERT_HEADER \

@ -73,7 +73,7 @@ template<typename Plugin__> struct
static constexpr bool value = true;
};
#define _NOOP(...) __NL__ \
#define _NOOP(...) __NL__
#define _DEFINE_IMPLEMENTATION_CHECK_CLASSES(HOOK_NAME, ...) \
__NL__ \
@ -98,7 +98,7 @@ template<typename Plugin__> struct
* to do check if a plugin defines a hook method with a specific __NL__ \
* signature. __NL__ \
*/ __NL__ \
DEFINE_HAS_METHOD_TRAITS(Plugin, HOOK_NAME, __NL__ \
DEFINE_HAS_METHOD_TRAITS(GLUE2(Plugin, HOOK_VERSION), HOOK_NAME, __NL__ \
kaleidoscope::EventHandlerResult, __NL__ \
SIGNATURE) __NL__ \
__NL__ \
@ -107,7 +107,7 @@ template<typename Plugin__> struct
*/ __NL__ \
template<typename Plugin__> __NL__ \
struct HookVersionImplemented_##HOOK_NAME<Plugin__, HOOK_VERSION> __NL__ \
: public Plugin_HasMethod_##HOOK_NAME<Plugin__> __NL__ \
: public GLUE4(Plugin, HOOK_VERSION, _HasMethod_, HOOK_NAME)<Plugin__> __NL__ \
{};
#define _PREPARE_EVENT_HANDLER_SIGNATURE_CHECK_START(HOOK_NAME, ...) \
@ -219,7 +219,7 @@ template<typename Plugin__> struct
*/ __NL__ \
__attribute__((unused)) constexpr bool dummy2 __NL__ \
= ___________Culprit_Plugin___________ __NL__ \
<PLUGIN_TYPE, !handler_has_wrong_signature>::value; __NL__ \
<PLUGIN_TYPE, !handler_ambiguously_implemented>::value; __NL__ \
}
#define _PREPARE_EVENT_HANDLER_SIGNATURE_CHECK \

@ -25,7 +25,7 @@
* implements a method with given signature. __NL__ \
*/ __NL__ \
template<typename Class__> __NL__ \
struct PREFIX##_HasMethod_##METHOD_NAME __NL__ \
struct GLUE3(PREFIX, _HasMethod_, METHOD_NAME) __NL__ \
{ __NL__ \
/* Define a pointer to member function with the correct __NL__ \
* argument signature. The newly defined type is named __NL__ \

Loading…
Cancel
Save