summaryrefslogtreecommitdiffstats
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 285e1e81ee..1fccaa7d5a 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -238,6 +238,9 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef UNICODEMAP_ENABLE
process_unicode_map(keycode, record) &&
#endif
+ #ifdef TERMINAL_ENABLE
+ process_terminal(keycode, record) &&
+ #endif
true)) {
return false;
}
@@ -600,21 +603,55 @@ void send_string(const char *str) {
send_string_with_delay(str, 0);
}
+void send_string_P(const char *str) {
+ send_string_with_delay_P(str, 0);
+}
+
void send_string_with_delay(const char *str, uint8_t interval) {
while (1) {
- uint8_t keycode;
- uint8_t ascii_code = pgm_read_byte(str);
+ char ascii_code = *str;
if (!ascii_code) break;
- keycode = pgm_read_byte(&ascii_to_keycode_lut[ascii_code]);
- if (pgm_read_byte(&ascii_to_shift_lut[ascii_code])) {
- register_code(KC_LSFT);
- register_code(keycode);
- unregister_code(keycode);
- unregister_code(KC_LSFT);
+ if (ascii_code == 1) {
+ // tap
+ uint8_t keycode = *(++str);
+ register_code(keycode);
+ unregister_code(keycode);
+ } else if (ascii_code == 2) {
+ // down
+ uint8_t keycode = *(++str);
+ register_code(keycode);
+ } else if (ascii_code == 3) {
+ // up
+ uint8_t keycode = *(++str);
+ unregister_code(keycode);
+ } else {
+ send_char(ascii_code);
}
- else {
- register_code(keycode);
- unregister_code(keycode);
+ ++str;
+ // interval
+ { uint8_t ms = interval; while (ms--) wait_ms(1); }
+ }
+}
+
+void send_string_with_delay_P(const char *str, uint8_t interval) {
+ while (1) {
+ char ascii_code = pgm_read_byte(str);
+ if (!ascii_code) break;
+ if (ascii_code == 1) {
+ // tap
+ uint8_t keycode = pgm_read_byte(++str);
+ register_code(keycode);
+ unregister_code(keycode);
+ } else if (ascii_code == 2) {
+ // down
+ uint8_t keycode = pgm_read_byte(++str);
+ register_code(keycode);
+ } else if (ascii_code == 3) {
+ // up
+ uint8_t keycode = pgm_read_byte(++str);
+ unregister_code(keycode);
+ } else {
+ send_char(ascii_code);
}
++str;
// interval
@@ -622,6 +659,20 @@ void send_string_with_delay(const char *str, uint8_t interval) {
}
}
+void send_char(char ascii_code) {
+ uint8_t keycode;
+ keycode = pgm_read_byte(&ascii_to_keycode_lut[(uint8_t)ascii_code]);
+ if (pgm_read_byte(&ascii_to_shift_lut[(uint8_t)ascii_code])) {
+ register_code(KC_LSFT);
+ register_code(keycode);
+ unregister_code(keycode);
+ unregister_code(KC_LSFT);
+ } else {
+ register_code(keycode);
+ unregister_code(keycode);
+ }
+}
+
void set_single_persistent_default_layer(uint8_t default_layer) {
#if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
PLAY_SONG(default_layer_songs[default_layer]);