From 0c1940bb799ec8d97bb2f80661778a1396e9277e Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Tue, 9 Feb 2021 20:20:54 +0100 Subject: feature(hold-tap): no-hold-flash for retro taps This is an improvement on retro-tap, solving the 'flashing hold' issue users people experience. When the tapping-term expires, the hold key is normally pressed. When retro-tap is enabled, this is undesirable; only an interrupted hold-tap should trigger the hold behavior. This change disables the hold behavior for the 'STATUS_HOLD_TIMER' state when retro-tap is enabled, and makes sure the 'STATUS_HOLD_INTERRUPT' state will be triggered when appropriate. --- app/src/behaviors/behavior_hold_tap.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'app/src') diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 739042a..376633a 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -317,6 +317,10 @@ static inline const char *decision_moment_str(enum decision_moment decision_mome } static int press_binding(struct active_hold_tap *hold_tap) { + if (hold_tap->config->retro_tap && hold_tap->status == STATUS_HOLD_TIMER) { + return 0; + } + struct zmk_behavior_binding_event event = { .position = hold_tap->position, .timestamp = hold_tap->timestamp, @@ -335,6 +339,10 @@ static int press_binding(struct active_hold_tap *hold_tap) { } static int release_binding(struct active_hold_tap *hold_tap) { + if (hold_tap->config->retro_tap && hold_tap->status == STATUS_HOLD_TIMER) { + return 0; + } + struct zmk_behavior_binding_event event = { .position = hold_tap->position, .timestamp = hold_tap->timestamp, @@ -396,12 +404,18 @@ static void decide_retro_tap(struct active_hold_tap *hold_tap) { } } -static void update_hold_status_for_retro_tap(uint32_t position) { +static void update_hold_status_for_retro_tap(uint32_t ignore_position) { for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { struct active_hold_tap *hold_tap = &active_hold_taps[i]; - if (hold_tap->position != position && hold_tap->status == STATUS_HOLD_TIMER) { + if (hold_tap->position == ignore_position || + hold_tap->position == ZMK_BHV_HOLD_TAP_POSITION_NOT_USED || + hold_tap->config->retro_tap == false) { + continue; + } + if (hold_tap->status == STATUS_HOLD_TIMER) { LOG_DBG("Update hold tap %d status to hold-interrupt", hold_tap->position); hold_tap->status = STATUS_HOLD_INTERRUPT; + press_binding(hold_tap); } } } -- cgit v1.2.3