From 3ecb0a80af9e4ce4194a34032642933641730706 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 2 Jul 2022 22:10:08 +1000 Subject: Feature-ify Send String (#17275) --- docs/feature_macros.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs/feature_macros.md') diff --git a/docs/feature_macros.md b/docs/feature_macros.md index 78bc4ba0a5..f5b163d5df 100644 --- a/docs/feature_macros.md +++ b/docs/feature_macros.md @@ -106,6 +106,8 @@ Only basic keycodes (prefixed by `KC_`) are supported. Do not include the `KC_` ### `SEND_STRING()` & `process_record_user` +See also: [Send String](feature_send_string.md) + Sometimes you want a key to type out words or phrases. For the most common situations, we've provided `SEND_STRING()`, which will type out a string (i.e. a sequence of characters) for you. All ASCII characters that are easily translatable to a keycode are supported (e.g. `qmk 123\n\t`). Here is an example `keymap.c` for a two-key keyboard: -- cgit v1.2.3 From d02cefe613f5ba252c6917c7b0fc6b5b87993062 Mon Sep 17 00:00:00 2001 From: JayceFayne <13365789+JayceFayne@users.noreply.github.com> Date: Sat, 23 Jul 2022 20:21:20 +0200 Subject: implement `tap_code16_delay` (#17748) --- docs/feature_macros.md | 2 +- quantum/quantum.c | 21 ++++++++++++++++----- quantum/quantum.h | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'docs/feature_macros.md') diff --git a/docs/feature_macros.md b/docs/feature_macros.md index f5b163d5df..f5bd5be41b 100644 --- a/docs/feature_macros.md +++ b/docs/feature_macros.md @@ -349,7 +349,7 @@ If the keycode is `KC_CAPS`, it waits `TAP_HOLD_CAPS_DELAY` milliseconds instead Like `tap_code()`, but with a `delay` parameter for specifying arbitrary intervals before sending the unregister event. -#### `register_code16();`, `unregister_code16();` and `tap_code16();` +#### `register_code16();`, `unregister_code16();`, `tap_code16();` and `tap_code16_delay(, );` These functions work similar to their regular counterparts, but allow you to use modded keycodes (with Shift, Alt, Control, and/or GUI applied to them). diff --git a/quantum/quantum.c b/quantum/quantum.c index 0d5f398585..80fa1a3ced 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -93,16 +93,27 @@ __attribute__((weak)) void unregister_code16(uint16_t code) { } } -__attribute__((weak)) void tap_code16(uint16_t code) { +/** \brief Tap a keycode with a delay. + * + * \param code The modded keycode to tap. + * \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it. + */ +__attribute__((weak)) void tap_code16_delay(uint16_t code, uint16_t delay) { register_code16(code); - if (code == KC_CAPS_LOCK) { - wait_ms(TAP_HOLD_CAPS_DELAY); - } else if (TAP_CODE_DELAY > 0) { - wait_ms(TAP_CODE_DELAY); + for (uint16_t i = delay; i > 0; i--) { + wait_ms(1); } unregister_code16(code); } +/** \brief Tap a keycode with the default delay. + * + * \param code The modded keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined. + */ +__attribute__((weak)) void tap_code16(uint16_t code) { + tap_code16_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY); +} + __attribute__((weak)) bool process_action_kb(keyrecord_t *record) { return true; } diff --git a/quantum/quantum.h b/quantum/quantum.h index f3a8a323c7..8d74f2be38 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -264,6 +264,7 @@ void shutdown_user(void); void register_code16(uint16_t code); void unregister_code16(uint16_t code); void tap_code16(uint16_t code); +void tap_code16_delay(uint16_t code, uint16_t delay); const char *get_numeric_str(char *buf, size_t buf_len, uint32_t curr_num, char curr_pad); const char *get_u8_str(uint8_t curr_num, char curr_pad); -- cgit v1.2.3