From 5380e74c31a933118470f3935c16e45b7f8c8142 Mon Sep 17 00:00:00 2001 From: Jan Christoph Ebersbach Date: Mon, 1 Feb 2021 21:00:59 +0100 Subject: [PATCH 1/2] fix broken activation of kinetic mouse mode --- tmk_core/common/mousekey.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tmk_core/common/mousekey.c b/tmk_core/common/mousekey.c index d8cf63f77101..4903d5ca4ac0 100644 --- a/tmk_core/common/mousekey.c +++ b/tmk_core/common/mousekey.c @@ -65,11 +65,16 @@ uint8_t mk_time_to_max = MOUSEKEY_TIME_TO_MAX; /* milliseconds between the initial key press and first repeated motion event (0-2550) */ uint8_t mk_wheel_delay = MOUSEKEY_WHEEL_DELAY / 10; /* milliseconds between repeated motion events (0-255) */ +#ifndef MK_KINETIC_SPEED uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL; +#else /* #ifndef MK_KINETIC_SPEED */ +float mk_wheel_interval = 1000.0f / MOUSEKEY_WHEEL_INITIAL_MOVEMENTS; +#endif /* #ifndef MK_KINETIC_SPEED */ uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED; uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX; # ifndef MK_COMBINED +# ifndef MK_KINETIC_SPEED static uint8_t move_unit(void) { uint16_t unit; @@ -107,8 +112,7 @@ static uint8_t wheel_unit(void) { return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit)); } -# else /* #ifndef MK_COMBINED */ -# ifndef MK_KINETIC_SPEED +# else /* #ifndef MK_KINETIC_SPEED */ /* * Kinetic movement acceleration algorithm @@ -126,10 +130,10 @@ const uint16_t mk_accelerated_speed = MOUSEKEY_ACCELERATED_SPEED; const uint16_t mk_base_speed = MOUSEKEY_BASE_SPEED; const uint16_t mk_decelerated_speed = MOUSEKEY_DECELERATED_SPEED; const uint16_t mk_initial_speed = MOUSEKEY_INITIAL_SPEED; +float speed = mk_initial_speed; -static uint8_t move_unit(void) { - float speed = mk_initial_speed; +static uint8_t move_unit(void) { if (mousekey_accel & ((1 << 0) | (1 << 2))) { speed = mousekey_accel & (1 << 2) ? mk_accelerated_speed : mk_decelerated_speed; } else if (mousekey_repeat && mouse_timer) { @@ -146,8 +150,6 @@ static uint8_t move_unit(void) { return speed > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : speed; } -float mk_wheel_interval = 1000.0f / MOUSEKEY_WHEEL_INITIAL_MOVEMENTS; - static uint8_t wheel_unit(void) { float speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS; @@ -166,7 +168,9 @@ static uint8_t wheel_unit(void) { return 1; } -# else /* #ifndef MK_KINETIC_SPEED */ +# endif /* #ifndef MK_KINETIC_SPEED */ + +# else /* #ifndef MK_COMBINED */ static uint8_t move_unit(void) { uint16_t unit; @@ -204,7 +208,6 @@ static uint8_t wheel_unit(void) { return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit)); } -# endif /* #ifndef MK_KINETIC_SPEED */ # endif /* #ifndef MK_COMBINED */ void mousekey_task(void) { From ceede3ff81b158ae0fbc72619e0763c5592bd559 Mon Sep 17 00:00:00 2001 From: Jan Christoph Ebersbach Date: Fri, 5 Feb 2021 08:11:38 +0100 Subject: [PATCH 2/2] fix: move speed into function and type-convert initial value --- tmk_core/common/mousekey.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tmk_core/common/mousekey.c b/tmk_core/common/mousekey.c index 4903d5ca4ac0..d80a042d5146 100644 --- a/tmk_core/common/mousekey.c +++ b/tmk_core/common/mousekey.c @@ -130,10 +130,10 @@ const uint16_t mk_accelerated_speed = MOUSEKEY_ACCELERATED_SPEED; const uint16_t mk_base_speed = MOUSEKEY_BASE_SPEED; const uint16_t mk_decelerated_speed = MOUSEKEY_DECELERATED_SPEED; const uint16_t mk_initial_speed = MOUSEKEY_INITIAL_SPEED; -float speed = mk_initial_speed; - static uint8_t move_unit(void) { + float speed = (float)mk_initial_speed; + if (mousekey_accel & ((1 << 0) | (1 << 2))) { speed = mousekey_accel & (1 << 2) ? mk_accelerated_speed : mk_decelerated_speed; } else if (mousekey_repeat && mouse_timer) {