aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2021-02-17 07:26:52 +1100
committerGitHub <noreply@github.com>2021-02-17 07:26:52 +1100
commit3345ce268610edbca8f53bc2909c547485531603 (patch)
tree9d984734f8aa5f2aa964e0151ab48eee936ef34b /tmk_core
parentcdb9d55956c67e1e2a9209522c1a2b30a7d9fb67 (diff)
downloadqmk_firmware-3345ce268610edbca8f53bc2909c547485531603.tar.gz
qmk_firmware-3345ce268610edbca8f53bc2909c547485531603.zip
Add `tap_code_delay(code, delay)` (#11913)
Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common/action.c21
-rw-r--r--tmk_core/common/action.h1
2 files changed, 14 insertions, 8 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index e4a97e0bc..74bfc0626 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -940,20 +940,25 @@ void unregister_code(uint8_t code) {
940#endif 940#endif
941} 941}
942 942
943/** \brief Utilities for actions. (FIXME: Needs better description) 943/** \brief Tap a keycode with a delay.
944 * 944 *
945 * FIXME: Needs documentation. 945 * \param code The basic keycode to tap.
946 * \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it.
946 */ 947 */
947void tap_code(uint8_t code) { 948void tap_code_delay(uint8_t code, uint16_t delay) {
948 register_code(code); 949 register_code(code);
949 if (code == KC_CAPS) { 950 wait_ms(delay);
950 wait_ms(TAP_HOLD_CAPS_DELAY);
951 } else {
952 wait_ms(TAP_CODE_DELAY);
953 }
954 unregister_code(code); 951 unregister_code(code);
955} 952}
956 953
954/** \brief Tap a keycode with the default delay.
955 *
956 * \param code The basic keycode to tap. If `code` is `KC_CAPS`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined.
957 */
958void tap_code(uint8_t code) {
959 tap_code_delay(code, code == KC_CAPS ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY);
960}
961
957/** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately. 962/** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately.
958 * 963 *
959 * \param mods A bitfield of modifiers to register. 964 * \param mods A bitfield of modifiers to register.
diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h
index 81cd54369..9a991de1c 100644
--- a/tmk_core/common/action.h
+++ b/tmk_core/common/action.h
@@ -100,6 +100,7 @@ void process_action(keyrecord_t *record, action_t action);
100void register_code(uint8_t code); 100void register_code(uint8_t code);
101void unregister_code(uint8_t code); 101void unregister_code(uint8_t code);
102void tap_code(uint8_t code); 102void tap_code(uint8_t code);
103void tap_code_delay(uint8_t code, uint16_t delay);
103void register_mods(uint8_t mods); 104void register_mods(uint8_t mods);
104void unregister_mods(uint8_t mods); 105void unregister_mods(uint8_t mods);
105void register_weak_mods(uint8_t mods); 106void register_weak_mods(uint8_t mods);