End mouse warping when any non-warp mouse key toggles on

Fixes #1220

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
master^2^2
Michael Richters 2 years ago
parent 51125f215b
commit a0045f4d9e
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -129,10 +129,15 @@ EventHandlerResult MouseKeys::onKeyEvent(KeyEvent &event) {
// Clear button state; it will be repopulated by `onAddToReport()`, and the // Clear button state; it will be repopulated by `onAddToReport()`, and the
// report will be sent by `afterReportingState()`. // report will be sent by `afterReportingState()`.
buttons_ = 0; buttons_ = 0;
}
} else if (isMouseWarpKey(event.key)) { if (keyToggledOn(event.state)) {
if (keyToggledOn(event.state)) { if (isMouseWarpKey(event.key)) {
// If a mouse warp key toggles on, we immediately send the warp report.
sendMouseWarpReport(event); sendMouseWarpReport(event);
} else {
// If any non-warp mouse key toggles on, we cancel warping.
MouseWrapper.endWarping();
} }
} }

@ -47,6 +47,7 @@ namespace mousekeys {
class MouseWrapper { class MouseWrapper {
public: public:
void warp(uint8_t warp_cmd); void warp(uint8_t warp_cmd);
void endWarping();
uint8_t warp_grid_size = MOUSE_WARP_GRID_2X2; uint8_t warp_grid_size = MOUSE_WARP_GRID_2X2;
@ -58,7 +59,6 @@ class MouseWrapper {
bool is_warping = false; bool is_warping = false;
void beginWarping(); void beginWarping();
void endWarping();
void resetWarping(); void resetWarping();
void warpJump(uint16_t left, uint16_t top, uint16_t height, uint16_t width); void warpJump(uint16_t left, uint16_t top, uint16_t height, uint16_t width);
}; };

Loading…
Cancel
Save