Make mousekeys 'synthetic' as we work toward compressing datastructures

pull/18/head
Jesse Vincent 9 years ago
parent 6c6dfa30c1
commit 264bcd24c0

@ -216,6 +216,15 @@ byte load_primary_keymap() {
// Sending events to the usb host // Sending events to the usb host
void handle_synthetic_key_press(byte switchState, Key mappedKey) { 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 (mappedKey.flags & IS_CONSUMER) {
if (key_toggled_on (switchState)) { if (key_toggled_on (switchState)) {
ConsumerControl.press(mappedKey.rawKey); ConsumerControl.press(mappedKey.rawKey);
@ -265,16 +274,8 @@ void send_key_event(byte row, byte col) {
set_keymap(keymaps[primary_keymap][row][col], switchState); 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); handle_synthetic_key_press(switchState, mappedKey);
} else { } else {
if (key_is_pressed(switchState)) { if (key_is_pressed(switchState)) {

@ -17,7 +17,6 @@ typedef struct {
#define GUI_HELD B00001000 #define GUI_HELD B00001000
#define SWITCH_TO_KEYMAP B00010000 #define SWITCH_TO_KEYMAP B00010000
#define MOMENTARY B00100000 #define MOMENTARY B00100000
#define MOUSE_KEY B01000000
#define SYNTHETIC_KEY B10000000 #define SYNTHETIC_KEY B10000000
// we assert that synthetic keys can never have keys held, so we reuse the _HELD bits // 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_SYSCTL B00000010
#define IS_CONSUMER B00000100 #define IS_CONSUMER B00000100
#define IS_INTERNAL B00001000 #define IS_INTERNAL B00001000
#define IS_MOUSE_KEY B00010000
// IS_INTERNAL key table: // IS_INTERNAL key table:
@ -61,22 +61,22 @@ typedef struct {
#define Key_macroKey1 (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MACRO, 1} #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_mouseWarpNW (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_WARP| MOUSE_UP | MOUSE_L }
#define Key_mouseWarpNE (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_WARP| MOUSE_UP | MOUSE_R } #define Key_mouseWarpNE (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_WARP| MOUSE_UP | MOUSE_R }
#define Key_mouseWarpSW (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_WARP| MOUSE_DN | MOUSE_L } #define Key_mouseWarpSW (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_WARP| MOUSE_DN | MOUSE_L }
#define Key_mouseWarpSE (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_WARP| MOUSE_DN | MOUSE_R } #define Key_mouseWarpSE (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_WARP| MOUSE_DN | MOUSE_R }
#define Key_mouseWarpEnd (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_WARP| MOUSE_END_WARP} #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_mouseUpL (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_UP | MOUSE_L }
#define Key_mouseUp (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_UP } #define Key_mouseUp (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_UP }
#define Key_mouseUpR (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_UP | MOUSE_R } #define Key_mouseUpR (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_UP | MOUSE_R }
#define Key_mouseL (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_L } #define Key_mouseL (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_L }
#define Key_mouseR (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_R } #define Key_mouseR (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_R }
#define Key_mouseDnL (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_DN | MOUSE_L } #define Key_mouseDnL (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_DN | MOUSE_L }
#define Key_mouseDn (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_DN } #define Key_mouseDn (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_DN }
#define Key_mouseDnR (Key){ KEY_FLAGS|MOUSE_KEY, MOUSE_DN | MOUSE_R } #define Key_mouseDnR (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, MOUSE_DN | MOUSE_R }
#define Key_mouseScrollUp #define Key_mouseScrollUp
#define Key_mouseScrollDn #define Key_mouseScrollDn
#define Key_mouseScrollL #define Key_mouseScrollL

Loading…
Cancel
Save