Modified mouse_timer_unref to account for errors

This commit is contained in:
krikun98 2021-05-15 00:42:29 +03:00 committed by Alexander Krikun
parent c55bd0fa27
commit 1815820716

View file

@ -94,7 +94,9 @@ void mouse_timer_ref() {
} }
void mouse_timer_unref() { 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) { if (mouse_timer_ref_count == 0) {
k_timer_stop(&mouse_timer); k_timer_stop(&mouse_timer);
} }
@ -118,6 +120,7 @@ static int hid_listener_mouse_released(const struct zmk_mouse_state_changed *ev)
err = zmk_hid_mouse_movement_release(ev->x, ev->y); err = zmk_hid_mouse_movement_release(ev->x, ev->y);
if (err) { if (err) {
LOG_ERR("Unable to release button"); LOG_ERR("Unable to release button");
mouse_timer_unref();
return err; return err;
} }
mouse_timer_unref(); mouse_timer_unref();