diff options
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r-- | quantum/quantum.c | 149 |
1 files changed, 118 insertions, 31 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index ab47fa48ff..85db100ab4 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -42,6 +42,11 @@ extern backlight_config_t backlight_config; #include "process_midi.h" #endif + +#ifdef ENCODER_ENABLE +#include "encoder.h" +#endif + #ifdef AUDIO_ENABLE #ifndef GOODBYE_SONG #define GOODBYE_SONG SONG(GOODBYE_SOUND) @@ -127,6 +132,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; @@ -196,7 +209,7 @@ bool process_record_quantum(keyrecord_t *record) { keypos_t key = record->event.key; uint16_t keycode; - #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) + #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) /* TODO: Use store_or_get_action() or a similar function. */ if (!disable_action_cache) { uint8_t layer; @@ -230,7 +243,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) @@ -245,36 +258,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 - #ifndef DISABLE_LEADER - process_leader(keycode, record) && + #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) + process_unicode_common(keycode, record) && #endif - #ifndef DISABLE_CHORDING - process_chording(keycode, record) && + #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 @@ -296,6 +300,11 @@ bool process_record_quantum(keyrecord_t *record) { print("DEBUG: enabled.\n"); } return false; + case EEPROM_RESET: + if (record->event.pressed) { + eeconfig_init(); + } + return false; #ifdef FAUXCLICKY_ENABLE case FC_TOG: if (record->event.pressed) { @@ -445,75 +454,97 @@ bool process_record_quantum(keyrecord_t *record) { return false; case RGB_MODE_PLAIN: if (record->event.pressed) { - rgblight_mode(1); + rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); #ifdef SPLIT_KEYBOARD RGB_DIRTY = true; #endif } return false; case RGB_MODE_BREATHE: + #ifdef RGBLIGHT_EFFECT_BREATHING if (record->event.pressed) { - if ((2 <= rgblight_get_mode()) && (rgblight_get_mode() < 5)) { + if ((RGBLIGHT_MODE_BREATHING <= rgblight_get_mode()) && + (rgblight_get_mode() < RGBLIGHT_MODE_BREATHING_end)) { rgblight_step(); } else { - rgblight_mode(2); + rgblight_mode(RGBLIGHT_MODE_BREATHING); } } + #endif return false; case RGB_MODE_RAINBOW: + #ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD if (record->event.pressed) { - if ((6 <= rgblight_get_mode()) && (rgblight_get_mode() < 8)) { + if ((RGBLIGHT_MODE_RAINBOW_MOOD <= rgblight_get_mode()) && + (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_MOOD_end)) { rgblight_step(); } else { - rgblight_mode(6); + rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD); } } + #endif return false; case RGB_MODE_SWIRL: + #ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL if (record->event.pressed) { - if ((9 <= rgblight_get_mode()) && (rgblight_get_mode() < 14)) { + if ((RGBLIGHT_MODE_RAINBOW_SWIRL <= rgblight_get_mode()) && + (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_SWIRL_end)) { rgblight_step(); } else { - rgblight_mode(9); + rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL); } } + #endif return false; case RGB_MODE_SNAKE: + #ifdef RGBLIGHT_EFFECT_SNAKE if (record->event.pressed) { - if ((15 <= rgblight_get_mode()) && (rgblight_get_mode() < 20)) { + if ((RGBLIGHT_MODE_SNAKE <= rgblight_get_mode()) && + (rgblight_get_mode() < RGBLIGHT_MODE_SNAKE_end)) { rgblight_step(); } else { - rgblight_mode(15); + rgblight_mode(RGBLIGHT_MODE_SNAKE); } } + #endif return false; case RGB_MODE_KNIGHT: + #ifdef RGBLIGHT_EFFECT_KNIGHT if (record->event.pressed) { - if ((21 <= rgblight_get_mode()) && (rgblight_get_mode() < 23)) { + if ((RGBLIGHT_MODE_KNIGHT <= rgblight_get_mode()) && + (rgblight_get_mode() < RGBLIGHT_MODE_KNIGHT_end)) { rgblight_step(); } else { - rgblight_mode(21); + rgblight_mode(RGBLIGHT_MODE_KNIGHT); } } + #endif return false; case RGB_MODE_XMAS: + #ifdef RGBLIGHT_EFFECT_CHRISTMAS if (record->event.pressed) { - rgblight_mode(24); + rgblight_mode(RGBLIGHT_MODE_CHRISTMAS); } + #endif return false; case RGB_MODE_GRADIENT: + #ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT if (record->event.pressed) { - if ((25 <= rgblight_get_mode()) && (rgblight_get_mode() < 34)) { + if ((RGBLIGHT_MODE_STATIC_GRADIENT <= rgblight_get_mode()) && + (rgblight_get_mode() < RGBLIGHT_MODE_STATIC_GRADIENT_end)) { rgblight_step(); } else { - rgblight_mode(25); + rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT); } } + #endif return false; case RGB_MODE_RGBTEST: + #ifdef RGBLIGHT_EFFECT_RGB_TEST if (record->event.pressed) { - rgblight_mode(35); + rgblight_mode(RGBLIGHT_MODE_RGB_TEST); } + #endif return false; #endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) #ifdef PROTOCOL_LUFA @@ -607,6 +638,17 @@ bool process_record_quantum(keyrecord_t *record) { PLAY_SONG(ag_norm_song); #endif break; + case MAGIC_TOGGLE_ALT_GUI: + keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; + keymap_config.swap_ralt_rgui = !keymap_config.swap_ralt_rgui; + #ifdef AUDIO_ENABLE + if (keymap_config.swap_ralt_rgui) { + PLAY_SONG(ag_swap_song); + } else { + PLAY_SONG(ag_norm_song); + } + #endif + break; case MAGIC_TOGGLE_NKRO: keymap_config.nkro = !keymap_config.nkro; break; @@ -914,7 +956,42 @@ void tap_random_base64(void) { } } +__attribute__((weak)) +void bootmagic_lite(void) { + // The lite version of TMK's bootmagic based on Wilba. + // 100% less potential for accidentally making the + // keyboard do stupid things. + + // We need multiple scans because debouncing can't be turned off. + matrix_scan(); + #if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0 + wait_ms(DEBOUNCING_DELAY * 2); + #elif defined(DEBOUNCE) && DEBOUNCE > 0 + wait_ms(DEBOUNCE * 2); + #else + wait_ms(30); + #endif + matrix_scan(); + + // If the Esc and space bar are held down on power up, + // reset the EEPROM valid state and jump to bootloader. + // Assumes Esc is at [0,0]. + // This isn't very generalized, but we need something that doesn't + // rely on user's keymaps in firmware or EEPROM. + if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { + eeconfig_disable(); + // Jump to bootloader. + bootloader_jump(); + } +} + void matrix_init_quantum() { + #ifdef BOOTMAGIC_LITE + bootmagic_lite(); + #endif + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } #ifdef BACKLIGHT_ENABLE backlight_init_ports(); #endif @@ -924,6 +1001,12 @@ void matrix_init_quantum() { #ifdef RGB_MATRIX_ENABLE rgb_matrix_init(); #endif + #ifdef ENCODER_ENABLE + encoder_init(); + #endif + #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) + unicode_input_mode_init(); + #endif matrix_init_kb(); } @@ -958,6 +1041,10 @@ void matrix_scan_quantum() { rgb_matrix_task_counter = ((rgb_matrix_task_counter + 1) % (RGB_MATRIX_SKIP_FRAMES + 1)); #endif + #ifdef ENCODER_ENABLE + encoder_read(); + #endif + matrix_scan_kb(); } #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_PIN) |