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>
`Dr`, `Ur`, and `Tr` are similar to the already existing `D`, `U`, and
`T` helpers, but they do not prefix their argument with `Key_`. This
makes it a lot easier to create macros that use custom key codes.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Keys that have the IS_INTERNAL flag set can also have the same bit set as the
IS_MACRO bit, yet, we do not want to handle those as if they were macros. So
teach `handleMacroEvent` to skip keys with that bit set.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Use dot_a_linkage for the Keyboardio-Macros library, and as a
consequence, declare the Macros variable static instead of extern, so
that it gets compiled and linked in even when not referenced directly.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Instead of trying to include an uint16_t in an array of uint8_ts, add the flags
and the rawKey separately. Without this, macro playback would not work, because
the sequence would be corrupt.
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
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>