diff --git a/app/src/mouse/Kconfig b/app/src/mouse/Kconfig index c440de58..213b305a 100644 --- a/app/src/mouse/Kconfig +++ b/app/src/mouse/Kconfig @@ -7,6 +7,10 @@ menuconfig ZMK_MOUSE if ZMK_MOUSE +config ZMK_MOUSE_TICK_DURATION + int "Mouse tick duration in ms" + default 8 + choice ZMK_MOUSE_WORK_QUEUE prompt "Work queue selection for mouse events" default ZMK_MOUSE_WORK_QUEUE_DEDICATED diff --git a/app/src/mouse/key_listener.c b/app/src/mouse/key_listener.c index d522ca9e..4b8443f7 100644 --- a/app/src/mouse/key_listener.c +++ b/app/src/mouse/key_listener.c @@ -47,7 +47,7 @@ static int mouse_timer_ref_count = 0; void mouse_timer_ref() { if (mouse_timer_ref_count == 0) { - k_timer_start(&mouse_timer, K_NO_WAIT, K_MSEC(10)); + k_timer_start(&mouse_timer, K_NO_WAIT, K_MSEC(CONFIG_ZMK_MOUSE_TICK_DURATION)); } mouse_timer_ref_count += 1; // trigger the first mouse tick event immediately diff --git a/app/src/mouse/main.c b/app/src/mouse/main.c index 7ba27c39..a36b0047 100644 --- a/app/src/mouse/main.c +++ b/app/src/mouse/main.c @@ -5,9 +5,6 @@ */ #include -#include -#include -#include #if IS_ENABLED(CONFIG_ZMK_MOUSE_WORK_QUEUE_DEDICATED) diff --git a/app/src/mouse/tick_listener.c b/app/src/mouse/tick_listener.c index a80b6069..4aec26f4 100644 --- a/app/src/mouse/tick_listener.c +++ b/app/src/mouse/tick_listener.c @@ -34,7 +34,6 @@ static float powf(float base, float exponent) { struct movement_state { int64_t start; - int64_t last_tick; struct vector2d fractional_remainder; }; @@ -52,8 +51,6 @@ static struct mouse_config scroll_config = (struct mouse_config){ .acceleration_exponent = 2.0, }; -static int64_t ms_since_last_tick(int64_t last_tick, int64_t now) { return now - last_tick; } - static int64_t ms_since_start(int64_t start, int64_t now) { int64_t move_duration = now - start; // start can be in the future if there's a delay @@ -88,20 +85,17 @@ static struct vector2d update_movement(struct movement_state *state, struct mous } if (state->start == 0) { state->start = now + config->delay_ms; - state->last_tick = now; } - int64_t tick_duration = ms_since_last_tick(state->last_tick, now); int64_t move_duration = ms_since_start(state->start, now); move = (struct vector2d){ - .x = speed(config, max_speed.x, move_duration) * tick_duration / 1000, - .y = speed(config, max_speed.y, move_duration) * tick_duration / 1000, + .x = speed(config, max_speed.x, move_duration) * CONFIG_ZMK_MOUSE_TICK_DURATION / 1000, + .y = speed(config, max_speed.y, move_duration) * CONFIG_ZMK_MOUSE_TICK_DURATION / 1000, }; track_remainder(&(move.x), &state->fractional_remainder.x); track_remainder(&(move.y), &state->fractional_remainder.y); - state->last_tick = now; return move; }