The main thing here is `Macros_::play`, which takes a list of bytes from PROGMEM, and plays a macro. The array is always a command, followed by arguments, and the size of the argument depends on the command: key presses and releases take a 16-bit argument, and the event is injected into the event handler flow. Waiting and interval change take a 8-bit time. Helpers are provided to make it a little bit easier to construct a macro. Of course, the `macroAction` method may do any other side effects, and is not restricted to returning a sequence of commands. Fixes #5. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>pull/58/head
parent
516d617cce
commit
44f5de357c
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#define IS_MACRO B00000001
|
||||
|
||||
#define M(n) (Key){ KEY_FLAGS|SYNTHETIC|IS_MACRO, n}
|
||||
#define Key_macroKey1 M(1)
|
||||
#define Key_macroKey2 M(2)
|
||||
#define Key_macroKey3 M(3)
|
||||
#define Key_macroKey4 M(4)
|
||||
#define Key_macroKey5 M(5)
|
||||
#define Key_macroKey6 M(6)
|
||||
#define Key_macroKey7 M(7)
|
||||
#define Key_macroKey8 M(8)
|
||||
#define Key_macroKey9 M(9)
|
||||
#define Key_macroKey10 M(10)
|
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
typedef enum {
|
||||
MACRO_ACTION_END,
|
||||
|
||||
MACRO_ACTION_STEP_INTERVAL,
|
||||
MACRO_ACTION_STEP_WAIT,
|
||||
MACRO_ACTION_STEP_KEYDOWN,
|
||||
MACRO_ACTION_STEP_KEYUP,
|
||||
} MacroActionStepType;
|
||||
|
||||
typedef uint8_t macro_t;
|
||||
|
||||
#define MACRO_NONE 0
|
||||
#define MACRO(...) ({static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; })
|
||||
|
||||
#define I(n) MACRO_ACTION_STEP_INTERVAL, n
|
||||
#define W(n) MACRO_ACTION_STEP_WAIT, n
|
||||
#define D(k) MACRO_ACTION_STEP_KEYDOWN, (Key_ ## k).raw
|
||||
#define U(k) MACRO_ACTION_STEP_KEYUP, (Key_ ## k).raw
|
||||
#define T(k) D(k), U(k)
|
||||
#define END MACRO_ACTION_END
|
Loading…
Reference in new issue