summaryrefslogtreecommitdiff
path: root/tmk_core/common
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common')
-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 e4a97e0bc1..74bfc06264 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -940,20 +940,25 @@ void unregister_code(uint8_t code) {
#endif
}
-/** \brief Utilities for actions. (FIXME: Needs better description)
+/** \brief Tap a keycode with a delay.
*
- * FIXME: Needs documentation.
+ * \param code The basic keycode to tap.
+ * \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it.
*/
-void tap_code(uint8_t code) {
+void tap_code_delay(uint8_t code, uint16_t delay) {
register_code(code);
- if (code == KC_CAPS) {
- wait_ms(TAP_HOLD_CAPS_DELAY);
- } else {
- wait_ms(TAP_CODE_DELAY);
- }
+ wait_ms(delay);
unregister_code(code);
}
+/** \brief Tap a keycode with the default delay.
+ *
+ * \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.
+ */
+void tap_code(uint8_t code) {
+ tap_code_delay(code, code == KC_CAPS ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY);
+}
+
/** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately.
*
* \param mods A bitfield of modifiers to register.
diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h
index 81cd54369c..9a991de1c2 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);
void register_code(uint8_t code);
void unregister_code(uint8_t code);
void tap_code(uint8_t code);
+void tap_code_delay(uint8_t code, uint16_t delay);
void register_mods(uint8_t mods);
void unregister_mods(uint8_t mods);
void register_weak_mods(uint8_t mods);