diff options
Diffstat (limited to 'quantum/quantum.c')
| -rw-r--r-- | quantum/quantum.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index 8ccdb774b..3329c1146 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -49,21 +49,18 @@ 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 | uint8_t extract_mod_bits(uint16_t code) { |
| 62 | switch (code) { | 59 | switch (code) { |
| 63 | case QK_MODS ... QK_MODS_MAX: | 60 | case QK_MODS ... QK_MODS_MAX: |
| 64 | break; | 61 | break; |
| 65 | default: | 62 | default: |
| 66 | return; | 63 | return 0; |
| 67 | } | 64 | } |
| 68 | 65 | ||
| 69 | uint8_t mods_to_send = 0; | 66 | uint8_t mods_to_send = 0; |
| @@ -80,9 +77,11 @@ static void do_code16(uint16_t code, void (*f)(uint8_t)) { | |||
| 80 | if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI); | 77 | if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI); |
| 81 | } | 78 | } |
| 82 | 79 | ||
| 83 | f(mods_to_send); | 80 | return mods_to_send; |
| 84 | } | 81 | } |
| 85 | 82 | ||
| 83 | static void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); } | ||
| 84 | |||
| 86 | void register_code16(uint16_t code) { | 85 | void register_code16(uint16_t code) { |
| 87 | if (IS_MOD(code) || code == KC_NO) { | 86 | if (IS_MOD(code) || code == KC_NO) { |
| 88 | do_code16(code, register_mods); | 87 | do_code16(code, register_mods); |
| @@ -217,10 +216,10 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 217 | #endif | 216 | #endif |
| 218 | #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) | 217 | #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) |
| 219 | process_clicky(keycode, record) && | 218 | process_clicky(keycode, record) && |
| 220 | #endif // AUDIO_CLICKY | 219 | #endif |
| 221 | #ifdef HAPTIC_ENABLE | 220 | #ifdef HAPTIC_ENABLE |
| 222 | process_haptic(keycode, record) && | 221 | process_haptic(keycode, record) && |
| 223 | #endif // HAPTIC_ENABLE | 222 | #endif |
| 224 | #if defined(VIA_ENABLE) | 223 | #if defined(VIA_ENABLE) |
| 225 | process_record_via(keycode, record) && | 224 | process_record_via(keycode, record) && |
| 226 | #endif | 225 | #endif |
| @@ -243,6 +242,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 243 | #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) | 242 | #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) |
| 244 | process_music(keycode, record) && | 243 | process_music(keycode, record) && |
| 245 | #endif | 244 | #endif |
| 245 | #ifdef KEY_OVERRIDE_ENABLE | ||
| 246 | process_key_override(keycode, record) && | ||
| 247 | #endif | ||
| 246 | #ifdef TAP_DANCE_ENABLE | 248 | #ifdef TAP_DANCE_ENABLE |
| 247 | process_tap_dance(keycode, record) && | 249 | process_tap_dance(keycode, record) && |
| 248 | #endif | 250 | #endif |
| @@ -340,13 +342,13 @@ void set_single_persistent_default_layer(uint8_t default_layer) { | |||
| 340 | #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS) | 342 | #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS) |
| 341 | PLAY_SONG(default_layer_songs[default_layer]); | 343 | PLAY_SONG(default_layer_songs[default_layer]); |
| 342 | #endif | 344 | #endif |
| 343 | eeconfig_update_default_layer(1U << default_layer); | 345 | eeconfig_update_default_layer((layer_state_t)1 << default_layer); |
| 344 | default_layer_set(1U << default_layer); | 346 | default_layer_set((layer_state_t)1 << default_layer); |
| 345 | } | 347 | } |
| 346 | 348 | ||
| 347 | layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3) { | 349 | 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); | 350 | layer_state_t mask12 = ((layer_state_t)1 << layer1) | ((layer_state_t)1 << layer2); |
| 349 | layer_state_t mask3 = 1UL << layer3; | 351 | layer_state_t mask3 = (layer_state_t)1 << layer3; |
| 350 | return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3); | 352 | return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3); |
| 351 | } | 353 | } |
| 352 | 354 | ||
| @@ -354,10 +356,7 @@ void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_st | |||
| 354 | 356 | ||
| 355 | void matrix_init_quantum() { | 357 | void matrix_init_quantum() { |
| 356 | magic(); | 358 | magic(); |
| 357 | #if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN) | ||
| 358 | // TODO: remove calls to led_init_ports from keyboards and remove ifdef | ||
| 359 | led_init_ports(); | 359 | led_init_ports(); |
| 360 | #endif | ||
| 361 | #ifdef BACKLIGHT_ENABLE | 360 | #ifdef BACKLIGHT_ENABLE |
| 362 | backlight_init_ports(); | 361 | backlight_init_ports(); |
| 363 | #endif | 362 | #endif |
| @@ -405,19 +404,23 @@ void matrix_scan_quantum() { | |||
| 405 | #endif | 404 | #endif |
| 406 | 405 | ||
| 407 | #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) | 406 | #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) |
| 408 | matrix_scan_music(); | 407 | music_task(); |
| 408 | #endif | ||
| 409 | |||
| 410 | #ifdef KEY_OVERRIDE_ENABLE | ||
| 411 | key_override_task(); | ||
| 409 | #endif | 412 | #endif |
| 410 | 413 | ||
| 411 | #ifdef SEQUENCER_ENABLE | 414 | #ifdef SEQUENCER_ENABLE |
| 412 | matrix_scan_sequencer(); | 415 | sequencer_task(); |
| 413 | #endif | 416 | #endif |
| 414 | 417 | ||
| 415 | #ifdef TAP_DANCE_ENABLE | 418 | #ifdef TAP_DANCE_ENABLE |
| 416 | matrix_scan_tap_dance(); | 419 | tap_dance_task(); |
| 417 | #endif | 420 | #endif |
| 418 | 421 | ||
| 419 | #ifdef COMBO_ENABLE | 422 | #ifdef COMBO_ENABLE |
| 420 | matrix_scan_combo(); | 423 | combo_task(); |
| 421 | #endif | 424 | #endif |
| 422 | 425 | ||
| 423 | #ifdef LED_MATRIX_ENABLE | 426 | #ifdef LED_MATRIX_ENABLE |
