Skip to content

Commit

Permalink
Modified mouse_timer_unref to account for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
krikun98 committed Jan 28, 2022
1 parent b4ec49e commit 728f42e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/src/hid_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ void mouse_timer_ref() {
}

void mouse_timer_unref() {
mouse_timer_ref_count -= 1;
if (mouse_timer_ref_count > 0) {
mouse_timer_ref_count -= 1;
}
if (mouse_timer_ref_count == 0) {
k_timer_stop(&mouse_timer);
}
Expand All @@ -139,6 +141,7 @@ static int hid_listener_mouse_released(const struct zmk_mouse_state_changed *ev)
err = zmk_hid_mouse_movement_release(ev->x, ev->y);
if (err) {
LOG_ERR("Unable to release button");
mouse_timer_unref();
return err;
}
mouse_timer_unref();
Expand Down

0 comments on commit 728f42e

Please sign in to comment.