diff options
author | Okke Formsma <okke@formsma.nl> | 2021-02-09 20:20:54 +0100 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2021-02-24 07:24:27 -0500 |
commit | 0c1940bb799ec8d97bb2f80661778a1396e9277e (patch) | |
tree | ed571e878fca9ce47b9679e0016bac9a1b7c6577 /app/src/behaviors/behavior_hold_tap.c | |
parent | 89ed816c670abdc74fe02b484fe148bc5658564c (diff) |
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.
Diffstat (limited to 'app/src/behaviors/behavior_hold_tap.c')
-rw-r--r-- | app/src/behaviors/behavior_hold_tap.c | 18 |
1 files changed, 16 insertions, 2 deletions
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); } } } |