diff --git a/src/key_defs.h b/src/key_defs.h index dd9318f0..ef965677 100644 --- a/src/key_defs.h +++ b/src/key_defs.h @@ -19,16 +19,16 @@ typedef union { #define RALT_HELD B00000100 #define SHIFT_HELD B00001000 #define GUI_HELD B00010000 -#define SWITCH_TO_KEYMAP B00100000 -#define MOMENTARY B01000000 #define SYNTHETIC B10000000 // 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 B00000100 -#define IS_INTERNAL B00001000 -#define IS_MOUSE_KEY B00010000 +#define IS_MACRO B00000001 +#define IS_SYSCTL B00000010 +#define IS_CONSUMER B00000100 +#define IS_INTERNAL B00001000 +#define IS_MOUSE_KEY B00010000 +#define SWITCH_TO_KEYMAP B00100000 +#define SWITCH_TO_KEYMAP_MOMENTARY B01000000 // IS_INTERNAL key table: @@ -278,21 +278,21 @@ typedef union { #define Key_Paste (Key){ KEY_FLAGS, HID_KEYBOARD_PASTE } -#define Key_Keymap0 (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP , KEYMAP_0 } -#define Key_Keymap1 (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP , KEYMAP_1 } -#define Key_Keymap2 (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP , KEYMAP_2 } -#define Key_Keymap3 (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP , KEYMAP_3 } -#define Key_Keymap4 (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP , KEYMAP_4 } -#define Key_Keymap5 (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP , KEYMAP_5 } -#define Key_Keymap0_Momentary (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP | MOMENTARY, KEYMAP_0 } -#define Key_Keymap1_Momentary (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP | MOMENTARY, KEYMAP_1 } -#define Key_Keymap2_Momentary (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP | MOMENTARY, KEYMAP_2 } -#define Key_Keymap3_Momentary (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP | MOMENTARY, KEYMAP_3 } -#define Key_Keymap4_Momentary (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP | MOMENTARY, KEYMAP_4 } -#define Key_Keymap5_Momentary (Key){ KEY_FLAGS | SWITCH_TO_KEYMAP | MOMENTARY, KEYMAP_5 } - -#define Key_KeymapNext_Momentary (Key) {KEY_FLAGS | SWITCH_TO_KEYMAP | MOMENTARY, KEYMAP_NEXT } -#define Key_KeymapPrevious_Momentary (Key) {KEY_FLAGS | SWITCH_TO_KEYMAP | MOMENTARY, KEYMAP_PREVIOUS } +#define Key_Keymap0 (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP , KEYMAP_0 } +#define Key_Keymap1 (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP , KEYMAP_1 } +#define Key_Keymap2 (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP , KEYMAP_2 } +#define Key_Keymap3 (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP , KEYMAP_3 } +#define Key_Keymap4 (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP , KEYMAP_4 } +#define Key_Keymap5 (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP , KEYMAP_5 } +#define Key_Keymap0_Momentary (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP_MOMENTARY, KEYMAP_0 } +#define Key_Keymap1_Momentary (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP_MOMENTARY, KEYMAP_1 } +#define Key_Keymap2_Momentary (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP_MOMENTARY, KEYMAP_2 } +#define Key_Keymap3_Momentary (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP_MOMENTARY, KEYMAP_3 } +#define Key_Keymap4_Momentary (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP_MOMENTARY, KEYMAP_4 } +#define Key_Keymap5_Momentary (Key){ KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP_MOMENTARY, KEYMAP_5 } + +#define Key_KeymapNext_Momentary (Key) {KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP_MOMENTARY, KEYMAP_NEXT } +#define Key_KeymapPrevious_Momentary (Key) {KEY_FLAGS | SYNTHETIC | SWITCH_TO_KEYMAP_MOMENTARY, KEYMAP_PREVIOUS } diff --git a/src/key_events.cpp b/src/key_events.cpp index 29a86d6c..5787d497 100644 --- a/src/key_events.cpp +++ b/src/key_events.cpp @@ -69,7 +69,8 @@ bool handle_key_event_default(byte row, byte col, uint8_t currentState, uint8_t Key mappedKey = lookup_key(temporary_keymap, row, col); Key baseKey = lookup_key(primary_keymap, row, col); - if (baseKey.flags & SWITCH_TO_KEYMAP) { + if ((baseKey.flags == (SYNTHETIC | SWITCH_TO_KEYMAP)) + || (baseKey.flags == (SYNTHETIC | SWITCH_TO_KEYMAP_MOMENTARY))) { handle_keymap_key_event(baseKey, currentState, previousState); } else if (mappedKey.flags & SYNTHETIC) { handle_synthetic_key_event( mappedKey, currentState, previousState); @@ -100,7 +101,7 @@ void press_key(Key mappedKey) { void handle_keymap_key_event(Key keymapEntry, uint8_t currentState, uint8_t previousState) { - if (keymapEntry.flags & MOMENTARY ) { + if (keymapEntry.flags == (SYNTHETIC| SWITCH_TO_KEYMAP_MOMENTARY )) { if (key_toggled_on(currentState, previousState)) { if ( keymapEntry.rawKey == KEYMAP_NEXT) { temporary_keymap++;