Macros: A way to run the macro on keypress only

Add a `MACRODOWN` convenience macro, that will only run the given macro
when the key toggled on. It assumes that it is called from a function
with a `keyState` argument. If the key is not pressed, the macro will
evaluate to `MACRO_NONE`.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/63/head
Gergely Nagy 8 years ago
parent e510970291
commit 31c7133e04

@ -13,6 +13,7 @@ typedef uint8_t macro_t;
#define MACRO_NONE 0
#define MACRO(...) ({static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; })
#define MACRODOWN(...) (key_toggled_on(keyState) ? MACRO(__VA_ARGS__) : MACRO_NONE)
#define I(n) MACRO_ACTION_STEP_INTERVAL, n
#define W(n) MACRO_ACTION_STEP_WAIT, n

Loading…
Cancel
Save