diff --git a/src/Kaleidoscope-MouseKeys.cpp b/src/Kaleidoscope-MouseKeys.cpp index 859dc669..0bfb7aa9 100644 --- a/src/Kaleidoscope-MouseKeys.cpp +++ b/src/Kaleidoscope-MouseKeys.cpp @@ -89,6 +89,12 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; if (keyIsPressed(keyState)) { + // Reset warp state on initial mouse button key-down only so we can use + // warp keys to drag-and-drop: + if (keyToggledOn(keyState)) { + MouseWrapper.reset_warping(); + } + MouseWrapper.pressButton(button); } else if (keyToggledOff(keyState)) { MouseWrapper.release_button(button); diff --git a/src/MouseWrapper.cpp b/src/MouseWrapper.cpp index 100367bb..cca78610 100644 --- a/src/MouseWrapper.cpp +++ b/src/MouseWrapper.cpp @@ -25,11 +25,11 @@ void MouseWrapper_::begin(void) { void MouseWrapper_::pressButton(uint8_t button) { kaleidoscope::hid::pressMouseButtons(button); - end_warping(); } void MouseWrapper_::release_button(uint8_t button) { kaleidoscope::hid::releaseMouseButtons(button); + end_warping(); } void MouseWrapper_::warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width) { @@ -50,6 +50,12 @@ void MouseWrapper_::end_warping() { is_warping = false; } +void MouseWrapper_::reset_warping() { + if (is_warping == true) { + begin_warping(); + } +} + void MouseWrapper_::warp(uint8_t warp_cmd) { if (is_warping == false) { begin_warping(); diff --git a/src/MouseWrapper.h b/src/MouseWrapper.h index 8c6ee04f..3bb467fc 100644 --- a/src/MouseWrapper.h +++ b/src/MouseWrapper.h @@ -29,6 +29,7 @@ class MouseWrapper_ { static void begin(void); static void move(int8_t x, int8_t y); static void warp(uint8_t warp_cmd); + static void reset_warping(); static void pressButton(uint8_t button); static void release_button(uint8_t button); static uint8_t accelStep;