diff options
author | Okke Formsma <okke@formsma.nl> | 2020-11-30 21:50:33 +0100 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2020-12-06 00:33:20 -0500 |
commit | f86e0fff14c4c6419a1388f963c5535a4f9c201a (patch) | |
tree | cc8d56fcff03950738f4a3a24ac0823bd2eaa0de /app | |
parent | 2ba16c2f3d97ab5a244d3c91fe270e132d0b8f62 (diff) |
fix(sticky keys): always clear sticky key when releasing the behavior
Diffstat (limited to 'app')
-rw-r--r-- | app/src/behaviors/behavior_sticky_key.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index 7003e2d..7a7f136 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -109,6 +109,8 @@ static inline int release_sticky_key_behavior(struct active_sticky_key *sticky_k .position = sticky_key->position, .timestamp = timestamp, }; + + clear_sticky_key(sticky_key); return behavior_keymap_binding_released(&binding, event); } @@ -149,9 +151,7 @@ static int on_sticky_key_binding_released(struct zmk_behavior_binding *binding, if (sticky_key->modified_key_usage_page != 0 && sticky_key->modified_key_keycode != 0) { LOG_DBG("Another key was pressed while the sticky key was pressed. Act like a normal key."); - int retval = release_sticky_key_behavior(sticky_key, event.timestamp); - clear_sticky_key(sticky_key); - return retval; + return release_sticky_key_behavior(sticky_key, event.timestamp); } // No other key was pressed. Start the timer. @@ -192,9 +192,8 @@ static int sticky_key_keycode_state_changed_listener(const struct zmk_event_head // If events were queued, the timer event may be queued late or not at all. // Release the sticky key if the timer should've run out in the meantime. if (sticky_key->release_at != 0 && ev->timestamp > sticky_key->release_at) { - release_sticky_key_behavior(sticky_key, sticky_key->release_at); stop_timer(sticky_key); - clear_sticky_key(sticky_key); + release_sticky_key_behavior(sticky_key, sticky_key->release_at); continue; } @@ -213,9 +212,8 @@ static int sticky_key_keycode_state_changed_listener(const struct zmk_event_head if (sticky_key->timer_started && sticky_key->modified_key_usage_page == ev->usage_page && sticky_key->modified_key_keycode == ev->keycode) { - release_sticky_key_behavior(sticky_key, ev->timestamp); stop_timer(sticky_key); - clear_sticky_key(sticky_key); + release_sticky_key_behavior(sticky_key, ev->timestamp); } } } @@ -235,7 +233,6 @@ void behavior_sticky_key_timer_handler(struct k_work *item) { sticky_key->timer_is_cancelled = false; } else { release_sticky_key_behavior(sticky_key, sticky_key->release_at); - clear_sticky_key(sticky_key); } } |