[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
This commit is contained in:
Drashna Jaelre 2022-03-13 17:01:47 -07:00 committed by GitHub
parent cc9a2aef0f
commit 921b9dad6c
Failed to generate hash of commit
5 changed files with 32 additions and 23 deletions

View file

@ -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) {