Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 728f42e

Browse files
committed
Modified mouse_timer_unref to account for errors
1 parent b4ec49e commit 728f42e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

app/src/hid_listener.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ void mouse_timer_ref() {
115115
}
116116

117117
void mouse_timer_unref() {
118-
mouse_timer_ref_count -= 1;
118+
if (mouse_timer_ref_count > 0) {
119+
mouse_timer_ref_count -= 1;
120+
}
119121
if (mouse_timer_ref_count == 0) {
120122
k_timer_stop(&mouse_timer);
121123
}
@@ -139,6 +141,7 @@ static int hid_listener_mouse_released(const struct zmk_mouse_state_changed *ev)
139141
err = zmk_hid_mouse_movement_release(ev->x, ev->y);
140142
if (err) {
141143
LOG_ERR("Unable to release button");
144+
mouse_timer_unref();
142145
return err;
143146
}
144147
mouse_timer_unref();

0 commit comments

Comments
 (0)