Insert delay between shifted chars in send_string_with_delay (#19280)
This commit is contained in:
parent
3a0f11a661
commit
13434fc066
3 changed files with 38 additions and 16 deletions
|
@ -1011,9 +1011,7 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
|
||||||
*/
|
*/
|
||||||
__attribute__((weak)) void tap_code_delay(uint8_t code, uint16_t delay) {
|
__attribute__((weak)) void tap_code_delay(uint8_t code, uint16_t delay) {
|
||||||
register_code(code);
|
register_code(code);
|
||||||
for (uint16_t i = delay; i > 0; i--) {
|
wait_ms(delay);
|
||||||
wait_ms(1);
|
|
||||||
}
|
|
||||||
unregister_code(code);
|
unregister_code(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ __attribute__((weak)) const uint8_t ascii_to_keycode_lut[128] PROGMEM = {
|
||||||
#define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01)
|
#define PGM_LOADBIT(mem, pos) ((pgm_read_byte(&((mem)[(pos) / 8])) >> ((pos) % 8)) & 0x01)
|
||||||
|
|
||||||
void send_string(const char *string) {
|
void send_string(const char *string) {
|
||||||
send_string_with_delay(string, 0);
|
send_string_with_delay(string, TAP_CODE_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_string_with_delay(const char *string, uint8_t interval) {
|
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) {
|
||||||
if (!ascii_code) break;
|
if (!ascii_code) break;
|
||||||
if (ascii_code == SS_QMK_PREFIX) {
|
if (ascii_code == SS_QMK_PREFIX) {
|
||||||
ascii_code = *(++string);
|
ascii_code = *(++string);
|
||||||
|
|
||||||
if (ascii_code == SS_TAP_CODE) {
|
if (ascii_code == SS_TAP_CODE) {
|
||||||
// tap
|
// tap
|
||||||
uint8_t keycode = *(++string);
|
uint8_t keycode = *(++string);
|
||||||
|
@ -172,28 +173,30 @@ void send_string_with_delay(const char *string, uint8_t interval) {
|
||||||
// delay
|
// delay
|
||||||
int ms = 0;
|
int ms = 0;
|
||||||
uint8_t keycode = *(++string);
|
uint8_t keycode = *(++string);
|
||||||
|
|
||||||
while (isdigit(keycode)) {
|
while (isdigit(keycode)) {
|
||||||
ms *= 10;
|
ms *= 10;
|
||||||
ms += keycode - '0';
|
ms += keycode - '0';
|
||||||
keycode = *(++string);
|
keycode = *(++string);
|
||||||
}
|
}
|
||||||
while (ms--)
|
|
||||||
wait_ms(1);
|
wait_ms(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait_ms(interval);
|
||||||
} else {
|
} else {
|
||||||
send_char(ascii_code);
|
send_char_with_delay(ascii_code, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
++string;
|
++string;
|
||||||
// interval
|
|
||||||
{
|
|
||||||
uint8_t ms = interval;
|
|
||||||
while (ms--)
|
|
||||||
wait_ms(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_char(char ascii_code) {
|
void send_char(char ascii_code) {
|
||||||
|
send_char_with_delay(ascii_code, TAP_CODE_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void send_char_with_delay(char ascii_code, uint8_t interval) {
|
||||||
#if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL)
|
#if defined(AUDIO_ENABLE) && defined(SENDSTRING_BELL)
|
||||||
if (ascii_code == '\a') { // BEL
|
if (ascii_code == '\a') { // BEL
|
||||||
PLAY_SONG(bell_song);
|
PLAY_SONG(bell_song);
|
||||||
|
@ -208,19 +211,30 @@ void send_char(char ascii_code) {
|
||||||
|
|
||||||
if (is_shifted) {
|
if (is_shifted) {
|
||||||
register_code(KC_LEFT_SHIFT);
|
register_code(KC_LEFT_SHIFT);
|
||||||
|
wait_ms(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_altgred) {
|
if (is_altgred) {
|
||||||
register_code(KC_RIGHT_ALT);
|
register_code(KC_RIGHT_ALT);
|
||||||
|
wait_ms(interval);
|
||||||
}
|
}
|
||||||
tap_code(keycode);
|
|
||||||
|
tap_code_delay(keycode, interval);
|
||||||
|
wait_ms(interval);
|
||||||
|
|
||||||
if (is_altgred) {
|
if (is_altgred) {
|
||||||
unregister_code(KC_RIGHT_ALT);
|
unregister_code(KC_RIGHT_ALT);
|
||||||
|
wait_ms(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_shifted) {
|
if (is_shifted) {
|
||||||
unregister_code(KC_LEFT_SHIFT);
|
unregister_code(KC_LEFT_SHIFT);
|
||||||
|
wait_ms(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_dead) {
|
if (is_dead) {
|
||||||
tap_code(KC_SPACE);
|
tap_code(KC_SPACE);
|
||||||
|
wait_ms(interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ extern const uint8_t ascii_to_keycode_lut[128];
|
||||||
/**
|
/**
|
||||||
* \brief Type out a string of ASCII characters.
|
* \brief Type out a string of ASCII characters.
|
||||||
*
|
*
|
||||||
* This function simply calls `send_string_with_delay(string, 0)`.
|
* This function simply calls `send_string_with_delay(string, TAP_CODE_DELAY)`.
|
||||||
*
|
*
|
||||||
* Most keycodes from the basic keycode range are also supported by way of a special sequence - see `send_string_keycodes.h`.
|
* Most keycodes from the basic keycode range are also supported by way of a special sequence - see `send_string_keycodes.h`.
|
||||||
*
|
*
|
||||||
|
@ -61,17 +61,27 @@ void send_string(const char *string);
|
||||||
* \brief Type out a string of ASCII characters, with a delay between each character.
|
* \brief Type out a string of ASCII characters, with a delay between each character.
|
||||||
*
|
*
|
||||||
* \param string The string to type out.
|
* \param string The string to type out.
|
||||||
* \param interval The amount of time, in milliseconds, to wait before typing the next character.
|
* \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.
|
||||||
*/
|
*/
|
||||||
void send_string_with_delay(const char *string, uint8_t interval);
|
void send_string_with_delay(const char *string, uint8_t interval);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Type out an ASCII character.
|
* \brief Type out an ASCII character.
|
||||||
*
|
*
|
||||||
|
* This function simply calls `send_char_with_delay(string, TAP_CODE_DELAY)`.
|
||||||
|
*
|
||||||
* \param ascii_code The character to type.
|
* \param ascii_code The character to type.
|
||||||
*/
|
*/
|
||||||
void send_char(char ascii_code);
|
void send_char(char ascii_code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Type out an ASCII character, with a delay between any modifiers.
|
||||||
|
*
|
||||||
|
* \param ascii_code The character to type.
|
||||||
|
* \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.
|
||||||
|
*/
|
||||||
|
void send_char_with_delay(char ascii_code, uint8_t interval);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Type out an eight digit (unsigned 32-bit) hexadecimal value.
|
* \brief Type out an eight digit (unsigned 32-bit) hexadecimal value.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue