diff --git a/key_events.cpp b/key_events.cpp index 5eef16e0..d454b217 100644 --- a/key_events.cpp +++ b/key_events.cpp @@ -7,7 +7,11 @@ void handle_synthetic_key_event(byte switchState, Key mappedKey) { if (mappedKey.flags & IS_MOUSE_KEY ) { if (mappedKey.rawKey & MOUSE_WARP) { if (key_toggled_on(switchState)) { - warp_mouse(mappedKey.rawKey); + // we don't pass in the left and up values because those are the + // default, "no-op" conditionals + warp_mouse( (mappedKey.rawKey & MOUSE_WARP_END ? WARP_END : 0x00) | + (mappedKey.rawKey & MOUSE_DN ? WARP_DOWN : 0x00) | + (mappedKey.rawKey & MOUSE_R ? WARP_RIGHT : 0x00) ); } } else { handle_mouse_key_event(switchState, mappedKey); diff --git a/mouse_movement.cpp b/mouse_movement.cpp index 2088f7ee..d64a14f4 100644 --- a/mouse_movement.cpp +++ b/mouse_movement.cpp @@ -42,13 +42,13 @@ void end_warping() { is_warping= false; } -void warp_mouse(uint8_t quadrant) { +void warp_mouse(uint8_t warp_cmd) { if (is_warping == false) { begin_warping(); } - if ( quadrant & MOUSE_END_WARP) { + if ( warp_cmd & WARP_END) { end_warping(); return; } @@ -57,16 +57,16 @@ void warp_mouse(uint8_t quadrant) { next_width = next_width / 2; next_height = next_height/2; - if (quadrant & MOUSE_UP) { + if (warp_cmd & WARP_UP) { // Serial.print(" - up "); - } else if (quadrant & MOUSE_DN) { + } else if (warp_cmd & WARP_DOWN) { // Serial.print(" - down "); section_top = section_top + next_height; } - if (quadrant & MOUSE_L) { + if (warp_cmd & WARP_LEFT) { // Serial.print(" - left "); - } else if (quadrant & MOUSE_R) { + } else if (warp_cmd & WARP_RIGHT) { // Serial.print(" - right "); section_left = section_left + next_width; } diff --git a/mouse_movement.h b/mouse_movement.h index f9ca2233..aa2d79e5 100644 --- a/mouse_movement.h +++ b/mouse_movement.h @@ -2,7 +2,6 @@ #pragma once #include "Arduino.h" -#include "key_defs.h" #include "matrix_state.h" #include "HID-Project.h" @@ -12,9 +11,17 @@ double mouse_accel (double cycles); void move_mouse( int8_t x, int8_t y); void begin_warping(); void end_warping(); -void warp_mouse(uint8_t quadrant); +void warp_mouse(uint8_t warp_cmd); +// Warping commands + +#define WARP_END 1 +#define WARP_UP 2 +#define WARP_DOWN 4 +#define WARP_LEFT 8 +#define WARP_RIGHT 16 + // apparently, the mac discards 15% of the value space for mouse movement.