Compile out some keycode processing when features are disabled (#7506)

This commit is contained in:
Joel Challis 2019-11-28 21:59:59 +00:00 committed by GitHub
parent 99f3321e26
commit 2048df8832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View File

@ -52,9 +52,6 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
uint8_t action_layer, when, mod; uint8_t action_layer, when, mod;
switch (keycode) { switch (keycode) {
case KC_FN0 ... KC_FN31:
action.code = keymap_function_id_to_action(FN_INDEX(keycode));
break;
case KC_A ... KC_EXSEL: case KC_A ... KC_EXSEL:
case KC_LCTRL ... KC_RGUI: case KC_LCTRL ... KC_RGUI:
action.code = ACTION_KEY(keycode); action.code = ACTION_KEY(keycode);
@ -65,9 +62,11 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
case KC_AUDIO_MUTE ... KC_BRIGHTNESS_DOWN: case KC_AUDIO_MUTE ... KC_BRIGHTNESS_DOWN:
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
break; break;
#ifdef MOUSEKEY_ENABLE
case KC_MS_UP ... KC_MS_ACCEL2: case KC_MS_UP ... KC_MS_ACCEL2:
action.code = ACTION_MOUSEKEY(keycode); action.code = ACTION_MOUSEKEY(keycode);
break; break;
#endif
case KC_TRNS: case KC_TRNS:
action.code = ACTION_TRANSPARENT; action.code = ACTION_TRANSPARENT;
break; break;
@ -76,17 +75,24 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
// Split it up // Split it up
action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
break; break;
#ifndef NO_ACTION_FUNCTION
case KC_FN0 ... KC_FN31:
action.code = keymap_function_id_to_action(FN_INDEX(keycode));
break;
case QK_FUNCTION ... QK_FUNCTION_MAX:; case QK_FUNCTION ... QK_FUNCTION_MAX:;
// Is a shortcut for function action_layer, pull last 12bits // Is a shortcut for function action_layer, pull last 12bits
// This means we have 4,096 FN macros at our disposal // This means we have 4,096 FN macros at our disposal
action.code = keymap_function_id_to_action((int)keycode & 0xFFF); action.code = keymap_function_id_to_action((int)keycode & 0xFFF);
break; break;
#endif
#ifndef NO_ACTION_MACRO
case QK_MACRO ... QK_MACRO_MAX: case QK_MACRO ... QK_MACRO_MAX:
if (keycode & 0x800) // tap macros have upper bit set if (keycode & 0x800) // tap macros have upper bit set
action.code = ACTION_MACRO_TAP(keycode & 0xFF); action.code = ACTION_MACRO_TAP(keycode & 0xFF);
else else
action.code = ACTION_MACRO(keycode & 0xFF); action.code = ACTION_MACRO(keycode & 0xFF);
break; break;
#endif
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
break; break;

View File

@ -164,11 +164,6 @@ void reset_keyboard(void) {
bootloader_jump(); bootloader_jump();
} }
/* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise.
* Used to ensure that the correct keycode is released if the key is released.
*/
static bool grave_esc_was_shifted = false;
/* Convert record into usable keycode via the contained event. */ /* Convert record into usable keycode via the contained event. */
uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); } uint16_t get_record_keycode(keyrecord_t *record) { return get_event_keycode(record->event); }
@ -281,6 +276,7 @@ bool process_record_quantum(keyrecord_t *record) {
case RESET: case RESET:
reset_keyboard(); reset_keyboard();
return false; return false;
#ifndef NO_DEBUG
case DEBUG: case DEBUG:
debug_enable ^= 1; debug_enable ^= 1;
if (debug_enable) { if (debug_enable) {
@ -288,6 +284,7 @@ bool process_record_quantum(keyrecord_t *record) {
} else { } else {
print("DEBUG: disabled.\n"); print("DEBUG: disabled.\n");
} }
#endif
return false; return false;
case EEPROM_RESET: case EEPROM_RESET:
eeconfig_init(); eeconfig_init();
@ -308,18 +305,16 @@ bool process_record_quantum(keyrecord_t *record) {
velocikey_toggle(); velocikey_toggle();
return false; return false;
#endif #endif
#ifdef PROTOCOL_LUFA #ifdef BLUETOOTH_ENABLE
case OUT_AUTO: case OUT_AUTO:
set_output(OUTPUT_AUTO); set_output(OUTPUT_AUTO);
return false; return false;
case OUT_USB: case OUT_USB:
set_output(OUTPUT_USB); set_output(OUTPUT_USB);
return false; return false;
# ifdef BLUETOOTH_ENABLE
case OUT_BT: case OUT_BT:
set_output(OUTPUT_BLUETOOTH); set_output(OUTPUT_BLUETOOTH);
return false; return false;
# endif
#endif #endif
} }
} }
@ -590,6 +585,11 @@ bool process_record_quantum(keyrecord_t *record) {
break; break;
case GRAVE_ESC: { case GRAVE_ESC: {
/* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise.
* Used to ensure that the correct keycode is released if the key is released.
*/
static bool grave_esc_was_shifted = false;
uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI))); uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)));
#ifdef GRAVE_ESC_ALT_OVERRIDE #ifdef GRAVE_ESC_ALT_OVERRIDE