Fix warping while dragging the mouse

Before this change, we couldn't use the full functionality of the plugin's
warp feature to drag an item (by holding down a mouse button key). The
plugin would reset the warp state during each scan cycle, so we could
only warp the pointer to a cell in the top-level grid. This fix enables
warping repeatedly into sub-cells while holding a mouse button.
pull/365/head
Cy Rossignol 7 years ago
parent 88f8308e49
commit b370681111

@ -83,6 +83,12 @@ Key MouseKeys_::eventHandlerHook(Key mappedKey, byte row, byte col, uint8_t keyS
uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON; uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON;
if (keyIsPressed(keyState)) { 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); MouseWrapper.pressButton(button);
} else if (keyToggledOff(keyState)) { } else if (keyToggledOff(keyState)) {
MouseWrapper.release_button(button); MouseWrapper.release_button(button);

@ -24,11 +24,11 @@ void MouseWrapper_::begin(void) {
void MouseWrapper_::pressButton(uint8_t button) { void MouseWrapper_::pressButton(uint8_t button) {
kaleidoscope::hid::pressMouseButtons(button); kaleidoscope::hid::pressMouseButtons(button);
end_warping();
} }
void MouseWrapper_::release_button(uint8_t button) { void MouseWrapper_::release_button(uint8_t button) {
kaleidoscope::hid::releaseMouseButtons(button); kaleidoscope::hid::releaseMouseButtons(button);
end_warping();
} }
void MouseWrapper_::warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width) { void MouseWrapper_::warp_jump(uint16_t left, uint16_t top, uint16_t height, uint16_t width) {
@ -49,6 +49,12 @@ void MouseWrapper_::end_warping() {
is_warping = false; is_warping = false;
} }
void MouseWrapper_::reset_warping() {
if (is_warping == true) {
begin_warping();
}
}
void MouseWrapper_::warp(uint8_t warp_cmd) { void MouseWrapper_::warp(uint8_t warp_cmd) {
if (is_warping == false) { if (is_warping == false) {
begin_warping(); begin_warping();

@ -28,6 +28,7 @@ class MouseWrapper_ {
static void begin(void); static void begin(void);
static void move(int8_t x, int8_t y); static void move(int8_t x, int8_t y);
static void warp(uint8_t warp_cmd); static void warp(uint8_t warp_cmd);
static void reset_warping();
static void pressButton(uint8_t button); static void pressButton(uint8_t button);
static void release_button(uint8_t button); static void release_button(uint8_t button);
static uint8_t accelStep; static uint8_t accelStep;

Loading…
Cancel
Save