diff options
Diffstat (limited to 'users')
-rw-r--r-- | users/bcat/bcat.c | 39 | ||||
-rw-r--r-- | users/bcat/bcat.h | 8 | ||||
-rw-r--r-- | users/bcat/rules.mk | 5 |
3 files changed, 49 insertions, 3 deletions
diff --git a/users/bcat/bcat.c b/users/bcat/bcat.c index 2b250c10f1..397d565da0 100644 --- a/users/bcat/bcat.c +++ b/users/bcat/bcat.c @@ -1,6 +1,43 @@ -#include "quantum.h" +#include "bcat.h" #if defined(RGBLIGHT_ENABLE) /* Adjust RGB static hue ranges for shorter gradients than default. */ const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 127, 63, 31, 15}; #endif + +static int8_t alt_tab_layer = -1; + +__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (!process_record_keymap(keycode, record)) { + return false; + } + switch (keycode) { + /* Alt+Tab that holds Alt until current layer is released: */ + case MC_ALTT: + if (record->event.pressed) { + if (alt_tab_layer < 0) { + alt_tab_layer = layer_switch_get_layer(record->event.key); + register_code(KC_LALT); + } + register_code(KC_TAB); + } else { + unregister_code(KC_TAB); + } + return false; + default: + return true; + } +} + +__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; } + +layer_state_t layer_state_set_user(layer_state_t state) { + state = layer_state_set_keymap(state); + if (alt_tab_layer >= 0 && !layer_state_cmp(state, alt_tab_layer)) { + unregister_code(KC_LALT); + alt_tab_layer = -1; + } + return state; +} diff --git a/users/bcat/bcat.h b/users/bcat/bcat.h new file mode 100644 index 0000000000..1ea05e5fa8 --- /dev/null +++ b/users/bcat/bcat.h @@ -0,0 +1,8 @@ +#pragma once + +#include "quantum.h" + +enum user_keycodes { + MC_ALTT = SAFE_RANGE, + KEYMAP_SAFE_RANGE, +}; diff --git a/users/bcat/rules.mk b/users/bcat/rules.mk index f3c6f9ab27..f979c703f8 100644 --- a/users/bcat/rules.mk +++ b/users/bcat/rules.mk @@ -3,8 +3,10 @@ SRC += bcat.c # Enable Bootmagic Lite to consistently reset to bootloader and clear EEPROM. BOOTMAGIC_ENABLE = lite -# Enable media keys on all keyboards. +# Enable media keys on all keyboards. (Even though I don't use mouse keys, they +# seem to be required for media keys to register on Chrome OS.) EXTRAKEY_ENABLE = yes +MOUSEKEY_ENABLE = yes # Enable link-time optimization to reduce binary size. LINK_TIME_OPTIMIZATION_ENABLE = yes @@ -12,7 +14,6 @@ LINK_TIME_OPTIMIZATION_ENABLE = yes # Disable unused build options on all keyboards. COMMAND_ENABLE = no CONSOLE_ENABLE = no -MOUSEKEY_ENABLE = no NKRO_ENABLE = no TERMINAL_ENABLE = no |