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 <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago
parent ace478116f
commit 4d22c27e8d

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

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

Loading…
Cancel
Save