diff options
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r-- | quantum/quantum.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index cf16e953a..8ae487bec 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -391,6 +391,29 @@ __attribute__((weak)) const uint8_t ascii_to_altgr_lut[16] PROGMEM = { | |||
391 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | 391 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), |
392 | }; | 392 | }; |
393 | 393 | ||
394 | /* Bit-Packed look-up table to convert an ASCII character to whether | ||
395 | * [Space] needs to be sent after the keycode | ||
396 | */ | ||
397 | __attribute__((weak)) const uint8_t ascii_to_dead_lut[16] PROGMEM = { | ||
398 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
399 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
400 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
401 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
402 | |||
403 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
404 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
405 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
406 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
407 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
408 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
409 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
410 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
411 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
412 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
413 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
414 | KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), | ||
415 | }; | ||
416 | |||
394 | /* Look-up table to convert an ASCII character to a keycode. | 417 | /* Look-up table to convert an ASCII character to a keycode. |
395 | */ | 418 | */ |
396 | __attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = { | 419 | __attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = { |
@@ -531,6 +554,7 @@ void send_char(char ascii_code) { | |||
531 | uint8_t keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]); | 554 | uint8_t keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]); |
532 | bool is_shifted = PGM_LOADBIT(ascii_to_shift_lut, (uint8_t)ascii_code); | 555 | bool is_shifted = PGM_LOADBIT(ascii_to_shift_lut, (uint8_t)ascii_code); |
533 | bool is_altgred = PGM_LOADBIT(ascii_to_altgr_lut, (uint8_t)ascii_code); | 556 | bool is_altgred = PGM_LOADBIT(ascii_to_altgr_lut, (uint8_t)ascii_code); |
557 | bool is_dead = PGM_LOADBIT(ascii_to_dead_lut, (uint8_t)ascii_code); | ||
534 | 558 | ||
535 | if (is_shifted) { | 559 | if (is_shifted) { |
536 | register_code(KC_LSFT); | 560 | register_code(KC_LSFT); |
@@ -545,6 +569,9 @@ void send_char(char ascii_code) { | |||
545 | if (is_shifted) { | 569 | if (is_shifted) { |
546 | unregister_code(KC_LSFT); | 570 | unregister_code(KC_LSFT); |
547 | } | 571 | } |
572 | if (is_dead) { | ||
573 | tap_code(KC_SPACE); | ||
574 | } | ||
548 | } | 575 | } |
549 | 576 | ||
550 | void set_single_persistent_default_layer(uint8_t default_layer) { | 577 | void set_single_persistent_default_layer(uint8_t default_layer) { |
@@ -629,6 +656,26 @@ void matrix_init_quantum() { | |||
629 | } | 656 | } |
630 | 657 | ||
631 | void matrix_scan_quantum() { | 658 | void matrix_scan_quantum() { |
659 | #if defined(AUDIO_ENABLE) | ||
660 | // There are some tasks that need to be run a little bit | ||
661 | // after keyboard startup, or else they will not work correctly | ||
662 | // because of interaction with the USB device state, which | ||
663 | // may still be in flux... | ||
664 | // | ||
665 | // At the moment the only feature that needs this is the | ||
666 | // startup song. | ||
667 | static bool delayed_tasks_run = false; | ||
668 | static uint16_t delayed_task_timer = 0; | ||
669 | if (!delayed_tasks_run) { | ||
670 | if (!delayed_task_timer) { | ||
671 | delayed_task_timer = timer_read(); | ||
672 | } else if (timer_elapsed(delayed_task_timer) > 300) { | ||
673 | audio_startup(); | ||
674 | delayed_tasks_run = true; | ||
675 | } | ||
676 | } | ||
677 | #endif | ||
678 | |||
632 | #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) | 679 | #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) |
633 | matrix_scan_music(); | 680 | matrix_scan_music(); |
634 | #endif | 681 | #endif |