From d882c141588df97ccf791aaa425f19cbdf1576c8 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 12 Nov 2016 21:11:08 -0800 Subject: [PATCH] Revert "The various types of synthetic keys never overlap." This reverts commit a9088e91791db24aacd599d43d3796126c619b9a. --- src/key_defs.h | 6 +++--- src/key_events.cpp | 17 +++++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/key_defs.h b/src/key_defs.h index 7b731bc8..493d8cc5 100644 --- a/src/key_defs.h +++ b/src/key_defs.h @@ -26,9 +26,9 @@ typedef union { // we assert that synthetic keys can never have keys held, so we reuse the _HELD bits #define IS_MACRO B00000001 #define IS_SYSCTL B00000010 -#define IS_CONSUMER B00000011 -#define IS_INTERNAL B00000100 -#define IS_MOUSE_KEY B00000101 +#define IS_CONSUMER B00000100 +#define IS_INTERNAL B00001000 +#define IS_MOUSE_KEY B00010000 // IS_INTERNAL key table: diff --git a/src/key_events.cpp b/src/key_events.cpp index 5cd65016..cbc50968 100644 --- a/src/key_events.cpp +++ b/src/key_events.cpp @@ -3,11 +3,9 @@ static const Key keymaps[KEYMAPS][ROWS][COLS] PROGMEM = { KEYMAP_LIST }; void handle_synthetic_key_event(Key mappedKey, uint8_t currentState, uint8_t previousState) { - if ( (mappedKey.flags == SYNTHETIC_KEY| IS_MOUSE_KEY ) - - && !( mappedKey.rawKey & KEY_MOUSE_WARP) ) { + if (mappedKey.flags & IS_MOUSE_KEY && !( mappedKey.rawKey & KEY_MOUSE_WARP) ) { handle_mouse_key_event(mappedKey, currentState, previousState); - } else if (! (mappedKey.flags == SYNTHETIC_KEY| IS_INTERNAL) + } else if (! (mappedKey.flags & IS_INTERNAL) && (mappedKey.rawKey == KEY_MOUSE_BTN_L || mappedKey.rawKey == KEY_MOUSE_BTN_M || mappedKey.rawKey == KEY_MOUSE_BTN_R)) { @@ -20,22 +18,21 @@ void handle_synthetic_key_event(Key mappedKey, uint8_t currentState, uint8_t pre else if (key_toggled_on(currentState,previousState)) { - if ( (mappedKey.flags == SYNTHETIC_KEY| IS_MOUSE_KEY) - && mappedKey.rawKey & KEY_MOUSE_WARP ) { + if (mappedKey.rawKey & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) { // we don't pass in the left and up values because those are the // default, "no-op" conditionals MouseWrapper.warp( ((mappedKey.rawKey & KEY_MOUSE_WARP_END) ? WARP_END : 0x00) | ((mappedKey.rawKey & KEY_MOUSE_DOWN) ? WARP_DOWN : 0x00) | ((mappedKey.rawKey & KEY_MOUSE_RIGHT) ? WARP_RIGHT : 0x00) ); - } else if (mappedKey.flags == SYNTHETIC_KEY| IS_CONSUMER) { + } else if (mappedKey.flags & IS_CONSUMER) { ConsumerControl.press(mappedKey.rawKey); - } else if (mappedKey.flags == SYNTHETIC_KEY| IS_INTERNAL) { + } else if (mappedKey.flags & IS_INTERNAL) { if (mappedKey.rawKey == LED_TOGGLE) { LEDControl.next_mode(); } - } else if (mappedKey.flags == SYNTHETIC_KEY| IS_SYSCTL) { + } else if (mappedKey.flags & IS_SYSCTL) { SystemControl.press(mappedKey.rawKey); - } else if (mappedKey.flags == SYNTHETIC_KEY| IS_MACRO) { + } else if (mappedKey.flags & IS_MACRO) { if (mappedKey.rawKey == 1) { Serial.print("Keyboard.IO keyboard driver v0.00"); }