Merge branch 'kc-firewall' into vial

This commit is contained in:
Ilya Zhuravlev 2022-05-22 01:25:31 -06:00
commit 08ae881210
4 changed files with 15 additions and 6 deletions

View file

@ -1,3 +1,4 @@
VIA_ENABLE = yes
VIAL_ENABLE = yes
LTO_ENABLE = yes
QMK_SETTINGS = no

View file

@ -3,3 +3,4 @@ LTO_ENABLE = yes
VIAL_ENABLE = yes
QMK_SETTINGS = no
TAP_DANCE_ENABLE = no
COMBO_ENABLE = no

View file

@ -183,11 +183,6 @@ void dynamic_keymap_set_encoder(uint8_t layer, uint8_t idx, uint8_t dir, uint16_
if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || idx >= NUMBER_OF_ENCODERS || dir > 1)
return;
#ifdef VIAL_ENABLE
if (keycode == RESET && !vial_unlocked)
return;
#endif
void *address = dynamic_keymap_encoder_to_eeprom_address(layer, idx, dir);
eeprom_update_byte(address, (uint8_t)(keycode >> 8));
eeprom_update_byte(address + 1, (uint8_t)(keycode & 0xFF));

View file

@ -74,6 +74,12 @@ void vial_init(void) {
#endif
}
__attribute__((unused)) static uint16_t vial_keycode_firewall(uint16_t in) {
if (in == RESET && !vial_unlocked)
return 0;
return in;
}
void vial_handle_cmd(uint8_t *msg, uint8_t length) {
/* All packets must be fixed 32 bytes */
if (length != VIAL_RAW_EPSIZE)
@ -130,7 +136,7 @@ void vial_handle_cmd(uint8_t *msg, uint8_t length) {
break;
}
case vial_set_encoder: {
dynamic_keymap_set_encoder(msg[2], msg[3], msg[4], (msg[5] << 8) | msg[6]);
dynamic_keymap_set_encoder(msg[2], msg[3], msg[4], vial_keycode_firewall((msg[5] << 8) | msg[6]));
break;
}
#endif
@ -236,6 +242,10 @@ void vial_handle_cmd(uint8_t *msg, uint8_t length) {
uint8_t idx = msg[3];
vial_tap_dance_entry_t td;
memcpy(&td, &msg[4], sizeof(td));
td.on_tap = vial_keycode_firewall(td.on_tap);
td.on_hold = vial_keycode_firewall(td.on_hold);
td.on_double_tap = vial_keycode_firewall(td.on_double_tap);
td.on_tap_hold = vial_keycode_firewall(td.on_tap_hold);
msg[0] = dynamic_keymap_set_tap_dance(idx, &td);
reload_tap_dance();
break;
@ -253,6 +263,7 @@ void vial_handle_cmd(uint8_t *msg, uint8_t length) {
uint8_t idx = msg[3];
vial_combo_entry_t entry;
memcpy(&entry, &msg[4], sizeof(entry));
entry.output = vial_keycode_firewall(entry.output);
msg[0] = dynamic_keymap_set_combo(idx, &entry);
reload_combo();
break;
@ -270,6 +281,7 @@ void vial_handle_cmd(uint8_t *msg, uint8_t length) {
uint8_t idx = msg[3];
vial_key_override_entry_t entry;
memcpy(&entry, &msg[4], sizeof(entry));
entry.replacement = vial_keycode_firewall(entry.replacement);
msg[0] = dynamic_keymap_set_key_override(idx, &entry);
reload_key_override();
break;