From 6805b349e129636f7109b7e58e39318702baf4d7 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Sat, 27 Apr 2019 09:41:22 -0500 Subject: [PATCH] Make opposing mouse movement keys cancel each other Instead of having `Key_mouseL` & `Key_mouseUp` override `Key_mouseR` & `Key_mouseDn`, respectively, stop mouse movement on a given axis when both keys are held simultaneously. Doing so will not reset acceleration, so when one of them is released, the mouse will resume movement at full speed immediately. Closes #634. Signed-off-by: Michael Richters --- src/kaleidoscope/plugin/MouseKeys.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/kaleidoscope/plugin/MouseKeys.cpp b/src/kaleidoscope/plugin/MouseKeys.cpp index 91c0d3e9..b6b4e13a 100644 --- a/src/kaleidoscope/plugin/MouseKeys.cpp +++ b/src/kaleidoscope/plugin/MouseKeys.cpp @@ -90,14 +90,14 @@ EventHandlerResult MouseKeys_::beforeReportingState() { } if (mouseMoveIntent & KEY_MOUSE_UP) - moveY = -speed; - else if (mouseMoveIntent & KEY_MOUSE_DOWN) - moveY = speed; + moveY -= speed; + if (mouseMoveIntent & KEY_MOUSE_DOWN) + moveY += speed; if (mouseMoveIntent & KEY_MOUSE_LEFT) - moveX = -speed; - else if (mouseMoveIntent & KEY_MOUSE_RIGHT) - moveX = speed; + moveX -= speed; + if (mouseMoveIntent & KEY_MOUSE_RIGHT) + moveX += speed; MouseWrapper.move(moveX, moveY);