]> git.donarmstrong.com Git - qmk_firmware.git/blob - users/d4mation/tap-hold.c
[Keymap] Added userspace for d4mation. Included their keymap for the Atreus62 (#7483)
[qmk_firmware.git] / users / d4mation / tap-hold.c
1 #include "tap-hold.h"
2
3 #ifndef TAP_HOLD_TIME
4 #define TAP_HOLD_TIME 200
5 #endif
6
7 uint16_t tap_hold_timer;
8
9 void tap_or_hold( keyrecord_t *record, uint16_t tap, uint16_t hold ) {
10
11   if ( record->event.pressed ) {
12     tap_hold_timer = timer_read();
13   } else {
14
15     if ( tap_hold_timer &&
16       timer_elapsed( tap_hold_timer ) > TAP_HOLD_TIME ) {
17       /* Held down then released */
18       tap_code( hold );
19     } else {
20       /* Quickly Tapped */
21       tap_code( tap );
22     }
23
24     tap_hold_timer = 0;
25
26   }
27
28 }