From 4d22c27e8db4dc290ca6c3ff7a40e45fbee831ee Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 29 Jan 2017 08:20:03 +0100 Subject: [PATCH] Use Macros.row/.col instead of macroAction params To make the signature of `macroAction` simple, the `row` and `col` properties are not passed in every time anymore, but they are available as `Macros.row` and `Macros.col`, respectively. This keeps the function simple, but still allows access to these properties for the rarer case of needing them. Signed-off-by: Gergely Nagy --- src/Keyboardio-Macros.cpp | 8 ++++++-- src/Keyboardio-Macros.h | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Keyboardio-Macros.cpp b/src/Keyboardio-Macros.cpp index 5518b333..eb408576 100644 --- a/src/Keyboardio-Macros.cpp +++ b/src/Keyboardio-Macros.cpp @@ -1,10 +1,12 @@ #include "Keyboardio-Macros.h" __attribute__((weak)) -const macro_t *macroAction(uint8_t macroIndex, byte row, byte col, uint8_t keyState) { +const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) { return MACRO_NONE; } +byte Macros_::row, Macros_::col; + void Macros_::play(const macro_t *macro_p) { macro_t macro = END; uint8_t interval = 0; @@ -51,7 +53,9 @@ static Key handleMacroEvent(Key mappedKey, byte row, byte col, uint8_t keyState) if (!key_toggled_on(keyState)) return Key_NoKey; - const macro_t *m = macroAction(mappedKey.keyCode, row, col, keyState); + Macros_::row = row; + Macros_::col = col; + const macro_t *m = macroAction(mappedKey.keyCode, keyState); Macros.play(m); return Key_NoKey; diff --git a/src/Keyboardio-Macros.h b/src/Keyboardio-Macros.h index 7b24dd2f..e5e8b723 100644 --- a/src/Keyboardio-Macros.h +++ b/src/Keyboardio-Macros.h @@ -5,7 +5,7 @@ #include "MacroKeyDefs.h" #include "MacroSteps.h" -const macro_t *macroAction(uint8_t macroIndex, byte row, byte col, uint8_t keyState); +const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState); class Macros_ : public KeyboardioPlugin { public: @@ -14,6 +14,8 @@ class Macros_ : public KeyboardioPlugin { virtual void begin(void) final; void play(const macro_t *macro_p); + + static byte row, col; }; extern Macros_ Macros;