From 7396a8bd1d6574004a8b774effe21949206e5aaa Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 13 Nov 2016 09:41:25 +0100 Subject: [PATCH 1/2] Add the default key event handler in Keyboardio_::setup Having the default handler in the list by default prevents other things to hook up before it. Add it in Keyboardio_::setup instead, so that others have a chance to add themselves first. Signed-off-by: Gergely Nagy --- src/KeyboardioFirmware.cpp | 1 + src/key_events.cpp | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/KeyboardioFirmware.cpp b/src/KeyboardioFirmware.cpp index b342446f..00ac2a5c 100644 --- a/src/KeyboardioFirmware.cpp +++ b/src/KeyboardioFirmware.cpp @@ -5,6 +5,7 @@ Keyboardio_::Keyboardio_(void) { void Keyboardio_::setup(void) { + event_handler_hook_add (handle_key_event_default); wdt_disable(); delay(100); Keyboard.begin(); diff --git a/src/key_events.cpp b/src/key_events.cpp index 125c0043..a1f6541c 100644 --- a/src/key_events.cpp +++ b/src/key_events.cpp @@ -41,10 +41,7 @@ void handle_synthetic_key_event(Key mappedKey, uint8_t currentState, uint8_t pre } } -custom_handler_t eventHandlers[HOOK_MAX] = { - handle_key_event_default, - (custom_handler_t) NULL -}; +custom_handler_t eventHandlers[HOOK_MAX] = {NULL}; Key lookup_key(byte keymap, byte row, byte col) { Key mappedKey; From 03b4e0e325b11598b1e9d2746dff82af8d0cd0ac Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Mon, 14 Nov 2016 09:36:03 +0100 Subject: [PATCH 2/2] Add helper macros to access keys in a bitfield The RxCx set of macros help addressing key positions within the keydata the Scanner returns for us. These can be ORed together to form a pattern to match against, for example, or to look for a certain key by address, and so on. Signed-off-by: Gergely Nagy --- src/Model01.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/Model01.h b/src/Model01.h index 123304c7..d9f7c4d9 100644 --- a/src/Model01.h +++ b/src/Model01.h @@ -48,6 +48,74 @@ class Model01 { }; +#define SCANBIT(row,col) (1 << (row * 8 + (7 - col))) + +#define R0C0 SCANBIT(0, 0) +#define R0C1 SCANBIT(0, 1) +#define R0C2 SCANBIT(0, 2) +#define R0C3 SCANBIT(0, 3) +#define R0C4 SCANBIT(0, 4) +#define R0C5 SCANBIT(0, 5) +#define R0C6 SCANBIT(0, 6) +#define R0C7 SCANBIT(0, 7) +#define R1C0 SCANBIT(1, 0) +#define R1C1 SCANBIT(1, 1) +#define R1C2 SCANBIT(1, 2) +#define R1C3 SCANBIT(1, 3) +#define R1C4 SCANBIT(1, 4) +#define R1C5 SCANBIT(1, 5) +#define R1C6 SCANBIT(1, 6) +#define R1C7 SCANBIT(1, 7) +#define R2C0 SCANBIT(2, 0) +#define R2C1 SCANBIT(2, 1) +#define R2C2 SCANBIT(2, 2) +#define R2C3 SCANBIT(2, 3) +#define R2C4 SCANBIT(2, 4) +#define R2C5 SCANBIT(2, 5) +#define R2C6 SCANBIT(2, 6) +#define R2C7 SCANBIT(2, 7) +#define R3C0 SCANBIT(3, 0) +#define R3C1 SCANBIT(3, 1) +#define R3C2 SCANBIT(3, 2) +#define R3C3 SCANBIT(3, 3) +#define R3C4 SCANBIT(3, 4) +#define R3C5 SCANBIT(3, 5) +#define R3C6 SCANBIT(3, 6) +#define R3C7 SCANBIT(3, 7) + +#define R0C8 SCANBIT(0, 0) +#define R0C9 SCANBIT(0, 1) +#define R0C10 SCANBIT(0, 2) +#define R0C11 SCANBIT(0, 3) +#define R0C12 SCANBIT(0, 4) +#define R0C13 SCANBIT(0, 5) +#define R0C14 SCANBIT(0, 6) +#define R0C15 SCANBIT(0, 7) +#define R1C8 SCANBIT(1, 0) +#define R1C9 SCANBIT(1, 1) +#define R1C10 SCANBIT(1, 2) +#define R1C11 SCANBIT(1, 3) +#define R1C12 SCANBIT(1, 4) +#define R1C13 SCANBIT(1, 5) +#define R1C14 SCANBIT(1, 6) +#define R1C15 SCANBIT(1, 7) +#define R2C8 SCANBIT(2, 0) +#define R2C9 SCANBIT(2, 1) +#define R2C10 SCANBIT(2, 2) +#define R2C11 SCANBIT(2, 3) +#define R2C12 SCANBIT(2, 4) +#define R2C13 SCANBIT(2, 5) +#define R2C14 SCANBIT(2, 6) +#define R2C15 SCANBIT(2, 7) +#define R3C8 SCANBIT(3, 0) +#define R3C9 SCANBIT(3, 1) +#define R3C10 SCANBIT(3, 2) +#define R3C11 SCANBIT(3, 3) +#define R3C12 SCANBIT(3, 4) +#define R3C13 SCANBIT(3, 5) +#define R3C14 SCANBIT(3, 6) +#define R3C15 SCANBIT(3, 7) + #define LED_COUNT 64