From c2d388ca064a24e3691d9a98a5c70ebe61cf3d00 Mon Sep 17 00:00:00 2001 From: Ilya Zhuravlev Date: Sun, 22 May 2022 00:22:37 -0600 Subject: [PATCH 1/2] vial: implement keycode firewall for dynamic features --- quantum/dynamic_keymap.c | 5 ----- quantum/vial.c | 14 +++++++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index 49971ba529..670ea752f7 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -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)); diff --git a/quantum/vial.c b/quantum/vial.c index b67c168737..23d62a2fa5 100644 --- a/quantum/vial.c +++ b/quantum/vial.c @@ -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; From 6f239148fb5e0ac9bf0415c2c7893b8634bb4c9f Mon Sep 17 00:00:00 2001 From: Ilya Zhuravlev Date: Sun, 22 May 2022 01:05:24 -0600 Subject: [PATCH 2/2] keyboards: disable features to fit firmware --- keyboards/lazydesigners/the30/keymaps/vial/rules.mk | 1 + keyboards/ymdk/yd60mq/keymaps/vial/rules.mk | 1 + 2 files changed, 2 insertions(+) diff --git a/keyboards/lazydesigners/the30/keymaps/vial/rules.mk b/keyboards/lazydesigners/the30/keymaps/vial/rules.mk index 46f9f1360f..043b69911e 100644 --- a/keyboards/lazydesigners/the30/keymaps/vial/rules.mk +++ b/keyboards/lazydesigners/the30/keymaps/vial/rules.mk @@ -1,3 +1,4 @@ VIA_ENABLE = yes VIAL_ENABLE = yes LTO_ENABLE = yes +QMK_SETTINGS = no diff --git a/keyboards/ymdk/yd60mq/keymaps/vial/rules.mk b/keyboards/ymdk/yd60mq/keymaps/vial/rules.mk index 256d6a187b..543e668885 100644 --- a/keyboards/ymdk/yd60mq/keymaps/vial/rules.mk +++ b/keyboards/ymdk/yd60mq/keymaps/vial/rules.mk @@ -3,3 +3,4 @@ LTO_ENABLE = yes VIAL_ENABLE = yes QMK_SETTINGS = no TAP_DANCE_ENABLE = no +COMBO_ENABLE = no