aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r--quantum/quantum.c72
1 files changed, 47 insertions, 25 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index cf16e953a..38234bb17 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -25,10 +25,6 @@
25# include "backlight.h" 25# include "backlight.h"
26#endif 26#endif
27 27
28#ifdef FAUXCLICKY_ENABLE
29# include "fauxclicky.h"
30#endif
31
32#ifdef API_ENABLE 28#ifdef API_ENABLE
33# include "api.h" 29# include "api.h"
34#endif 30#endif
@@ -225,9 +221,6 @@ bool process_record_quantum(keyrecord_t *record) {
225#ifdef HAPTIC_ENABLE 221#ifdef HAPTIC_ENABLE
226 process_haptic(keycode, record) && 222 process_haptic(keycode, record) &&
227#endif // HAPTIC_ENABLE 223#endif // HAPTIC_ENABLE
228#if defined(RGB_MATRIX_ENABLE)
229 process_rgb_matrix(keycode, record) &&
230#endif
231#if defined(VIA_ENABLE) 224#if defined(VIA_ENABLE)
232 process_record_via(keycode, record) && 225 process_record_via(keycode, record) &&
233#endif 226#endif
@@ -310,17 +303,6 @@ bool process_record_quantum(keyrecord_t *record) {
310 case EEPROM_RESET: 303 case EEPROM_RESET:
311 eeconfig_init(); 304 eeconfig_init();
312 return false; 305 return false;
313#ifdef FAUXCLICKY_ENABLE
314 case FC_TOG:
315 FAUXCLICKY_TOGGLE;
316 return false;
317 case FC_ON:
318 FAUXCLICKY_ON;
319 return false;
320 case FC_OFF:
321 FAUXCLICKY_OFF;
322 return false;
323#endif
324#ifdef VELOCIKEY_ENABLE 306#ifdef VELOCIKEY_ENABLE
325 case VLK_TOG: 307 case VLK_TOG:
326 velocikey_toggle(); 308 velocikey_toggle();
@@ -391,6 +373,29 @@ __attribute__((weak)) const uint8_t ascii_to_altgr_lut[16] PROGMEM = {
391 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), 373 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
392}; 374};
393 375
376/* Bit-Packed look-up table to convert an ASCII character to whether
377 * [Space] needs to be sent after the keycode
378 */
379__attribute__((weak)) const uint8_t ascii_to_dead_lut[16] PROGMEM = {
380 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
381 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
382 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
383 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
384
385 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
386 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
387 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
388 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
389 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
390 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
391 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
392 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
393 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
394 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
395 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
396 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
397};
398
394/* Look-up table to convert an ASCII character to a keycode. 399/* Look-up table to convert an ASCII character to a keycode.
395 */ 400 */
396__attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = { 401__attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
@@ -531,6 +536,7 @@ void send_char(char ascii_code) {
531 uint8_t keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]); 536 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); 537 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); 538 bool is_altgred = PGM_LOADBIT(ascii_to_altgr_lut, (uint8_t)ascii_code);
539 bool is_dead = PGM_LOADBIT(ascii_to_dead_lut, (uint8_t)ascii_code);
534 540
535 if (is_shifted) { 541 if (is_shifted) {
536 register_code(KC_LSFT); 542 register_code(KC_LSFT);
@@ -545,6 +551,9 @@ void send_char(char ascii_code) {
545 if (is_shifted) { 551 if (is_shifted) {
546 unregister_code(KC_LSFT); 552 unregister_code(KC_LSFT);
547 } 553 }
554 if (is_dead) {
555 tap_code(KC_SPACE);
556 }
548} 557}
549 558
550void set_single_persistent_default_layer(uint8_t default_layer) { 559void set_single_persistent_default_layer(uint8_t default_layer) {
@@ -612,9 +621,6 @@ void matrix_init_quantum() {
612#ifdef AUDIO_ENABLE 621#ifdef AUDIO_ENABLE
613 audio_init(); 622 audio_init();
614#endif 623#endif
615#ifdef RGB_MATRIX_ENABLE
616 rgb_matrix_init();
617#endif
618#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) 624#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
619 unicode_input_mode_init(); 625 unicode_input_mode_init();
620#endif 626#endif
@@ -629,6 +635,26 @@ void matrix_init_quantum() {
629} 635}
630 636
631void matrix_scan_quantum() { 637void matrix_scan_quantum() {
638#if defined(AUDIO_ENABLE)
639 // There are some tasks that need to be run a little bit
640 // after keyboard startup, or else they will not work correctly
641 // because of interaction with the USB device state, which
642 // may still be in flux...
643 //
644 // At the moment the only feature that needs this is the
645 // startup song.
646 static bool delayed_tasks_run = false;
647 static uint16_t delayed_task_timer = 0;
648 if (!delayed_tasks_run) {
649 if (!delayed_task_timer) {
650 delayed_task_timer = timer_read();
651 } else if (timer_elapsed(delayed_task_timer) > 300) {
652 audio_startup();
653 delayed_tasks_run = true;
654 }
655 }
656#endif
657
632#if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) 658#if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
633 matrix_scan_music(); 659 matrix_scan_music();
634#endif 660#endif
@@ -649,10 +675,6 @@ void matrix_scan_quantum() {
649 led_matrix_task(); 675 led_matrix_task();
650#endif 676#endif
651 677
652#ifdef RGB_MATRIX_ENABLE
653 rgb_matrix_task();
654#endif
655
656#ifdef WPM_ENABLE 678#ifdef WPM_ENABLE
657 decay_wpm(); 679 decay_wpm();
658#endif 680#endif