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 | |
| parent | 3a0f11a66178116ee935dd5b58332962666de5f2 (diff) | |
Insert delay between shifted chars in send_string_with_delay (#19280)
Diffstat (limited to 'quantum/send_string')
| -rw-r--r-- | quantum/send_string/send_string.c | 36 | ||||
| -rw-r--r-- | quantum/send_string/send_string.h | 14 |
2 files changed, 37 insertions, 13 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 | ||
diff --git a/quantum/send_string/send_string.h b/quantum/send_string/send_string.h index dbaed43ebc..f727ec507d 100644 --- a/quantum/send_string/send_string.h +++ b/quantum/send_string/send_string.h | |||
| @@ -49,7 +49,7 @@ extern const uint8_t ascii_to_keycode_lut[128]; | |||
| 49 | /** | 49 | /** |
| 50 | * \brief Type out a string of ASCII characters. | 50 | * \brief Type out a string of ASCII characters. |
| 51 | * | 51 | * |
| 52 | * This function simply calls `send_string_with_delay(string, 0)`. | 52 | * This function simply calls `send_string_with_delay(string, TAP_CODE_DELAY)`. |
| 53 | * | 53 | * |
| 54 | * Most keycodes from the basic keycode range are also supported by way of a special sequence - see `send_string_keycodes.h`. | 54 | * Most keycodes from the basic keycode range are also supported by way of a special sequence - see `send_string_keycodes.h`. |
| 55 | * | 55 | * |
| @@ -61,18 +61,28 @@ void send_string(const char *string); | |||
| 61 | * \brief Type out a string of ASCII characters, with a delay between each character. | 61 | * \brief Type out a string of ASCII characters, with a delay between each character. |
| 62 | * | 62 | * |
| 63 | * \param string The string to type out. | 63 | * \param string The string to type out. |
| 64 | * \param interval The amount of time, in milliseconds, to wait before typing the next character. | 64 | * \param interval The amount of time, in milliseconds, to wait before typing the next character. Note this can be set to 0 to ensure no delay, regardless of what TAP_CODE_DELAY is set to. |
| 65 | */ | 65 | */ |
| 66 | void send_string_with_delay(const char *string, uint8_t interval); | 66 | void send_string_with_delay(const char *string, uint8_t interval); |
| 67 | 67 | ||
| 68 | /** | 68 | /** |
| 69 | * \brief Type out an ASCII character. | 69 | * \brief Type out an ASCII character. |
| 70 | * | 70 | * |
| 71 | * This function simply calls `send_char_with_delay(string, TAP_CODE_DELAY)`. | ||
| 72 | * | ||
| 71 | * \param ascii_code The character to type. | 73 | * \param ascii_code The character to type. |
| 72 | */ | 74 | */ |
| 73 | void send_char(char ascii_code); | 75 | void send_char(char ascii_code); |
| 74 | 76 | ||
| 75 | /** | 77 | /** |
| 78 | * \brief Type out an ASCII character, with a delay between any modifiers. | ||
| 79 | * | ||
| 80 | * \param ascii_code The character to type. | ||
| 81 | * \param interval The amount of time, in milliseconds, to wait in between key presses. Note this can be set to 0 to ensure no delay, regardless of what TAP_CODE_DELAY is set to. | ||
| 82 | */ | ||
| 83 | void send_char_with_delay(char ascii_code, uint8_t interval); | ||
| 84 | |||
| 85 | /** | ||
| 76 | * \brief Type out an eight digit (unsigned 32-bit) hexadecimal value. | 86 | * \brief Type out an eight digit (unsigned 32-bit) hexadecimal value. |
| 77 | * | 87 | * |
| 78 | * The format is `[0-9a-f]{8}`, eg. `00000000` through `ffffffff`. | 88 | * The format is `[0-9a-f]{8}`, eg. `00000000` through `ffffffff`. |
