dynamic_keymap: support vial 2-byte macros
This commit is contained in:
parent
53a41dcfab
commit
54b14e8a7f
@ -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++);
|
||||
|
@ -284,7 +284,7 @@ void vial_handle_cmd(uint8_t *msg, uint8_t length) {
|
||||
|
||||
uint16_t g_vial_magic_keycode_override;
|
||||
|
||||
static void vial_keycode_down(uint16_t keycode) {
|
||||
void vial_keycode_down(uint16_t keycode) {
|
||||
g_vial_magic_keycode_override = keycode;
|
||||
|
||||
if (keycode <= QK_MODS_MAX) {
|
||||
@ -296,7 +296,7 @@ static void vial_keycode_down(uint16_t keycode) {
|
||||
}
|
||||
}
|
||||
|
||||
static void vial_keycode_up(uint16_t keycode) {
|
||||
void vial_keycode_up(uint16_t keycode) {
|
||||
g_vial_magic_keycode_override = keycode;
|
||||
|
||||
if (keycode <= QK_MODS_MAX) {
|
||||
@ -308,9 +308,7 @@ static void vial_keycode_up(uint16_t keycode) {
|
||||
}
|
||||
}
|
||||
|
||||
static void vial_keycode_tap(uint16_t keycode) __attribute__((unused));
|
||||
|
||||
static void vial_keycode_tap(uint16_t keycode) {
|
||||
void vial_keycode_tap(uint16_t keycode) {
|
||||
vial_keycode_down(keycode);
|
||||
qs_wait_ms(QS_tap_code_delay);
|
||||
vial_keycode_up(keycode);
|
||||
|
@ -63,6 +63,14 @@ enum {
|
||||
dynamic_vial_key_override_set = 0x06,
|
||||
};
|
||||
|
||||
#define VIAL_MACRO_EXT_TAP 5
|
||||
#define VIAL_MACRO_EXT_DOWN 6
|
||||
#define VIAL_MACRO_EXT_UP 7
|
||||
|
||||
void vial_keycode_down(uint16_t keycode);
|
||||
void vial_keycode_up(uint16_t keycode);
|
||||
void vial_keycode_tap(uint16_t keycode);
|
||||
|
||||
/* Fake position in keyboard matrix, can't use 255 as that is immediately rejected by IS_NOEVENT
|
||||
used to send arbitrary keycodes thru process_record_quantum_helper */
|
||||
#define VIAL_MATRIX_MAGIC 254
|
||||
|
Loading…
Reference in New Issue
Block a user