summaryrefslogtreecommitdiffstats
path: root/quantum/quantum.c
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-09-12 00:43:10 -0400
committerGitHub <noreply@github.com>2017-09-12 00:43:10 -0400
commit7ad924bae5519e981c57495e481db62741aa4376 (patch)
treee07575ee363f68b70579cda8e54eebcbd55d4127 /quantum/quantum.c
parenta4ff8b91f74df9fb1d87f52c0ded23935344d2eb (diff)
Updates send_string functionality, adds terminal feature (#1657)
* implement basic terminal stuff * modify send_string to read normal strings too * add files bc yeah. working pgm detected * pgm detection apparently not working * adds send string keycodes, additional keycode support in send string * implement arguments * [terminal] add help command * [terminal] adds keycode and keymap functions * [terminal] adds nop.h, documentation * update macro docs
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]);