fix NULL typecheck and add documentation note about tapping-term
This commit is contained in:
parent
6edeefa5aa
commit
67db38efb4
1 changed files with 10 additions and 8 deletions
|
@ -361,8 +361,10 @@ static int release_binding(struct active_hold_tap *hold_tap) {
|
|||
return behavior_keymap_binding_released(&binding, event);
|
||||
}
|
||||
|
||||
static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_moment decision_moment,
|
||||
int32_t other_key_down_position) {
|
||||
static void
|
||||
decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_moment decision_moment,
|
||||
int32_t other_key_down_position // use -1 if decision_moment != HT_OTHER_KEY_DOWN
|
||||
) {
|
||||
if (hold_tap->status != STATUS_UNDECIDED) {
|
||||
return;
|
||||
}
|
||||
|
@ -466,7 +468,7 @@ static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding,
|
|||
undecided_hold_tap = hold_tap;
|
||||
|
||||
if (is_quick_tap(hold_tap)) {
|
||||
decide_hold_tap(hold_tap, HT_QUICK_TAP, NULL);
|
||||
decide_hold_tap(hold_tap, HT_QUICK_TAP, -1);
|
||||
}
|
||||
|
||||
// if this behavior was queued we have to adjust the timer to only
|
||||
|
@ -489,10 +491,10 @@ static int on_hold_tap_binding_released(struct zmk_behavior_binding *binding,
|
|||
// We insert a timer event before the TH_KEY_UP event to verify.
|
||||
int work_cancel_result = k_delayed_work_cancel(&hold_tap->work);
|
||||
if (event.timestamp > (hold_tap->timestamp + hold_tap->config->tapping_term_ms)) {
|
||||
decide_hold_tap(hold_tap, HT_TIMER_EVENT, NULL);
|
||||
decide_hold_tap(hold_tap, HT_TIMER_EVENT, -1);
|
||||
}
|
||||
|
||||
decide_hold_tap(hold_tap, HT_KEY_UP, NULL);
|
||||
decide_hold_tap(hold_tap, HT_KEY_UP, -1);
|
||||
decide_retro_tap(hold_tap);
|
||||
release_binding(hold_tap);
|
||||
|
||||
|
@ -539,7 +541,7 @@ static int position_state_changed_listener(const zmk_event_t *eh) {
|
|||
// have run out.
|
||||
if (ev->timestamp >
|
||||
(undecided_hold_tap->timestamp + undecided_hold_tap->config->tapping_term_ms)) {
|
||||
decide_hold_tap(undecided_hold_tap, HT_TIMER_EVENT, NULL);
|
||||
decide_hold_tap(undecided_hold_tap, HT_TIMER_EVENT, -1);
|
||||
}
|
||||
|
||||
if (!ev->state && find_captured_keydown_event(ev->position) == NULL) {
|
||||
|
@ -554,7 +556,7 @@ static int position_state_changed_listener(const zmk_event_t *eh) {
|
|||
ev->state ? "down" : "up");
|
||||
capture_event(eh);
|
||||
decide_hold_tap(undecided_hold_tap, ev->state ? HT_OTHER_KEY_DOWN : HT_OTHER_KEY_UP,
|
||||
ev->state ? ev->position : NULL);
|
||||
ev->state ? ev->position : -1);
|
||||
return ZMK_EV_EVENT_CAPTURED;
|
||||
}
|
||||
|
||||
|
@ -600,7 +602,7 @@ void behavior_hold_tap_timer_work_handler(struct k_work *item) {
|
|||
if (hold_tap->work_is_cancelled) {
|
||||
clear_hold_tap(hold_tap);
|
||||
} else {
|
||||
decide_hold_tap(hold_tap, HT_TIMER_EVENT, NULL);
|
||||
decide_hold_tap(hold_tap, HT_TIMER_EVENT, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue