From 921b9dad6c37575215231b34a3492ffb38eaeec2 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sun, 13 Mar 2022 17:01:47 -0700 Subject: [Core] Move `has_mouse_report_changed` function to `report.c` (#16543) * Move 'has_mouse_report_changed' checkto report.c * change mousekeys to use memcpy * fix linting issues --- quantum/mousekey.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'quantum/mousekey.c') diff --git a/quantum/mousekey.c b/quantum/mousekey.c index 8bafbf977a..0cbb472045 100644 --- a/quantum/mousekey.c +++ b/quantum/mousekey.c @@ -209,7 +209,7 @@ static uint8_t wheel_unit(void) { void mousekey_task(void) { // report cursor and scroll movement independently - report_mouse_t const tmpmr = mouse_report; + report_mouse_t tmpmr = mouse_report; mouse_report.x = 0; mouse_report.y = 0; @@ -251,8 +251,10 @@ void mousekey_task(void) { } } - if (mouse_report.x || mouse_report.y || mouse_report.v || mouse_report.h) mousekey_send(); - mouse_report = tmpmr; + if (has_mouse_report_changed(&mouse_report, &tmpmr)) { + mousekey_send(); + } + memcpy(&mouse_report, &tmpmr, sizeof(tmpmr)); } void mousekey_on(uint8_t code) { @@ -340,11 +342,11 @@ uint16_t w_intervals[mkspd_COUNT] = {MK_W_INTERVAL_UNMOD, MK_W_INTERVAL_0 void mousekey_task(void) { // report cursor and scroll movement independently - report_mouse_t const tmpmr = mouse_report; - mouse_report.x = 0; - mouse_report.y = 0; - mouse_report.v = 0; - mouse_report.h = 0; + report_mouse_t tmpmr = mouse_report; + mouse_report.x = 0; + mouse_report.y = 0; + mouse_report.v = 0; + mouse_report.h = 0; if ((tmpmr.x || tmpmr.y) && timer_elapsed(last_timer_c) > c_intervals[mk_speed]) { mouse_report.x = tmpmr.x; @@ -355,8 +357,10 @@ void mousekey_task(void) { mouse_report.h = tmpmr.h; } - if (mouse_report.x || mouse_report.y || mouse_report.v || mouse_report.h) mousekey_send(); - mouse_report = tmpmr; + if (has_mouse_report_changed(&mouse_report, &tmpmr)) { + mousekey_send(); + } + memcpy(&mouse_report, &tmpmr, sizeof(tmpmr)); } void adjust_speed(void) { -- cgit v1.2.3 From 86a35483a12a12bcf8d0005ebc7e4e2bca3ab5b3 Mon Sep 17 00:00:00 2001 From: jack <0x6A73@pm.me> Date: Sun, 13 Mar 2022 19:53:53 -0600 Subject: Mousekeys fix (#16640) --- quantum/mousekey.c | 1 + 1 file changed, 1 insertion(+) (limited to 'quantum/mousekey.c') diff --git a/quantum/mousekey.c b/quantum/mousekey.c index 0cbb472045..64d0e66682 100644 --- a/quantum/mousekey.c +++ b/quantum/mousekey.c @@ -16,6 +16,7 @@ */ #include +#include #include "keycode.h" #include "host.h" #include "timer.h" -- cgit v1.2.3 From 90eef4cd153cdc1b00d973e6abb029828f656294 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Sat, 14 May 2022 07:26:12 +0200 Subject: Fix kinetic mouse mode (#16951) Co-authored-by: Jan Christoph Ebersbach --- quantum/mousekey.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'quantum/mousekey.c') diff --git a/quantum/mousekey.c b/quantum/mousekey.c index 64d0e66682..a15bd8f13e 100644 --- a/quantum/mousekey.c +++ b/quantum/mousekey.c @@ -66,11 +66,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) */ -uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL; +# 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; @@ -108,8 +113,7 @@ static uint8_t wheel_unit(void) { return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit)); } -# else /* #ifndef MK_COMBINED */ -# ifdef MK_KINETIC_SPEED +# else /* #ifndef MK_KINETIC_SPEED */ /* * Kinetic movement acceleration algorithm @@ -129,7 +133,7 @@ const uint16_t mk_decelerated_speed = MOUSEKEY_DECELERATED_SPEED; const uint16_t mk_initial_speed = MOUSEKEY_INITIAL_SPEED; static uint8_t move_unit(void) { - float speed = mk_initial_speed; + float speed = (float)mk_initial_speed; if (mousekey_accel & ((1 << 0) | (1 << 2))) { speed = mousekey_accel & (1 << 2) ? mk_accelerated_speed : mk_decelerated_speed; @@ -147,8 +151,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; @@ -167,7 +169,8 @@ 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; @@ -205,8 +208,7 @@ 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 */ +# endif /* #ifndef MK_COMBINED */ void mousekey_task(void) { // report cursor and scroll movement independently -- cgit v1.2.3 From cd8d2b7f7f0611f04b503479181fd7e9acbe8358 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sat, 14 May 2022 13:03:07 -0700 Subject: Revert "Fix kinetic mouse mode (#16951)" (#17095) --- quantum/mousekey.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'quantum/mousekey.c') diff --git a/quantum/mousekey.c b/quantum/mousekey.c index a15bd8f13e..64d0e66682 100644 --- a/quantum/mousekey.c +++ b/quantum/mousekey.c @@ -66,16 +66,11 @@ 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_interval = MOUSEKEY_WHEEL_INTERVAL; 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; @@ -113,7 +108,8 @@ static uint8_t wheel_unit(void) { return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit)); } -# else /* #ifndef MK_KINETIC_SPEED */ +# else /* #ifndef MK_COMBINED */ +# ifdef MK_KINETIC_SPEED /* * Kinetic movement acceleration algorithm @@ -133,7 +129,7 @@ const uint16_t mk_decelerated_speed = MOUSEKEY_DECELERATED_SPEED; const uint16_t mk_initial_speed = MOUSEKEY_INITIAL_SPEED; static uint8_t move_unit(void) { - float speed = (float)mk_initial_speed; + float speed = mk_initial_speed; if (mousekey_accel & ((1 << 0) | (1 << 2))) { speed = mousekey_accel & (1 << 2) ? mk_accelerated_speed : mk_decelerated_speed; @@ -151,6 +147,8 @@ 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; @@ -169,8 +167,7 @@ static uint8_t wheel_unit(void) { return 1; } -# endif /* #ifndef MK_KINETIC_SPEED */ -# else /* #ifndef MK_COMBINED */ +# else /* #ifndef MK_KINETIC_SPEED */ static uint8_t move_unit(void) { uint16_t unit; @@ -208,7 +205,8 @@ static uint8_t wheel_unit(void) { return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit)); } -# endif /* #ifndef MK_COMBINED */ +# endif /* #ifndef MK_KINETIC_SPEED */ +# endif /* #ifndef MK_COMBINED */ void mousekey_task(void) { // report cursor and scroll movement independently -- cgit v1.2.3