X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=quantum%2Fquantum.c;h=0e605d4cb45f0904561ffba16983a7d4df3e9705;hb=c080a3e7c4aa565c696224588b16d4e883f60a7b;hp=69692233ebe4254c95223c7790f6bdd7eda8ffe4;hpb=6e44f94f21ef45865eb8820923d4c9c696f08133;p=qmk_firmware.git diff --git a/quantum/quantum.c b/quantum/quantum.c index 69692233e..0e605d4cb 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -15,6 +15,11 @@ */ #include "quantum.h" + +#if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE) + #include "rgb.h" +#endif + #ifdef PROTOCOL_LUFA #include "outputselect.h" #endif @@ -132,6 +137,14 @@ void unregister_code16 (uint16_t code) { } } +void tap_code16(uint16_t code) { + register_code16(code); + #if TAP_CODE_DELAY > 0 + wait_ms(TAP_CODE_DELAY); + #endif + unregister_code16(code); +} + __attribute__ ((weak)) bool process_action_kb(keyrecord_t *record) { return true; @@ -182,6 +195,13 @@ void reset_keyboard(void) { #define RSPC_KEY KC_0 #endif +#ifndef LSPO_MOD + #define LSPO_MOD KC_LSFT +#endif +#ifndef RSPC_MOD + #define RSPC_MOD KC_RSFT +#endif + // Shift / Enter setup #ifndef SFTENT_KEY #define SFTENT_KEY KC_ENT @@ -235,7 +255,7 @@ bool process_record_quantum(keyrecord_t *record) { process_key_lock(&keycode, record) && #endif #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) - process_clicky(keycode, record) && + process_clicky(keycode, record) && #endif //AUDIO_CLICKY process_record_kb(keycode, record) && #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYPRESSES) @@ -250,33 +270,27 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef STENO_ENABLE process_steno(keycode, record) && #endif - #if ( defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) + #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) process_music(keycode, record) && #endif #ifdef TAP_DANCE_ENABLE process_tap_dance(keycode, record) && #endif + #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) + process_unicode_common(keycode, record) && + #endif #ifdef LEADER_ENABLE process_leader(keycode, record) && #endif #ifdef COMBO_ENABLE process_combo(keycode, record) && #endif - #ifdef UNICODE_ENABLE - process_unicode(keycode, record) && - #endif - #ifdef UCIS_ENABLE - process_ucis(keycode, record) && - #endif #ifdef PRINTING_ENABLE process_printer(keycode, record) && #endif #ifdef AUTO_SHIFT_ENABLE process_auto_shift(keycode, record) && #endif - #ifdef UNICODEMAP_ENABLE - process_unicode_map(keycode, record) && - #endif #ifdef TERMINAL_ENABLE process_terminal(keycode, record) && #endif @@ -667,14 +681,27 @@ bool process_record_quantum(keyrecord_t *record) { } else { #ifdef DISABLE_SPACE_CADET_ROLLOVER - if (get_mods() & MOD_BIT(KC_RSFT)) { + if (get_mods() & MOD_BIT(RSPC_MOD)) { shift_interrupted[0] = true; shift_interrupted[1] = true; } #endif if (!shift_interrupted[0] && timer_elapsed(scs_timer[0]) < TAPPING_TERM) { + #ifdef DISABLE_SPACE_CADET_MODIFIER + unregister_mods(MOD_BIT(KC_LSFT)); + #else + if( LSPO_MOD != KC_LSFT ){ + unregister_mods(MOD_BIT(KC_LSFT)); + register_mods(MOD_BIT(LSPO_MOD)); + } + #endif register_code(LSPO_KEY); unregister_code(LSPO_KEY); + #ifndef DISABLE_SPACE_CADET_MODIFIER + if( LSPO_MOD != KC_LSFT ){ + unregister_mods(MOD_BIT(LSPO_MOD)); + } + #endif } unregister_mods(MOD_BIT(KC_LSFT)); } @@ -689,14 +716,27 @@ bool process_record_quantum(keyrecord_t *record) { } else { #ifdef DISABLE_SPACE_CADET_ROLLOVER - if (get_mods() & MOD_BIT(KC_LSFT)) { + if (get_mods() & MOD_BIT(LSPO_MOD)) { shift_interrupted[0] = true; shift_interrupted[1] = true; } #endif if (!shift_interrupted[1] && timer_elapsed(scs_timer[1]) < TAPPING_TERM) { + #ifdef DISABLE_SPACE_CADET_MODIFIER + unregister_mods(MOD_BIT(KC_RSFT)); + #else + if( RSPC_MOD != KC_RSFT ){ + unregister_mods(MOD_BIT(KC_RSFT)); + register_mods(MOD_BIT(RSPC_MOD)); + } + #endif register_code(RSPC_KEY); unregister_code(RSPC_KEY); + #ifndef DISABLE_SPACE_CADET_MODIFIER + if ( RSPC_MOD != KC_RSFT ){ + unregister_mods(MOD_BIT(RSPC_MOD)); + } + #endif } unregister_mods(MOD_BIT(KC_RSFT)); } @@ -991,7 +1031,11 @@ void matrix_init_quantum() { eeconfig_init(); } #ifdef BACKLIGHT_ENABLE - backlight_init_ports(); + #ifdef LED_MATRIX_ENABLE + led_matrix_init(); + #else + backlight_init_ports(); + #endif #endif #ifdef AUDIO_ENABLE audio_init(); @@ -1002,6 +1046,9 @@ void matrix_init_quantum() { #ifdef ENCODER_ENABLE encoder_init(); #endif + #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) + unicode_input_mode_init(); + #endif matrix_init_kb(); } @@ -1024,8 +1071,12 @@ void matrix_scan_quantum() { matrix_scan_combo(); #endif - #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_PIN) - backlight_task(); + #if defined(BACKLIGHT_ENABLE) + #if defined(LED_MATRIX_ENABLE) + led_matrix_task(); + #elif defined(BACKLIGHT_PIN) + backlight_task(); + #endif #endif #ifdef RGB_MATRIX_ENABLE @@ -1155,7 +1206,7 @@ static inline void set_pwm(uint16_t val) { OCRxx = val; } -#ifndef BACKLIGHT_CUSTOM_DRIVER +#ifndef BACKLIGHT_CUSTOM_DRIVER || LED_MATRIX_ENABLE __attribute__ ((weak)) void backlight_set(uint8_t level) { if (level > BACKLIGHT_LEVELS) @@ -1438,6 +1489,24 @@ void led_set(uint8_t usb_led) // PORTE &= ~(1<<6); // } +#if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE) + // Use backlight as Caps Lock indicator + uint8_t bl_toggle_lvl = 0; + + if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK) && !backlight_config.enable) { + // Turning Caps Lock ON and backlight is disabled in config + // Toggling backlight to the brightest level + bl_toggle_lvl = BACKLIGHT_LEVELS; + } else if (IS_LED_OFF(usb_led, USB_LED_CAPS_LOCK) && backlight_config.enable) { + // Turning Caps Lock OFF and backlight is enabled in config + // Toggling backlight and restoring config level + bl_toggle_lvl = backlight_config.level; + } + + // Set level without modify backlight_config to keep ability to restore state + backlight_set(bl_toggle_lvl); +#endif + led_set_kb(usb_led); }