From f406892ec373481f2f2ca5969bb4e8aef51112a2 Mon Sep 17 00:00:00 2001 From: Ilya Zhuravlev Date: Sat, 9 Oct 2021 14:33:26 -0400 Subject: [PATCH 1/2] vial: process tap dance release early, fix https://github.com/vial-kb/vial-gui/issues/50 --- quantum/process_keycode/process_tap_dance.c | 2 +- quantum/quantum.c | 3 +++ quantum/vial.c | 30 +++++++++++++++++++++ quantum/vial.h | 2 ++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c index c8712d919f..c719fef2f5 100644 --- a/quantum/process_keycode/process_tap_dance.c +++ b/quantum/process_keycode/process_tap_dance.c @@ -86,7 +86,7 @@ static inline void _process_tap_dance_action_fn(qk_tap_dance_state_t *state, voi static inline void process_tap_dance_action_on_each_tap(qk_tap_dance_action_t *action) { _process_tap_dance_action_fn(&action->state, action->user_data, action->fn.on_each_tap); } -static inline void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action) { +void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action) { if (action->state.finished) return; action->state.finished = true; add_mods(action->state.oneshot_mods); diff --git a/quantum/quantum.c b/quantum/quantum.c index 1b0b358b80..0c8209cf66 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -245,6 +245,9 @@ bool process_record_quantum_helper(uint16_t keycode, keyrecord_t *record) { #endif #if defined(VIA_ENABLE) process_record_via(keycode, record) && +#endif +#if defined(VIAL_ENABLE) + process_record_vial(keycode, record) && #endif process_record_kb(keycode, record) && #if defined(SEQUENCER_ENABLE) diff --git a/quantum/vial.c b/quantum/vial.c index 23968e0093..4881393462 100644 --- a/quantum/vial.c +++ b/quantum/vial.c @@ -514,3 +514,33 @@ static void reload_combo(void) { } } #endif + +#ifdef VIAL_TAP_DANCE_ENABLE +void process_tap_dance_action_on_dance_finished(qk_tap_dance_action_t *action); +#endif + +bool process_record_vial(uint16_t keycode, keyrecord_t *record) { +#ifdef VIAL_TAP_DANCE_ENABLE + /* process releases before tap-dance timeout arrives */ + if (!record->event.pressed && keycode >= QK_TAP_DANCE && keycode <= QK_TAP_DANCE_MAX) { + uint16_t idx = keycode - QK_TAP_DANCE; + if (dynamic_keymap_get_tap_dance(idx, &td_entry) != 0) + return true; + + qk_tap_dance_action_t *action = &tap_dance_actions[idx]; + + /* only care about 2 possibilities here + - tap and hold set, everything else unset: process first release early (count == 1) + - double tap set: process second release early (count == 2) + */ + if ((action->state.count == 1 && td_entry.on_tap && td_entry.on_hold && !td_entry.on_double_tap && !td_entry.on_tap_hold) + || (action->state.count == 2 && td_entry.on_double_tap)) { + action->state.pressed = false; + process_tap_dance_action_on_dance_finished(action); + /* reset_tap_dance() will get called in process_tap_dance() */ + } + } +#endif + + return true; +} diff --git a/quantum/vial.h b/quantum/vial.h index 3ace285444..9d8ef253f6 100644 --- a/quantum/vial.h +++ b/quantum/vial.h @@ -20,12 +20,14 @@ #include #include "dynamic_keymap_eeprom.h" +#include "action.h" #define VIAL_PROTOCOL_VERSION ((uint32_t)0x00000004) #define VIAL_RAW_EPSIZE 32 void vial_init(void); void vial_handle_cmd(uint8_t *data, uint8_t length); +bool process_record_vial(uint16_t keycode, keyrecord_t *record); #ifdef VIAL_ENCODERS_ENABLE bool vial_encoder_update(uint8_t index, bool clockwise); From 04698e6d44b8ba6c61e02be42f0bb7e639e7077d Mon Sep 17 00:00:00 2001 From: Ilya Zhuravlev Date: Fri, 22 Oct 2021 19:45:56 -0400 Subject: [PATCH 2/2] yd60mq: reduce firmware size --- keyboards/yd60mq/keymaps/vial/rules.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/keyboards/yd60mq/keymaps/vial/rules.mk b/keyboards/yd60mq/keymaps/vial/rules.mk index 148dfa63c4..256d6a187b 100644 --- a/keyboards/yd60mq/keymaps/vial/rules.mk +++ b/keyboards/yd60mq/keymaps/vial/rules.mk @@ -2,3 +2,4 @@ VIA_ENABLE = yes LTO_ENABLE = yes VIAL_ENABLE = yes QMK_SETTINGS = no +TAP_DANCE_ENABLE = no