]> git.donarmstrong.com Git - qmk_firmware.git/blob - quantum/process_keycode/process_tap_dance.h
Moves features to their own files (process_*), adds tap dance feature (#460)
[qmk_firmware.git] / quantum / process_keycode / process_tap_dance.h
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
9 typedef 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
18 typedef enum
19 {
20   QK_TAP_DANCE_TYPE_PAIR,
21   QK_TAP_DANCE_TYPE_FN,
22 } qk_tap_dance_type_t;
23
24 typedef void (*qk_tap_dance_user_fn_t) (qk_tap_dance_state_t *state);
25
26 typedef 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
48 extern const qk_tap_dance_action_t tap_dance_actions[];
49
50 /* To be used internally */
51
52 bool process_tap_dance(uint16_t keycode, keyrecord_t *record);
53 void matrix_scan_tap_dance (void);
54 void 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