summaryrefslogtreecommitdiff
path: root/users/d4mation/tap-hold.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/d4mation/tap-hold.c')
-rw-r--r--users/d4mation/tap-hold.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/users/d4mation/tap-hold.c b/users/d4mation/tap-hold.c
new file mode 100644
index 0000000000..0c5119f995
--- /dev/null
+++ b/users/d4mation/tap-hold.c
@@ -0,0 +1,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;
+
+ }
+
+} \ No newline at end of file