diff options
| author | Skyler Hawthorne <skyler@dead10ck.dev> | 2024-02-16 09:01:01 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-17 01:01:01 +1100 |
| commit | 13434fc066ef0b213587f773cc05f1c5b7d31113 (patch) | |
| tree | fdbab73b331a821ddd795c4c4cbe9d46f9ea1227 /quantum/send_string/send_string.c | |
| parent | 3a0f11a66178116ee935dd5b58332962666de5f2 (diff) | |
Insert delay between shifted chars in send_string_with_delay (#19280)
Diffstat (limited to 'quantum/send_string/send_string.c')
| -rw-r--r-- | quantum/send_string/send_string.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/quantum/send_string/send_string.c b/quantum/send_string/send_string.c index 820fc25163..8b59c19219 100644 --- a/quantum/send_string/send_string.c +++ b/quantum/send_string/send_string.c | |||
| @@ -147,7 +147,7 @@ __attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = { | |||
| 147 | #define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01) | 147 | #define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01) |
| 148 | 148 | ||
| 149 | void send_string(const char *string) { | 149 | void send_string(const char *string) { |
| 150 | send_string_with_delay(string, 0); | 150 | send_string_with_delay(string, TAP_CODE_DELAY); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | void send_string_with_delay(const char *string, uint8_t interval) { | 153 | void send_string_with_delay(const char *string, uint8_t interval) { |
| @@ -156,6 +156,7 @@ void send_string_with_delay(const char *string, uint8_t interval) { | |||
| 156 | if (!ascii_code) break; | 156 | if (!ascii_code) break; |
| 157 | if (ascii_code == SS_QMK_PREFIX) { | 157 | if (ascii_code == SS_QMK_PREFIX) { |
| 158 | ascii_code = *(++string); | 158 | ascii_code = *(++string); |
| 159 | |||
| 159 | if (ascii_code == SS_TAP_CODE) { | 160 | if (ascii_code == SS_TAP_CODE) { |
| 160 | // tap | 161 | // tap |
| 161 | uint8_t keycode = *(++string); | 162 | uint8_t keycode = *(++string); |
| @@ -172,28 +173,30 @@ void send_string_with_delay(const char *string, uint8_t interval) { | |||
| 172 | // delay | 173 | // delay |
| 173 | int ms = 0; | 174 | int ms = 0; |
| 174 | uint8_t keycode = *(++string); | 175 | uint8_t keycode = *(++string); |
| 176 | |||
| 175 | while (isdigit(keycode)) { | 177 | while (isdigit(keycode)) { |
| 176 | ms *= 10; | 178 | ms *= 10; |
| 177 | ms += keycode - '0'; | 179 | ms += keycode - '0'; |
| 178 | keycode = *(++string); | 180 | keycode = *(++string); |
| 179 | } | 181 | } |
| 180 | while (ms--) | 182 | |
| 181 | wait_ms(1); | 183 | wait_ms(ms); |
| 182 | } | 184 | } |
| 185 | |||
| 186 | wait_ms(interval); | ||
| 183 | } else { | 187 | } else { |
| 184 | send_char(ascii_code); | 188 | send_char_with_delay(ascii_code, interval); |
| 185 | } | 189 | } |
| 190 | |||
| 186 | ++string; | 191 | ++string; |
| 187 | // interval | ||
| 188 | { | ||
| 189 | uint8_t ms = interval; | ||
| 190 | while (ms--) | ||
| 191 | wait_ms(1); | ||
| 192 | } | ||
| 193 | } | 192 | } |
| 194 | } | 193 | } |
| 195 | 194 | ||
| 196 | void send_char(char ascii_code) { | 195 | void send_char(char ascii_code) { |
| 196 | send_char_with_delay(ascii_code, TAP_CODE_DELAY); | ||
| 197 | } | ||
| 198 | |||
| 199 | void send_char_with_delay(char ascii_code, uint8_t interval) { | ||
| 197 | #if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL) | 200 | #if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL) |
| 198 | if (ascii_code == '\a') { // BEL | 201 | if (ascii_code == '\a') { // BEL |
| 199 | PLAY_SONG(bell_song); | 202 | PLAY_SONG(bell_song); |
| @@ -208,19 +211,30 @@ void send_char(char ascii_code) { | |||
| 208 | 211 | ||
| 209 | if (is_shifted) { | 212 | if (is_shifted) { |
| 210 | register_code(KC_LEFT_SHIFT); | 213 | register_code(KC_LEFT_SHIFT); |
| 214 | wait_ms(interval); | ||
| 211 | } | 215 | } |
| 216 | |||
| 212 | if (is_altgred) { | 217 | if (is_altgred) { |
| 213 | register_code(KC_RIGHT_ALT); | 218 | register_code(KC_RIGHT_ALT); |
| 219 | wait_ms(interval); | ||
| 214 | } | 220 | } |
| 215 | tap_code(keycode); | 221 | |
| 222 | tap_code_delay(keycode, interval); | ||
| 223 | wait_ms(interval); | ||
| 224 | |||
| 216 | if (is_altgred) { | 225 | if (is_altgred) { |
| 217 | unregister_code(KC_RIGHT_ALT); | 226 | unregister_code(KC_RIGHT_ALT); |
| 227 | wait_ms(interval); | ||
| 218 | } | 228 | } |
| 229 | |||
| 219 | if (is_shifted) { | 230 | if (is_shifted) { |
| 220 | unregister_code(KC_LEFT_SHIFT); | 231 | unregister_code(KC_LEFT_SHIFT); |
| 232 | wait_ms(interval); | ||
| 221 | } | 233 | } |
| 234 | |||
| 222 | if (is_dead) { | 235 | if (is_dead) { |
| 223 | tap_code(KC_SPACE); | 236 | tap_code(KC_SPACE); |
| 237 | wait_ms(interval); | ||
| 224 | } | 238 | } |
| 225 | } | 239 | } |
| 226 | 240 | ||
