diff options
Diffstat (limited to 'quantum/process_keycode/process_tap_dance.h')
| -rw-r--r-- | quantum/process_keycode/process_tap_dance.h | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h index 7b820584a..e2c74efe9 100644 --- a/quantum/process_keycode/process_tap_dance.h +++ b/quantum/process_keycode/process_tap_dance.h | |||
| @@ -11,46 +11,40 @@ typedef struct | |||
| 11 | uint8_t count; | 11 | uint8_t count; |
| 12 | uint16_t keycode; | 12 | uint16_t keycode; |
| 13 | uint16_t timer; | 13 | uint16_t timer; |
| 14 | bool active:1; | ||
| 15 | bool pressed:1; | ||
| 14 | } qk_tap_dance_state_t; | 16 | } qk_tap_dance_state_t; |
| 15 | 17 | ||
| 16 | #define TD(n) (QK_TAP_DANCE + n) | 18 | #define TD(n) (QK_TAP_DANCE + n) |
| 17 | 19 | ||
| 18 | typedef enum | 20 | typedef void (*qk_tap_dance_user_fn_t) (qk_tap_dance_state_t *state, void *user_data); |
| 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 | 21 | ||
| 26 | typedef struct | 22 | typedef struct |
| 27 | { | 23 | { |
| 28 | qk_tap_dance_type_t type; | 24 | struct { |
| 29 | union { | 25 | qk_tap_dance_user_fn_t on_each_tap; |
| 30 | struct { | 26 | qk_tap_dance_user_fn_t on_dance_finished; |
| 31 | uint16_t kc1; | 27 | qk_tap_dance_user_fn_t on_reset; |
| 32 | uint16_t kc2; | 28 | } fn; |
| 33 | } pair; | 29 | void *user_data; |
| 34 | struct { | ||
| 35 | qk_tap_dance_user_fn_t on_each_tap; | ||
| 36 | qk_tap_dance_user_fn_t on_dance_finished; | ||
| 37 | qk_tap_dance_user_fn_t on_reset; | ||
| 38 | } fn; | ||
| 39 | }; | ||
| 40 | } qk_tap_dance_action_t; | 30 | } qk_tap_dance_action_t; |
| 41 | 31 | ||
| 32 | typedef struct | ||
| 33 | { | ||
| 34 | uint16_t kc1; | ||
| 35 | uint16_t kc2; | ||
| 36 | } qk_tap_dance_pair_t; | ||
| 37 | |||
| 42 | #define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) { \ | 38 | #define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) { \ |
| 43 | .type = QK_TAP_DANCE_TYPE_PAIR, \ | 39 | .fn = { NULL, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset }, \ |
| 44 | .pair = { kc1, kc2 } \ | 40 | .user_data = (void *)&((qk_tap_dance_pair_t) { kc1, kc2 }) \ |
| 45 | } | 41 | } |
| 46 | 42 | ||
| 47 | #define ACTION_TAP_DANCE_FN(user_fn) { \ | 43 | #define ACTION_TAP_DANCE_FN(user_fn) { \ |
| 48 | .type = QK_TAP_DANCE_TYPE_FN, \ | ||
| 49 | .fn = { NULL, user_fn, NULL } \ | 44 | .fn = { NULL, user_fn, NULL } \ |
| 50 | } | 45 | } |
| 51 | 46 | ||
| 52 | #define ACTION_TAP_DANCE_FN_ADVANCED(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_reset) { \ | 47 | #define ACTION_TAP_DANCE_FN_ADVANCED(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_reset) { \ |
| 53 | .type = QK_TAP_DANCE_TYPE_FN, \ | ||
| 54 | .fn = { user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_reset } \ | 48 | .fn = { user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_reset } \ |
| 55 | } | 49 | } |
| 56 | 50 | ||
| @@ -62,6 +56,9 @@ bool process_tap_dance(uint16_t keycode, keyrecord_t *record); | |||
| 62 | void matrix_scan_tap_dance (void); | 56 | void matrix_scan_tap_dance (void); |
| 63 | void reset_tap_dance (qk_tap_dance_state_t *state); | 57 | void reset_tap_dance (qk_tap_dance_state_t *state); |
| 64 | 58 | ||
| 59 | void qk_tap_dance_pair_finished (qk_tap_dance_state_t *state, void *user_data); | ||
| 60 | void qk_tap_dance_pair_reset (qk_tap_dance_state_t *state, void *user_data); | ||
| 61 | |||
| 65 | #else | 62 | #else |
| 66 | 63 | ||
| 67 | #define TD(n) KC_NO | 64 | #define TD(n) KC_NO |
