diff options
Diffstat (limited to 'quantum/quantum.c')
| -rw-r--r-- | quantum/quantum.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index 8ccdb774b..f430a521b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -49,21 +49,22 @@ float goodbye_song[][2] = GOODBYE_SONG; | |||
| 49 | # ifdef DEFAULT_LAYER_SONGS | 49 | # ifdef DEFAULT_LAYER_SONGS |
| 50 | float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; | 50 | float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS; |
| 51 | # endif | 51 | # endif |
| 52 | # ifdef SENDSTRING_BELL | ||
| 53 | float bell_song[][2] = SONG(TERMINAL_SOUND); | ||
| 54 | # endif | ||
| 55 | #endif | 52 | #endif |
| 56 | 53 | ||
| 57 | #ifdef AUTO_SHIFT_ENABLE | 54 | #ifdef AUTO_SHIFT_ENABLE |
| 58 | # include "process_auto_shift.h" | 55 | # include "process_auto_shift.h" |
| 59 | #endif | 56 | #endif |
| 60 | 57 | ||
| 61 | static void do_code16(uint16_t code, void (*f)(uint8_t)) { | 58 | #ifdef KEY_OVERRIDE_ENABLE |
| 59 | # include "process_key_override_private.h" | ||
| 60 | #endif | ||
| 61 | |||
| 62 | uint8_t extract_mod_bits(uint16_t code) { | ||
| 62 | switch (code) { | 63 | switch (code) { |
| 63 | case QK_MODS ... QK_MODS_MAX: | 64 | case QK_MODS ... QK_MODS_MAX: |
| 64 | break; | 65 | break; |
| 65 | default: | 66 | default: |
| 66 | return; | 67 | return 0; |
| 67 | } | 68 | } |
| 68 | 69 | ||
| 69 | uint8_t mods_to_send = 0; | 70 | uint8_t mods_to_send = 0; |
| @@ -80,9 +81,11 @@ static void do_code16(uint16_t code, void (*f)(uint8_t)) { | |||
| 80 | if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI); | 81 | if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI); |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | f(mods_to_send); | 84 | return mods_to_send; |
| 84 | } | 85 | } |
| 85 | 86 | ||
| 87 | static void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); } | ||
| 88 | |||
| 86 | void register_code16(uint16_t code) { | 89 | void register_code16(uint16_t code) { |
| 87 | if (IS_MOD(code) || code == KC_NO) { | 90 | if (IS_MOD(code) || code == KC_NO) { |
| 88 | do_code16(code, register_mods); | 91 | do_code16(code, register_mods); |
| @@ -217,10 +220,10 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 217 | #endif | 220 | #endif |
| 218 | #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) | 221 | #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) |
| 219 | process_clicky(keycode, record) && | 222 | process_clicky(keycode, record) && |
| 220 | #endif // AUDIO_CLICKY | 223 | #endif |
| 221 | #ifdef HAPTIC_ENABLE | 224 | #ifdef HAPTIC_ENABLE |
| 222 | process_haptic(keycode, record) && | 225 | process_haptic(keycode, record) && |
| 223 | #endif // HAPTIC_ENABLE | 226 | #endif |
| 224 | #if defined(VIA_ENABLE) | 227 | #if defined(VIA_ENABLE) |
| 225 | process_record_via(keycode, record) && | 228 | process_record_via(keycode, record) && |
| 226 | #endif | 229 | #endif |
| @@ -243,6 +246,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 243 | #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) | 246 | #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) |
| 244 | process_music(keycode, record) && | 247 | process_music(keycode, record) && |
| 245 | #endif | 248 | #endif |
| 249 | #ifdef KEY_OVERRIDE_ENABLE | ||
| 250 | process_key_override(keycode, record) && | ||
| 251 | #endif | ||
| 246 | #ifdef TAP_DANCE_ENABLE | 252 | #ifdef TAP_DANCE_ENABLE |
| 247 | process_tap_dance(keycode, record) && | 253 | process_tap_dance(keycode, record) && |
| 248 | #endif | 254 | #endif |
| @@ -340,13 +346,13 @@ void set_single_persistent_default_layer(uint8_t default_layer) { | |||
| 340 | #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS) | 346 | #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS) |
| 341 | PLAY_SONG(default_layer_songs[default_layer]); | 347 | PLAY_SONG(default_layer_songs[default_layer]); |
| 342 | #endif | 348 | #endif |
| 343 | eeconfig_update_default_layer(1U << default_layer); | 349 | eeconfig_update_default_layer((layer_state_t)1 << default_layer); |
| 344 | default_layer_set(1U << default_layer); | 350 | default_layer_set((layer_state_t)1 << default_layer); |
| 345 | } | 351 | } |
| 346 | 352 | ||
| 347 | layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3) { | 353 | layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3) { |
| 348 | layer_state_t mask12 = (1UL << layer1) | (1UL << layer2); | 354 | layer_state_t mask12 = ((layer_state_t)1 << layer1) | ((layer_state_t)1 << layer2); |
| 349 | layer_state_t mask3 = 1UL << layer3; | 355 | layer_state_t mask3 = (layer_state_t)1 << layer3; |
| 350 | return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3); | 356 | return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3); |
| 351 | } | 357 | } |
| 352 | 358 | ||
| @@ -408,6 +414,10 @@ void matrix_scan_quantum() { | |||
| 408 | matrix_scan_music(); | 414 | matrix_scan_music(); |
| 409 | #endif | 415 | #endif |
| 410 | 416 | ||
| 417 | #ifdef KEY_OVERRIDE_ENABLE | ||
| 418 | matrix_scan_key_override(); | ||
| 419 | #endif | ||
| 420 | |||
| 411 | #ifdef SEQUENCER_ENABLE | 421 | #ifdef SEQUENCER_ENABLE |
| 412 | matrix_scan_sequencer(); | 422 | matrix_scan_sequencer(); |
| 413 | #endif | 423 | #endif |
