summaryrefslogtreecommitdiff
path: root/quantum/mousekey.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/mousekey.c')
-rw-r--r--quantum/mousekey.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/quantum/mousekey.c b/quantum/mousekey.c
index 8bafbf977a..64d0e66682 100644
--- a/quantum/mousekey.c
+++ b/quantum/mousekey.c
@@ -16,6 +16,7 @@
*/
#include <stdint.h>
+#include <string.h>
#include "keycode.h"
#include "host.h"
#include "timer.h"
@@ -209,7 +210,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 +252,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 +343,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 +358,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) {