From 51fef2b33e1f6fb3e41cabe9018631484b4a6900 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Wed, 14 Apr 2021 20:02:36 -0500 Subject: [PATCH 1/2] Remove the (mostly) useless `MouseWrapper.diagonalize()` function Because the input value was always very small, it never really served its purpose. Signed-off-by: Michael Richters --- .../plugin/MouseKeys/MouseWrapper.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/plugins/Kaleidoscope-MouseKeys/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp b/plugins/Kaleidoscope-MouseKeys/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp index 16f30b98..0f7aeae4 100644 --- a/plugins/Kaleidoscope-MouseKeys/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp +++ b/plugins/Kaleidoscope-MouseKeys/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp @@ -110,15 +110,6 @@ uint8_t MouseWrapper_::acceleration(uint8_t cycles) { } } -// Get the diagonalized version of a value, i.e. value * sqrt(2) / 2. If the -// value ends up being zero, return the original value instead. -static int16_t diagonalize(int16_t value) { - // 99 / 140 closely approximates sqrt(2) / 2. Since integer division - // truncates towards zero we do not need to worry about truncation errors. - int16_t diagonalValue = value * 99 / 140; - return (diagonalValue == 0 ? value : diagonalValue); -} - void MouseWrapper_::move(int8_t x, int8_t y) { int16_t moveX = 0; int16_t moveY = 0; @@ -126,15 +117,6 @@ void MouseWrapper_::move(int8_t x, int8_t y) { static int8_t remainderY = 0; int16_t effectiveSpeedLimit = speedLimit; - if (x != 0 && y != 0) { - // For diagonal movements, we apply a diagonalized speed limit. The - // effective speed limit is set based on whether we are moving diagonally. - effectiveSpeedLimit = diagonalize(effectiveSpeedLimit); - - x = diagonalize(x); - y = diagonalize(y); - } - if (x != 0) { moveX = remainderX + (x * acceleration(accelStep)); if (moveX > effectiveSpeedLimit) moveX = effectiveSpeedLimit; From b16b47beaa73eb95cd61eb0f1f47f64671e5d04b Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Wed, 14 Apr 2021 20:04:28 -0500 Subject: [PATCH 2/2] Remove spurious third argument in call to `Mouse::move()` Signed-off-by: Michael Richters --- .../src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Kaleidoscope-MouseKeys/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp b/plugins/Kaleidoscope-MouseKeys/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp index 0f7aeae4..25eb8687 100644 --- a/plugins/Kaleidoscope-MouseKeys/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp +++ b/plugins/Kaleidoscope-MouseKeys/src/kaleidoscope/plugin/MouseKeys/MouseWrapper.cpp @@ -131,7 +131,7 @@ void MouseWrapper_::move(int8_t x, int8_t y) { end_warping(); // move by whole pixels, not subpixels - Kaleidoscope.hid().mouse().move(moveX / subpixelsPerPixel, moveY / subpixelsPerPixel, 0); + Kaleidoscope.hid().mouse().move(moveX / subpixelsPerPixel, moveY / subpixelsPerPixel); // save leftover subpixel movements for later remainderX = moveX - moveX / subpixelsPerPixel * subpixelsPerPixel; remainderY = moveY - moveY / subpixelsPerPixel * subpixelsPerPixel;