~ruther/qmk_firmware

ref: 4601f339e48b0116ca139dd06ce55ef0b9ed598f qmk_firmware/users/d4mation/tap-hold.c -rw-r--r-- 503 bytes
4601f339 — Ryan V-USB: implement NKRO (#22398) 1 year, 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "tap-hold.h"

#ifndef TAP_HOLD_TIME
#define TAP_HOLD_TIME 200
#endif

uint16_t tap_hold_timer;

void tap_or_hold( keyrecord_t *record, uint16_t tap, uint16_t hold ) {

  if ( record->event.pressed ) {
    tap_hold_timer = timer_read();
  } else {

    if ( tap_hold_timer &&
      timer_elapsed( tap_hold_timer ) > TAP_HOLD_TIME ) {
      /* Held down then released */
      tap_code( hold );
    } else {
      /* Quickly Tapped */
      tap_code( tap );
    }

    tap_hold_timer = 0;

  }

}
Do not follow this link