dynamic_keymap: support vial 2-byte macros

This commit is contained in:
Ilya Zhuravlev
2022-01-03 08:51:14 -05:00
parent 53a41dcfab
commit 54b14e8a7f
3 changed files with 39 additions and 5 deletions

View File

@ -480,6 +480,13 @@ void dynamic_keymap_macro_reset(void) {
}
}
static uint16_t decode_keycode(uint16_t kc) {
/* map 0xFF01 => 0x0100; 0xFF02 => 0x0200, etc */
if (kc > 0xFF00)
return (kc & 0xFF) << 8;
return kc;
}
void dynamic_keymap_macro_send(uint8_t id) {
if (id >= DYNAMIC_KEYMAP_MACRO_COUNT) {
return;
@ -534,6 +541,27 @@ void dynamic_keymap_macro_send(uint8_t id) {
data[2] = eeprom_read_byte(p++);
if (data[2] != 0)
send_string(data);
} else if (data[1] == VIAL_MACRO_EXT_TAP || data[1] == VIAL_MACRO_EXT_DOWN || data[1] == VIAL_MACRO_EXT_UP) {
data[2] = eeprom_read_byte(p++);
if (data[2] != 0) {
data[3] = eeprom_read_byte(p++);
if (data[3] != 0) {
uint16_t kc;
memcpy(&kc, &data[2], sizeof(kc));
kc = decode_keycode(kc);
switch (data[1]) {
case VIAL_MACRO_EXT_TAP:
vial_keycode_tap(kc);
break;
case VIAL_MACRO_EXT_DOWN:
vial_keycode_down(kc);
break;
case VIAL_MACRO_EXT_UP:
vial_keycode_up(kc);
break;
}
}
}
} else if (data[1] == SS_DELAY_CODE) {
// For delay, decode the delay and wait_ms for that amount
uint8_t d0 = eeprom_read_byte(p++);