fix(sticky keys): always clear sticky key when releasing the behavior

This commit is contained in:
Okke Formsma 2020-11-30 21:50:33 +01:00 committed by Pete Johanson
parent 2ba16c2f3d
commit f86e0fff14
1 changed files with 5 additions and 8 deletions

View File

@ -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);
}
}