diff options
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r-- | quantum/quantum.c | 152 |
1 files changed, 130 insertions, 22 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index d59bd5a3f8..e3a20f43e0 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -1,5 +1,42 @@ #include "quantum.h" +static void do_code16 (uint16_t code, void (*f) (uint8_t)) { + switch (code) { + case QK_MODS ... QK_MODS_MAX: + break; + default: + return; + } + + if (code & QK_LCTL) + f(KC_LCTL); + if (code & QK_LSFT) + f(KC_LSFT); + if (code & QK_LALT) + f(KC_LALT); + if (code & QK_LGUI) + f(KC_LGUI); + + if (code & QK_RCTL) + f(KC_RCTL); + if (code & QK_RSFT) + f(KC_RSFT); + if (code & QK_RALT) + f(KC_RALT); + if (code & QK_RGUI) + f(KC_RGUI); +} + +void register_code16 (uint16_t code) { + do_code16 (code, register_code); + register_code (code); +} + +void unregister_code16 (uint16_t code) { + unregister_code (code); + do_code16 (code, unregister_code); +} + __attribute__ ((weak)) bool process_action_kb(keyrecord_t *record) { return true; @@ -15,6 +52,19 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } +void reset_keyboard(void) { + clear_keyboard(); +#ifdef AUDIO_ENABLE + stop_all_notes(); + shutdown_user(); +#endif + wait_ms(250); +#ifdef CATERINA_BOOTLOADER + *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific +#endif + bootloader_jump(); +} + // Shift / paren setup #ifndef LSPO_KEY @@ -33,18 +83,20 @@ bool process_record_quantum(keyrecord_t *record) { uint16_t keycode; #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) - uint8_t layer; + /* TODO: Use store_or_get_action() or a similar function. */ + if (!disable_action_cache) { + uint8_t layer; - if (record->event.pressed) { - layer = layer_switch_get_layer(key); - update_source_layers_cache(key, layer); - } else { - layer = read_source_layers_cache(key); - } - keycode = keymap_key_to_keycode(layer, key); - #else - keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); + if (record->event.pressed) { + layer = layer_switch_get_layer(key); + update_source_layers_cache(key, layer); + } else { + layer = read_source_layers_cache(key); + } + keycode = keymap_key_to_keycode(layer, key); + } else #endif + keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); // This is how you use actions here // if (keycode == KC_LEAD) { @@ -74,6 +126,9 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef UNICODE_ENABLE process_unicode(keycode, record) && #endif + #ifdef UCIS_ENABLE + process_ucis(keycode, record) && + #endif true)) { return false; } @@ -83,26 +138,67 @@ bool process_record_quantum(keyrecord_t *record) { switch(keycode) { case RESET: if (record->event.pressed) { - clear_keyboard(); - #ifdef AUDIO_ENABLE - stop_all_notes(); - shutdown_user(); - #endif - wait_ms(250); - #ifdef ATREUS_ASTAR - *(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific - #endif - bootloader_jump(); - return false; + reset_keyboard(); } + return false; break; case DEBUG: if (record->event.pressed) { print("\nDEBUG: enabled.\n"); debug_enable = true; - return false; } + return false; + break; + #ifdef RGBLIGHT_ENABLE + case RGB_TOG: + if (record->event.pressed) { + rgblight_toggle(); + } + return false; + break; + case RGB_MOD: + if (record->event.pressed) { + rgblight_step(); + } + return false; + break; + case RGB_HUI: + if (record->event.pressed) { + rgblight_increase_hue(); + } + return false; + break; + case RGB_HUD: + if (record->event.pressed) { + rgblight_decrease_hue(); + } + return false; break; + case RGB_SAI: + if (record->event.pressed) { + rgblight_increase_sat(); + } + return false; + break; + case RGB_SAD: + if (record->event.pressed) { + rgblight_decrease_sat(); + } + return false; + break; + case RGB_VAI: + if (record->event.pressed) { + rgblight_increase_val(); + } + return false; + break; + case RGB_VAD: + if (record->event.pressed) { + rgblight_decrease_val(); + } + return false; + break; + #endif case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI: if (record->event.pressed) { // MAGIC actions (BOOTMAGIC without the boot) @@ -162,6 +258,12 @@ bool process_record_quantum(keyrecord_t *record) { register_mods(MOD_BIT(KC_LSFT)); } else { + #ifdef DISABLE_SPACE_CADET_ROLLOVER + if (get_mods() & MOD_BIT(KC_RSFT)) { + shift_interrupted[0] = true; + shift_interrupted[1] = true; + } + #endif if (!shift_interrupted[0]) { register_code(LSPO_KEY); unregister_code(LSPO_KEY); @@ -178,6 +280,12 @@ bool process_record_quantum(keyrecord_t *record) { register_mods(MOD_BIT(KC_RSFT)); } else { + #ifdef DISABLE_SPACE_CADET_ROLLOVER + if (get_mods() & MOD_BIT(KC_LSFT)) { + shift_interrupted[0] = true; + shift_interrupted[1] = true; + } + #endif if (!shift_interrupted[1]) { register_code(RSPC_KEY); unregister_code(RSPC_KEY); |