Introduce a way to describe a tap step

Instead of having to use a keydown & keyup step each time we tap a key, use a
combined event that does both. While this adds a tiny bit of code to
`Macros.play`, if our macros have many key taps (which by and large the most
common thing), we save a lot more. Three bytes per tap!

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago
parent 634dca4a2c
commit 55b035be86

@ -37,6 +37,14 @@ void Macros_::play(const macro_t *macro_p) {
handle_key_event(key, 255, 255, WAS_PRESSED | INJECTED); handle_key_event(key, 255, 255, WAS_PRESSED | INJECTED);
Keyboard.sendReport(); Keyboard.sendReport();
break; break;
case MACRO_ACTION_STEP_TAP:
key.flags = pgm_read_byte(macro_p++);
key.keyCode = pgm_read_byte(macro_p++);
handle_key_event(key, 255, 255, IS_PRESSED | INJECTED);
Keyboard.sendReport();
handle_key_event(key, 255, 255, WAS_PRESSED | INJECTED);
Keyboard.sendReport();
break;
case END: case END:
default: default:
return; return;

@ -7,6 +7,7 @@ typedef enum {
MACRO_ACTION_STEP_WAIT, MACRO_ACTION_STEP_WAIT,
MACRO_ACTION_STEP_KEYDOWN, MACRO_ACTION_STEP_KEYDOWN,
MACRO_ACTION_STEP_KEYUP, MACRO_ACTION_STEP_KEYUP,
MACRO_ACTION_STEP_TAP
} MacroActionStepType; } MacroActionStepType;
typedef uint8_t macro_t; typedef uint8_t macro_t;
@ -21,6 +22,6 @@ typedef uint8_t macro_t;
#define D(k) Dr(Key_ ## k) #define D(k) Dr(Key_ ## k)
#define Ur(k) MACRO_ACTION_STEP_KEYUP, (k).flags, (k).keyCode #define Ur(k) MACRO_ACTION_STEP_KEYUP, (k).flags, (k).keyCode
#define U(k) Ur(Key_ ## k) #define U(k) Ur(Key_ ## k)
#define Tr(k) Dr(k), Ur(k) #define Tr(k) MACRO_ACTION_STEP_TAP, (k).flags, (k).keyCode
#define T(k) D(k), U(k) #define T(k) Tr(Key_ ## k)
#define END MACRO_ACTION_END #define END MACRO_ACTION_END

Loading…
Cancel
Save