From 264bcd24c02b2415259d1fe5060a5b7851c3c802 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 25 Jan 2016 14:28:14 -0800 Subject: [PATCH] Make mousekeys 'synthetic' as we work toward compressing datastructures --- KeyboardioFirmware.ino | 19 ++++++++++--------- key_defs.h | 28 ++++++++++++++-------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/KeyboardioFirmware.ino b/KeyboardioFirmware.ino index d77257d5..783f8990 100644 --- a/KeyboardioFirmware.ino +++ b/KeyboardioFirmware.ino @@ -216,6 +216,15 @@ byte load_primary_keymap() { // Sending events to the usb host void handle_synthetic_key_press(byte switchState, Key mappedKey) { + if (mappedKey.flags & IS_MOUSE_KEY ) { + if (mappedKey.rawKey & MOUSE_WARP) { + if (key_toggled_on(switchState)) { + warp_mouse(mappedKey); + } + } else { + handle_mouse_key_press(switchState, mappedKey, x, y); + } + } if (mappedKey.flags & IS_CONSUMER) { if (key_toggled_on (switchState)) { ConsumerControl.press(mappedKey.rawKey); @@ -265,16 +274,8 @@ void send_key_event(byte row, byte col) { set_keymap(keymaps[primary_keymap][row][col], switchState); - if (mappedKey.flags & MOUSE_KEY ) { - if (mappedKey.rawKey & MOUSE_WARP) { - if (key_toggled_on(switchState)) { - warp_mouse(mappedKey); - } - } else { - handle_mouse_key_press(switchState, mappedKey, x, y); - } - } else if (mappedKey.flags & SYNTHETIC_KEY) { + if (mappedKey.flags & SYNTHETIC_KEY) { handle_synthetic_key_press(switchState, mappedKey); } else { if (key_is_pressed(switchState)) { diff --git a/key_defs.h b/key_defs.h index 4f75ab87..7f9f8d20 100644 --- a/key_defs.h +++ b/key_defs.h @@ -17,7 +17,6 @@ typedef struct { #define GUI_HELD B00001000 #define SWITCH_TO_KEYMAP B00010000 #define MOMENTARY B00100000 -#define MOUSE_KEY B01000000 #define SYNTHETIC_KEY B10000000 // we assert that synthetic keys can never have keys held, so we reuse the _HELD bits @@ -25,6 +24,7 @@ typedef struct { #define IS_SYSCTL B00000010 #define IS_CONSUMER B00000100 #define IS_INTERNAL B00001000 +#define IS_MOUSE_KEY B00010000 // IS_INTERNAL key table: @@ -61,22 +61,22 @@ typedef struct { #define Key_macroKey1 (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MACRO, 1} -#define Key_mouseWarpNW (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_WARP| MOUSE_UP | MOUSE_L } -#define Key_mouseWarpNE (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_WARP| MOUSE_UP | MOUSE_R } -#define Key_mouseWarpSW (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_WARP| MOUSE_DN | MOUSE_L } -#define Key_mouseWarpSE (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_WARP| MOUSE_DN | MOUSE_R } -#define Key_mouseWarpEnd (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_WARP| MOUSE_END_WARP} +#define Key_mouseWarpNW (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_WARP| MOUSE_UP | MOUSE_L } +#define Key_mouseWarpNE (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_WARP| MOUSE_UP | MOUSE_R } +#define Key_mouseWarpSW (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_WARP| MOUSE_DN | MOUSE_L } +#define Key_mouseWarpSE (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_WARP| MOUSE_DN | MOUSE_R } +#define Key_mouseWarpEnd (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_WARP| MOUSE_END_WARP} -#define Key_mouseUpL (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_UP | MOUSE_L } -#define Key_mouseUp (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_UP } -#define Key_mouseUpR (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_UP | MOUSE_R } -#define Key_mouseL (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_L } -#define Key_mouseR (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_R } -#define Key_mouseDnL (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_DN | MOUSE_L } -#define Key_mouseDn (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_DN } -#define Key_mouseDnR (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_DN | MOUSE_R } +#define Key_mouseUpL (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_UP | MOUSE_L } +#define Key_mouseUp (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_UP } +#define Key_mouseUpR (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_UP | MOUSE_R } +#define Key_mouseL (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_L } +#define Key_mouseR (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_R } +#define Key_mouseDnL (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_DN | MOUSE_L } +#define Key_mouseDn (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_DN } +#define Key_mouseDnR (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_DN | MOUSE_R } #define Key_mouseScrollUp #define Key_mouseScrollDn #define Key_mouseScrollL