aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/quantum.c')
-rw-r--r--quantum/quantum.c73
1 files changed, 62 insertions, 11 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 285e1e81e..1fccaa7d5 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -238,6 +238,9 @@ bool process_record_quantum(keyrecord_t *record) {
238 #ifdef UNICODEMAP_ENABLE 238 #ifdef UNICODEMAP_ENABLE
239 process_unicode_map(keycode, record) && 239 process_unicode_map(keycode, record) &&
240 #endif 240 #endif
241 #ifdef TERMINAL_ENABLE
242 process_terminal(keycode, record) &&
243 #endif
241 true)) { 244 true)) {
242 return false; 245 return false;
243 } 246 }
@@ -600,21 +603,55 @@ void send_string(const char *str) {
600 send_string_with_delay(str, 0); 603 send_string_with_delay(str, 0);
601} 604}
602 605
606void send_string_P(const char *str) {
607 send_string_with_delay_P(str, 0);
608}
609
603void send_string_with_delay(const char *str, uint8_t interval) { 610void send_string_with_delay(const char *str, uint8_t interval) {
604 while (1) { 611 while (1) {
605 uint8_t keycode; 612 char ascii_code = *str;
606 uint8_t ascii_code = pgm_read_byte(str);
607 if (!ascii_code) break; 613 if (!ascii_code) break;
608 keycode = pgm_read_byte(&ascii_to_keycode_lut[ascii_code]); 614 if (ascii_code == 1) {
609 if (pgm_read_byte(&ascii_to_shift_lut[ascii_code])) { 615 // tap
610 register_code(KC_LSFT); 616 uint8_t keycode = *(++str);
611 register_code(keycode); 617 register_code(keycode);
612 unregister_code(keycode); 618 unregister_code(keycode);
613 unregister_code(KC_LSFT); 619 } else if (ascii_code == 2) {
620 // down
621 uint8_t keycode = *(++str);
622 register_code(keycode);
623 } else if (ascii_code == 3) {
624 // up
625 uint8_t keycode = *(++str);
626 unregister_code(keycode);
627 } else {
628 send_char(ascii_code);
614 } 629 }
615 else { 630 ++str;
616 register_code(keycode); 631 // interval
617 unregister_code(keycode); 632 { uint8_t ms = interval; while (ms--) wait_ms(1); }
633 }
634}
635
636void send_string_with_delay_P(const char *str, uint8_t interval) {
637 while (1) {
638 char ascii_code = pgm_read_byte(str);
639 if (!ascii_code) break;
640 if (ascii_code == 1) {
641 // tap
642 uint8_t keycode = pgm_read_byte(++str);
643 register_code(keycode);
644 unregister_code(keycode);
645 } else if (ascii_code == 2) {
646 // down
647 uint8_t keycode = pgm_read_byte(++str);
648 register_code(keycode);
649 } else if (ascii_code == 3) {
650 // up
651 uint8_t keycode = pgm_read_byte(++str);
652 unregister_code(keycode);
653 } else {
654 send_char(ascii_code);
618 } 655 }
619 ++str; 656 ++str;
620 // interval 657 // interval
@@ -622,6 +659,20 @@ void send_string_with_delay(const char *str, uint8_t interval) {
622 } 659 }
623} 660}
624 661
662void send_char(char ascii_code) {
663 uint8_t keycode;
664 keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]);
665 if (pgm_read_byte(&ascii_to_shift_lut[(uint8_t)ascii_code])) {
666 register_code(KC_LSFT);
667 register_code(keycode);
668 unregister_code(keycode);
669 unregister_code(KC_LSFT);
670 } else {
671 register_code(keycode);
672 unregister_code(keycode);
673 }
674}
675
625void set_single_persistent_default_layer(uint8_t default_layer) { 676void set_single_persistent_default_layer(uint8_t default_layer) {
626 #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS) 677 #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
627 PLAY_SONG(default_layer_songs[default_layer]); 678 PLAY_SONG(default_layer_songs[default_layer]);