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;
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_LCTRL ... KC_RGUI:
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:
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
break;
#ifdef MOUSEKEY_ENABLE
case KC_MS_UP ... KC_MS_ACCEL2:
action.code = ACTION_MOUSEKEY(keycode);
break;
#endif
case KC_TRNS:
action.code = ACTION_TRANSPARENT;
break;
@ -76,17 +75,24 @@ action_t action_for_key(uint8_t layer, keypos_t key) {
// Split it up
action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key
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:;
// Is a shortcut for function action_layer, pull last 12bits
// This means we have 4,096 FN macros at our disposal
action.code = keymap_function_id_to_action((int)keycode & 0xFFF);
break;
#endif
#ifndef NO_ACTION_MACRO
case QK_MACRO ... QK_MACRO_MAX:
if (keycode & 0x800) // tap macros have upper bit set
action.code = ACTION_MACRO_TAP(keycode & 0xFF);
else
action.code = ACTION_MACRO(keycode & 0xFF);
break;
#endif
case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF);
break;

View File

@ -164,11 +164,6 @@ void reset_keyboard(void) {
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. */
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:
reset_keyboard();
return false;
#ifndef NO_DEBUG
case DEBUG:
debug_enable ^= 1;
if (debug_enable) {
@ -288,6 +284,7 @@ bool process_record_quantum(keyrecord_t *record) {
} else {
print("DEBUG: disabled.\n");
}
#endif
return false;
case EEPROM_RESET:
eeconfig_init();
@ -308,18 +305,16 @@ bool process_record_quantum(keyrecord_t *record) {
velocikey_toggle();
return false;
#endif
#ifdef PROTOCOL_LUFA
#ifdef BLUETOOTH_ENABLE
case OUT_AUTO:
set_output(OUTPUT_AUTO);
return false;
case OUT_USB:
set_output(OUTPUT_USB);
return false;
# ifdef BLUETOOTH_ENABLE
case OUT_BT:
set_output(OUTPUT_BLUETOOTH);
return false;
# endif
#endif
}
}
@ -590,6 +585,11 @@ bool process_record_quantum(keyrecord_t *record) {
break;
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)));
#ifdef GRAVE_ESC_ALT_OVERRIDE