aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r--quantum/quantum.c62
1 files changed, 47 insertions, 15 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index cf16e953a..6d202c515 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
@@ -310,17 +306,6 @@ bool process_record_quantum(keyrecord_t *record) {
310 case EEPROM_RESET: 306 case EEPROM_RESET:
311 eeconfig_init(); 307 eeconfig_init();
312 return false; 308 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 309#ifdef VELOCIKEY_ENABLE
325 case VLK_TOG: 310 case VLK_TOG:
326 velocikey_toggle(); 311 velocikey_toggle();
@@ -391,6 +376,29 @@ __attribute__((weak)) const uint8_t ascii_to_altgr_lut[16] PROGMEM = {
391 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0), 376 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
392}; 377};
393 378
379/* Bit-Packed look-up table to convert an ASCII character to whether
380 * [Space] needs to be sent after the keycode
381 */
382__attribute__((weak)) const uint8_t ascii_to_dead_lut[16] PROGMEM = {
383 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
384 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
385 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
386 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
387
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 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
398 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
399 KCLUT_ENTRY(0, 0, 0, 0, 0, 0, 0, 0),
400};
401
394/* Look-up table to convert an ASCII character to a keycode. 402/* Look-up table to convert an ASCII character to a keycode.
395 */ 403 */
396__attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = { 404__attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
@@ -531,6 +539,7 @@ void send_char(char ascii_code) {
531 uint8_t keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]); 539 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); 540 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); 541 bool is_altgred = PGM_LOADBIT(ascii_to_altgr_lut, (uint8_t)ascii_code);
542 bool is_dead = PGM_LOADBIT(ascii_to_dead_lut, (uint8_t)ascii_code);
534 543
535 if (is_shifted) { 544 if (is_shifted) {
536 register_code(KC_LSFT); 545 register_code(KC_LSFT);
@@ -545,6 +554,9 @@ void send_char(char ascii_code) {
545 if (is_shifted) { 554 if (is_shifted) {
546 unregister_code(KC_LSFT); 555 unregister_code(KC_LSFT);
547 } 556 }
557 if (is_dead) {
558 tap_code(KC_SPACE);
559 }
548} 560}
549 561
550void set_single_persistent_default_layer(uint8_t default_layer) { 562void set_single_persistent_default_layer(uint8_t default_layer) {
@@ -629,6 +641,26 @@ void matrix_init_quantum() {
629} 641}
630 642
631void matrix_scan_quantum() { 643void matrix_scan_quantum() {
644#if defined(AUDIO_ENABLE)
645 // There are some tasks that need to be run a little bit
646 // after keyboard startup, or else they will not work correctly
647 // because of interaction with the USB device state, which
648 // may still be in flux...
649 //
650 // At the moment the only feature that needs this is the
651 // startup song.
652 static bool delayed_tasks_run = false;
653 static uint16_t delayed_task_timer = 0;
654 if (!delayed_tasks_run) {
655 if (!delayed_task_timer) {
656 delayed_task_timer = timer_read();
657 } else if (timer_elapsed(delayed_task_timer) > 300) {
658 audio_startup();
659 delayed_tasks_run = true;
660 }
661 }
662#endif
663
632#if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE) 664#if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
633 matrix_scan_music(); 665 matrix_scan_music();
634#endif 666#endif