diff options
Diffstat (limited to 'tmk_core/common/action.c')
| -rw-r--r-- | tmk_core/common/action.c | 21 |
1 files changed, 13 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 | */ |
| 947 | void tap_code(uint8_t code) { | 948 | void 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 | */ | ||
| 958 | void 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. |
