aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2019-11-28 21:59:59 +0000
committerGitHub <noreply@github.com>2019-11-28 21:59:59 +0000
commit2048df883200589c20dfc581e39e03703edf0b23 (patch)
treeeaef3f6d5d56fb0050b33a0fedc72063886e2aa2
parent99f3321e2634547b57ec07f0d1d8b107670be824 (diff)
downloadqmk_firmware-2048df883200589c20dfc581e39e03703edf0b23.tar.gz
qmk_firmware-2048df883200589c20dfc581e39e03703edf0b23.zip
Compile out some keycode processing when features are disabled (#7506)
-rw-r--r--quantum/keymap_common.c12
-rw-r--r--quantum/quantum.c16
2 files changed, 17 insertions, 11 deletions
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 4fa45ac37..587727393 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -52,9 +52,6 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
52 uint8_t action_layer, when, mod; 52 uint8_t action_layer, when, mod;
53 53
54 switch (keycode) { 54 switch (keycode) {
55 case KC_FN0 ... KC_FN31:
56 action.code = keymap_function_id_to_action(FN_INDEX(keycode));
57 break;
58 case KC_A ... KC_EXSEL: 55 case KC_A ... KC_EXSEL:
59 case KC_LCTRL ... KC_RGUI: 56 case KC_LCTRL ... KC_RGUI:
60 action.code = ACTION_KEY(keycode); 57 action.code = ACTION_KEY(keycode);
@@ -65,9 +62,11 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
65 case KC_AUDIO_MUTE ... KC_BRIGHTNESS_DOWN: 62 case KC_AUDIO_MUTE ... KC_BRIGHTNESS_DOWN:
66 action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); 63 action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
67 break; 64 break;
65#ifdef MOUSEKEY_ENABLE
68 case KC_MS_UP ... KC_MS_ACCEL2: 66 case KC_MS_UP ... KC_MS_ACCEL2:
69 action.code = ACTION_MOUSEKEY(keycode); 67 action.code = ACTION_MOUSEKEY(keycode);
70 break; 68 break;
69#endif
71 case KC_TRNS: 70 case KC_TRNS:
72 action.code = ACTION_TRANSPARENT; 71 action.code = ACTION_TRANSPARENT;
73 break; 72 break;
@@ -76,17 +75,24 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
76 // Split it up 75 // Split it up
77 action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key 76 action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
78 break; 77 break;
78#ifndef NO_ACTION_FUNCTION
79 case KC_FN0 ... KC_FN31:
80 action.code = keymap_function_id_to_action(FN_INDEX(keycode));
81 break;
79 case QK_FUNCTION ... QK_FUNCTION_MAX:; 82 case QK_FUNCTION ... QK_FUNCTION_MAX:;
80 // Is a shortcut for function action_layer, pull last 12bits 83 // Is a shortcut for function action_layer, pull last 12bits
81 // This means we have 4,096 FN macros at our disposal 84 // This means we have 4,096 FN macros at our disposal
82 action.code = keymap_function_id_to_action((int)keycode & 0xFFF); 85 action.code = keymap_function_id_to_action((int)keycode & 0xFFF);
83 break; 86 break;
87#endif
88#ifndef NO_ACTION_MACRO
84 case QK_MACRO ... QK_MACRO_MAX: 89 case QK_MACRO ... QK_MACRO_MAX:
85 if (keycode & 0x800) // tap macros have upper bit set 90 if (keycode & 0x800) // tap macros have upper bit set
86 action.code = ACTION_MACRO_TAP(keycode & 0xFF); 91 action.code = ACTION_MACRO_TAP(keycode & 0xFF);
87 else 92 else
88 action.code = ACTION_MACRO(keycode & 0xFF); 93 action.code = ACTION_MACRO(keycode & 0xFF);
89 break; 94 break;
95#endif
90 case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: 96 case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
91 action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); 97 action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
92 break; 98 break;
diff --git a/quantum/quantum.c b/quantum/quantum.c
index aaed6ce4e..f768f86bc 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -164,11 +164,6 @@ void reset_keyboard(void) {
164 bootloader_jump(); 164 bootloader_jump();
165} 165}
166 166
167/* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise.
168 * Used to ensure that the correct keycode is released if the key is released.
169 */
170static bool grave_esc_was_shifted = false;
171
172/* Convert record into usable keycode via the contained event. */ 167/* Convert record into usable keycode via the contained event. */
173uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); } 168uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); }
174 169
@@ -281,6 +276,7 @@ bool process_record_quantum(keyrecord_t *record) {
281 case RESET: 276 case RESET:
282 reset_keyboard(); 277 reset_keyboard();
283 return false; 278 return false;
279#ifndef NO_DEBUG
284 case DEBUG: 280 case DEBUG:
285 debug_enable ^= 1; 281 debug_enable ^= 1;
286 if (debug_enable) { 282 if (debug_enable) {
@@ -288,6 +284,7 @@ bool process_record_quantum(keyrecord_t *record) {
288 } else { 284 } else {
289 print("DEBUG: disabled.\n"); 285 print("DEBUG: disabled.\n");
290 } 286 }
287#endif
291 return false; 288 return false;
292 case EEPROM_RESET: 289 case EEPROM_RESET:
293 eeconfig_init(); 290 eeconfig_init();
@@ -308,18 +305,16 @@ bool process_record_quantum(keyrecord_t *record) {
308 velocikey_toggle(); 305 velocikey_toggle();
309 return false; 306 return false;
310#endif 307#endif
311#ifdef PROTOCOL_LUFA 308#ifdef BLUETOOTH_ENABLE
312 case OUT_AUTO: 309 case OUT_AUTO:
313 set_output(OUTPUT_AUTO); 310 set_output(OUTPUT_AUTO);
314 return false; 311 return false;
315 case OUT_USB: 312 case OUT_USB:
316 set_output(OUTPUT_USB); 313 set_output(OUTPUT_USB);
317 return false; 314 return false;
318# ifdef BLUETOOTH_ENABLE
319 case OUT_BT: 315 case OUT_BT:
320 set_output(OUTPUT_BLUETOOTH); 316 set_output(OUTPUT_BLUETOOTH);
321 return false; 317 return false;
322# endif
323#endif 318#endif
324 } 319 }
325 } 320 }
@@ -590,6 +585,11 @@ bool process_record_quantum(keyrecord_t *record) {
590 break; 585 break;
591 586
592 case GRAVE_ESC: { 587 case GRAVE_ESC: {
588 /* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise.
589 * Used to ensure that the correct keycode is released if the key is released.
590 */
591 static bool grave_esc_was_shifted = false;
592
593 uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI))); 593 uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)));
594 594
595#ifdef GRAVE_ESC_ALT_OVERRIDE 595#ifdef GRAVE_ESC_ALT_OVERRIDE