Unify repeated code to a codepath. Saves us 16 bytes

pull/365/head
Jesse Vincent 7 years ago
parent cd847a7ead
commit a9068d16d4
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -8,18 +8,21 @@ const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
byte Macros_::row, Macros_::col; byte Macros_::row, Macros_::col;
void playMacroKeyswitchEvent(Key key, uint8_t flags) {
handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, INJECTED | flags);
kaleidoscope::hid::sendKeyboardReport();
}
static void readKeyCodeAndPlay(const macro_t *macro_p, uint8_t flags, uint8_t keyStates) { static void readKeyCodeAndPlay(const macro_t *macro_p, uint8_t flags, uint8_t keyStates) {
Key key; Key key;
key.flags = flags; key.flags = flags;
key.keyCode = pgm_read_byte(macro_p++); key.keyCode = pgm_read_byte(macro_p++);
if (keyIsPressed(keyStates)) { if (keyIsPressed(keyStates)) {
handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED); playMacroKeyswitchEvent(key, IS_PRESSED);
kaleidoscope::hid::sendKeyboardReport();
} }
if (keyWasPressed(keyStates)) { if (keyWasPressed(keyStates)) {
handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED); playMacroKeyswitchEvent(key, WAS_PRESSED);
kaleidoscope::hid::sendKeyboardReport();
} }
} }
@ -170,10 +173,9 @@ void Macros_::type(const char *string) {
if (key.raw == Key_NoKey.raw) if (key.raw == Key_NoKey.raw)
continue; continue;
handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED); playMacroKeyswitchEvent(key, IS_PRESSED);
kaleidoscope::hid::sendKeyboardReport(); playMacroKeyswitchEvent(key, WAS_PRESSED);
handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
kaleidoscope::hid::sendKeyboardReport();
} }
} }

Loading…
Cancel
Save