aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode/process_tap_dance.h
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode/process_tap_dance.h')
-rw-r--r--quantum/process_keycode/process_tap_dance.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h
new file mode 100644
index 000000000..b9d7c7fcf
--- /dev/null
+++ b/quantum/process_keycode/process_tap_dance.h
@@ -0,0 +1,62 @@
1#ifndef PROCESS_TAP_DANCE_H
2#define PROCESS_TAP_DANCE_H
3
4#ifdef TAP_DANCE_ENABLE
5
6#include <stdbool.h>
7#include <inttypes.h>
8
9typedef struct
10{
11 uint8_t count;
12 uint16_t keycode;
13 uint16_t timer;
14} qk_tap_dance_state_t;
15
16#define TD(n) (QK_TAP_DANCE + n)
17
18typedef enum
19{
20 QK_TAP_DANCE_TYPE_PAIR,
21 QK_TAP_DANCE_TYPE_FN,
22} qk_tap_dance_type_t;
23
24typedef void (*qk_tap_dance_user_fn_t) (qk_tap_dance_state_t *state);
25
26typedef struct
27{
28 qk_tap_dance_type_t type;
29 union {
30 struct {
31 uint16_t kc1;
32 uint16_t kc2;
33 } pair;
34 qk_tap_dance_user_fn_t fn;
35 };
36} qk_tap_dance_action_t;
37
38#define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) { \
39 .type = QK_TAP_DANCE_TYPE_PAIR, \
40 .pair = { kc1, kc2 } \
41 }
42
43#define ACTION_TAP_DANCE_FN(user_fn) { \
44 .type = QK_TAP_DANCE_TYPE_FN, \
45 .fn = user_fn \
46 }
47
48extern const qk_tap_dance_action_t tap_dance_actions[];
49
50/* To be used internally */
51
52bool process_tap_dance(uint16_t keycode, keyrecord_t *record);
53void matrix_scan_tap_dance (void);
54void reset_tap_dance (qk_tap_dance_state_t *state);
55
56#else
57
58#define TD(n) KC_NO
59
60#endif
61
62#endif