aboutsummaryrefslogtreecommitdiff
path: root/users/billypython/tap_dance.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/billypython/tap_dance.c')
-rw-r--r--users/billypython/tap_dance.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/users/billypython/tap_dance.c b/users/billypython/tap_dance.c
new file mode 100644
index 000000000..74ae16639
--- /dev/null
+++ b/users/billypython/tap_dance.c
@@ -0,0 +1,33 @@
1#include "tap_dance.h"
2
3#define ACTION_TAP_DANCE_DOUBLE_MODS(mod1, mod2) { \
4 .fn = { td_double_mods_each, NULL, td_double_mods_reset }, \
5 .user_data = &(qk_tap_dance_pair_t){ mod1, mod2 }, \
6 }
7
8void td_double_mods_each(qk_tap_dance_state_t *state, void *user_data) {
9 qk_tap_dance_pair_t *mods = (qk_tap_dance_pair_t *)user_data;
10 // Single tap → mod1, double tap → mod2, triple tap etc. → mod1+mod2
11 if (state->count == 1 || state->count == 3) {
12 register_code(mods->kc1);
13 } else if (state->count == 2) {
14 unregister_code(mods->kc1);
15 register_code(mods->kc2);
16 }
17 // Prevent tap dance from sending kc1 and kc2 as weak mods
18 state->weak_mods &= ~(MOD_BIT(mods->kc1) | MOD_BIT(mods->kc2));
19}
20
21void td_double_mods_reset(qk_tap_dance_state_t *state, void *user_data) {
22 qk_tap_dance_pair_t *mods = (qk_tap_dance_pair_t *)user_data;
23 if (state->count == 1 || state->count >= 3) {
24 unregister_code(mods->kc1);
25 }
26 if (state->count >= 2) {
27 unregister_code(mods->kc2);
28 }
29}
30
31qk_tap_dance_action_t tap_dance_actions[] = {
32 [TD_RSF_RCT] = ACTION_TAP_DANCE_DOUBLE_MODS(KC_RSFT, KC_RCTL),
33};