From be58a6847364a9a8243a77b5398e9c209628d1ef Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 6 May 2019 08:35:01 -0700 Subject: [PATCH] Re-fix Mousekey Movements (#5740) * Re-fix Mousekey Movements After the new movement model was instroduced, it broke diagonal momement, again. Reapplying fix from #3147 to both old and new acceleration method. * Make diagonal mouse report checks more readable Co-Authored-By: drashna --- changelog.md | 1 + tmk_core/common/mousekey.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index cdebe64f43..053d554125 100644 --- a/changelog.md +++ b/changelog.md @@ -16,3 +16,4 @@ 05-05-2019 - New keycode macro (XP) for shifted character pairs using UNICODEMAP, and bugfixes/improvements 05-05-2019 - Add `LINK_TIME_OPTIMIZATION_ENABLE` to enable LTO and disable problematic features that cause LTO to fail 05-05-2019 - Fix issue with Space Cadet +05-06-2019 - More readable fix of Mousekeys issue diff --git a/tmk_core/common/mousekey.c b/tmk_core/common/mousekey.c index 5b85268a03..bb08576b9f 100644 --- a/tmk_core/common/mousekey.c +++ b/tmk_core/common/mousekey.c @@ -114,9 +114,9 @@ void mousekey_task(void) { /* diagonal move [1/sqrt(2)] */ if (mouse_report.x && mouse_report.y) { mouse_report.x = times_inv_sqrt2(mouse_report.x); - mouse_report.x = mouse_report.x == 0 ? 1 : mouse_report.x; + if (mouse_report.x == 0) { mouse_report.x = 1; } mouse_report.y = times_inv_sqrt2(mouse_report.y); - mouse_report.y = mouse_report.y == 0 ? 1 : mouse_report.y; + if (mouse_report.y == 0) { mouse_report.y = 1; } } if (mouse_report.v > 0) mouse_report.v = wheel_unit(); if (mouse_report.v < 0) mouse_report.v = wheel_unit() * -1; @@ -234,9 +234,9 @@ void adjust_speed(void) { // adjust for diagonals if (mouse_report.x && mouse_report.y) { mouse_report.x = times_inv_sqrt2(mouse_report.x); - mouse_report.x = mouse_report.x == 0 ? 1 : mouse_report.x; + if (mouse_report.x == 0) { mouse_report.x = 1; } mouse_report.y = times_inv_sqrt2(mouse_report.y); - mouse_report.y = mouse_report.y == 0 ? 1 : mouse_report.y; + if (mouse_report.y == 0) { mouse_report.y = 1; } } if (mouse_report.h && mouse_report.v) { mouse_report.h = times_inv_sqrt2(mouse_report.h);