6 SINGLE_TAP, SINGLE_HOLD, DOUBLE
7 } tap_dance_state_enum;
9 static tap_dance_state_enum tap_dance_state;
10 static bool tap_dance_active = false;
12 void tap_dance_sym_vim_finished(qk_tap_dance_state_t *state, void *user_data) {
13 // Determine the current state
14 if (state->count == 1) {
15 if (state->interrupted || state->pressed == 0) tap_dance_state = SINGLE_TAP;
16 else tap_dance_state = SINGLE_HOLD;
18 // Handle any number of other taps as a VIM movement hold
19 tap_dance_state = DOUBLE;
22 switch (tap_dance_state) {
24 if (tap_dance_active) {
25 reset_oneshot_layer();
26 tap_dance_active = false;
28 set_oneshot_layer(SYMB, ONESHOT_START);
29 tap_dance_active = true;
41 void tap_dance_sym_vim_reset(qk_tap_dance_state_t *state, void *user_data) {
42 switch(tap_dance_state) {
44 clear_oneshot_layer_state(ONESHOT_PRESSED);
55 void tap_dance_copy_paste_finished(qk_tap_dance_state_t *state, void *user_data) {
56 bool is_paste = state->count == 2;
57 // If either the one-shot shift is set, or if shift is being held, count as shift being held.
58 // We'll clear the one-shot shift if it was held
59 uint8_t one_shot_mods = get_oneshot_mods();
60 bool is_shift = false;
62 if (get_mods() & MOD_MASK_SHIFT) {
64 } else if (one_shot_mods & MOD_MASK_SHIFT) {
65 set_oneshot_mods(one_shot_mods & ~MOD_MASK_SHIFT);
71 SEND_STRING(SS_LSFT(SS_TAP(X_INSERT)));
73 SEND_STRING(SS_LCTRL("v"));
77 SEND_STRING(SS_LCTRL(SS_TAP(X_INSERT)));
79 SEND_STRING(SS_LCTRL("c"));
84 qk_tap_dance_action_t tap_dance_actions[] = {
85 [TD_SYM_VIM] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, tap_dance_sym_vim_finished, tap_dance_sym_vim_reset),
86 [TD_COPY_PASTE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, tap_dance_copy_paste_finished, NULL)
89 void tap_dance_process_record(uint16_t keycode) {
90 if (tap_dance_state == SINGLE_TAP && keycode != TD(TD_SYM_VIM)) {
91 tap_dance_active = false;
95 __attribute__ ((weak))
96 void matrix_init_rgb(void) {}
98 __attribute__ ((weak))
99 void layer_state_set_rgb(uint32_t state) {}
101 __attribute__ ((weak))
102 void matrix_scan_user_keyboard(void) {}
104 void matrix_scan_user() {
105 static bool first_run = true;
110 matrix_scan_user_keyboard();
113 uint32_t layer_state_set_user(uint32_t state) {
114 layer_state_set_rgb(state);