diff --git a/src/key_defs.h b/src/key_defs.h index 493d8cc5..dc5a394d 100644 --- a/src/key_defs.h +++ b/src/key_defs.h @@ -21,7 +21,7 @@ typedef union { #define GUI_HELD B00010000 #define SWITCH_TO_KEYMAP B00100000 #define MOMENTARY B01000000 -#define SYNTHETIC_KEY B10000000 +#define SYNTHETIC B10000000 // we assert that synthetic keys can never have keys held, so we reuse the _HELD bits #define IS_MACRO B00000001 @@ -71,63 +71,63 @@ typedef union { #define Key_NoKey (Key){ KEY_FLAGS,0 } #define Key_skip (Key){ KEY_FLAGS,0 } -#define Key_macroKey1 (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MACRO, 1} +#define Key_macroKey1 (Key){ KEY_FLAGS|SYNTHETIC|IS_MACRO, 1} -#define Key_mouseWarpNW (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_LEFT } -#define Key_mouseWarpNE (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_RIGHT } -#define Key_mouseWarpSW (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_LEFT } -#define Key_mouseWarpSE (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT } -#define Key_mouseWarpEnd (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_WARP_END} +#define Key_mouseWarpNW (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_LEFT } +#define Key_mouseWarpNE (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_UP | KEY_MOUSE_RIGHT } +#define Key_mouseWarpSW (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_LEFT } +#define Key_mouseWarpSE (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT } +#define Key_mouseWarpEnd (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_WARP| KEY_MOUSE_WARP_END} -#define Key_mouseUpL (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_UP | KEY_MOUSE_LEFT } -#define Key_mouseUp (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_UP } -#define Key_mouseUpR (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_UP | KEY_MOUSE_RIGHT } -#define Key_mouseL (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_LEFT } -#define Key_mouseR (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_RIGHT } -#define Key_mouseDnL (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_DOWN | KEY_MOUSE_LEFT } -#define Key_mouseDn (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_DOWN } -#define Key_mouseDnR (Key){ KEY_FLAGS|SYNTHETIC_KEY|IS_MOUSE_KEY, KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT } +#define Key_mouseUpL (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_UP | KEY_MOUSE_LEFT } +#define Key_mouseUp (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_UP } +#define Key_mouseUpR (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_UP | KEY_MOUSE_RIGHT } +#define Key_mouseL (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_LEFT } +#define Key_mouseR (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_RIGHT } +#define Key_mouseDnL (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_DOWN | KEY_MOUSE_LEFT } +#define Key_mouseDn (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_DOWN } +#define Key_mouseDnR (Key){ KEY_FLAGS|SYNTHETIC|IS_MOUSE_KEY, KEY_MOUSE_DOWN | KEY_MOUSE_RIGHT } #define Key_mouseScrollUp #define Key_mouseScrollDn #define Key_mouseScrollL #define Key_mouseScrollR -#define Key_mouseBtnL (Key){ KEY_FLAGS | SYNTHETIC_KEY, KEY_MOUSE_BTN_L } -#define Key_mouseBtnM (Key){ KEY_FLAGS | SYNTHETIC_KEY , KEY_MOUSE_BTN_M } -#define Key_mouseBtnR (Key){ KEY_FLAGS | SYNTHETIC_KEY, KEY_MOUSE_BTN_R } +#define Key_mouseBtnL (Key){ KEY_FLAGS | SYNTHETIC, KEY_MOUSE_BTN_L } +#define Key_mouseBtnM (Key){ KEY_FLAGS | SYNTHETIC , KEY_MOUSE_BTN_M } +#define Key_mouseBtnR (Key){ KEY_FLAGS | SYNTHETIC, KEY_MOUSE_BTN_R } -#define Key_powerDown (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_POWER_DOWN } -#define Key_sleep (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_SLEEP } -#define Key_wakeup (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_WAKEUP } -#define Key_coldRestart (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_COLD_RESTART } -#define Key_warmRestart (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_WARM_RESTART } -#define Key_dock (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_DOCK } -#define Key_undock (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_UNDOCK } -#define Key_speakerMute (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_SPEAKER_MUTE } -#define Key_hibernate (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_HIBERNATE } -#define Key_displayInvert (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_DISPLAY_INVERT } -#define Key_displayInternal (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_DISPLAY_INTERNAL } -#define Key_displayExternal (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_DISPLAY_EXTERNAL } -#define Key_displayBoth (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_DISPLAY_BOTH } -#define Key_displayDual (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_DISPLAY_DUAL } -#define Key_displayToggle (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_DISPLAY_TOGGLE_INT_EXT -#define Key_displaySwap (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_SYSCTL,HID_SYSTEM_DISPLAY_SWAP } +#define Key_powerDown (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_POWER_DOWN } +#define Key_sleep (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_SLEEP } +#define Key_wakeup (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_WAKEUP } +#define Key_coldRestart (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_COLD_RESTART } +#define Key_warmRestart (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_WARM_RESTART } +#define Key_dock (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_DOCK } +#define Key_undock (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_UNDOCK } +#define Key_speakerMute (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_SPEAKER_MUTE } +#define Key_hibernate (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_HIBERNATE } +#define Key_displayInvert (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_DISPLAY_INVERT } +#define Key_displayInternal (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_DISPLAY_INTERNAL } +#define Key_displayExternal (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_DISPLAY_EXTERNAL } +#define Key_displayBoth (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_DISPLAY_BOTH } +#define Key_displayDual (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_DISPLAY_DUAL } +#define Key_displayToggle (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_DISPLAY_TOGGLE_INT_EXT +#define Key_displaySwap (Key) {KEY_FLAGS | SYNTHETIC|IS_SYSCTL,HID_SYSTEM_DISPLAY_SWAP } -#define Key_volumeMute (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_CONSUMER, HID_CONSUMER_MUTE} -#define Key_volumeUp (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_CONSUMER, HID_CONSUMER_VOLUME_INCREMENT } -#define Key_volumeDown (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_CONSUMER, HID_CONSUMER_VOLUME_DECREMENT } -#define Key_playPause (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_CONSUMER, HID_CONSUMER_PLAY_SLASH_PAUSE} -#define Key_stop (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_CONSUMER, HID_CONSUMER_STOP} -#define Key_prevTrack (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_CONSUMER, HID_CONSUMER_SCAN_PREVIOUS_TRACK} -#define Key_nextTrack (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_CONSUMER, HID_CONSUMER_SCAN_NEXT_TRACK} -#define Key_Eject (Key) {KEY_FLAGS | SYNTHETIC_KEY|IS_CONSUMER, HID_CONSUMER_EJECT} +#define Key_volumeMute (Key) {KEY_FLAGS | SYNTHETIC|IS_CONSUMER, HID_CONSUMER_MUTE} +#define Key_volumeUp (Key) {KEY_FLAGS | SYNTHETIC|IS_CONSUMER, HID_CONSUMER_VOLUME_INCREMENT } +#define Key_volumeDown (Key) {KEY_FLAGS | SYNTHETIC|IS_CONSUMER, HID_CONSUMER_VOLUME_DECREMENT } +#define Key_playPause (Key) {KEY_FLAGS | SYNTHETIC|IS_CONSUMER, HID_CONSUMER_PLAY_SLASH_PAUSE} +#define Key_stop (Key) {KEY_FLAGS | SYNTHETIC|IS_CONSUMER, HID_CONSUMER_STOP} +#define Key_prevTrack (Key) {KEY_FLAGS | SYNTHETIC|IS_CONSUMER, HID_CONSUMER_SCAN_PREVIOUS_TRACK} +#define Key_nextTrack (Key) {KEY_FLAGS | SYNTHETIC|IS_CONSUMER, HID_CONSUMER_SCAN_NEXT_TRACK} +#define Key_Eject (Key) {KEY_FLAGS | SYNTHETIC|IS_CONSUMER, HID_CONSUMER_EJECT} #define Key_LCtrl (Key){ KEY_FLAGS, HID_KEYBOARD_LEFT_CONTROL } @@ -297,6 +297,6 @@ typedef union { -#define Key_LEDEffectNext (Key) { KEY_FLAGS | SYNTHETIC_KEY | IS_INTERNAL, LED_TOGGLE } +#define Key_LEDEffectNext (Key) { KEY_FLAGS | SYNTHETIC | IS_INTERNAL, LED_TOGGLE } diff --git a/src/key_events.cpp b/src/key_events.cpp index cbc50968..29a86d6c 100644 --- a/src/key_events.cpp +++ b/src/key_events.cpp @@ -71,7 +71,7 @@ bool handle_key_event_default(byte row, byte col, uint8_t currentState, uint8_t if (baseKey.flags & SWITCH_TO_KEYMAP) { handle_keymap_key_event(baseKey, currentState, previousState); - } else if (mappedKey.flags & SYNTHETIC_KEY) { + } else if (mappedKey.flags & SYNTHETIC) { handle_synthetic_key_event( mappedKey, currentState, previousState); } else if (key_is_pressed(currentState, previousState)) { press_key(mappedKey);