implement tap_code16_delay
(#17748)
This commit is contained in:
parent
a6f3194397
commit
d02cefe613
3 changed files with 18 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue