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;
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) {
Key key;
key.flags = flags;
key.keyCode = pgm_read_byte(macro_p++);
if (keyIsPressed(keyStates)) {
handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
kaleidoscope::hid::sendKeyboardReport();
playMacroKeyswitchEvent(key, IS_PRESSED);
}
if (keyWasPressed(keyStates)) {
handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
kaleidoscope::hid::sendKeyboardReport();
playMacroKeyswitchEvent(key, WAS_PRESSED);
}
}
@ -165,15 +168,14 @@ void Macros_::type(const char *string) {
break;
Key key = lookupAsciiCode(ascii_code);
if (key.raw == Key_NoKey.raw)
continue;
handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
kaleidoscope::hid::sendKeyboardReport();
handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
kaleidoscope::hid::sendKeyboardReport();
playMacroKeyswitchEvent(key, IS_PRESSED);
playMacroKeyswitchEvent(key, WAS_PRESSED);
}
}

Loading…
Cancel
Save