~ruther/qmk_firmware

ref: 31a9d2d00dc732ca29be2213dbf915d6f6ffc76d qmk_firmware/users/ridingqwerty/tapdances.c -rw-r--r-- 817 bytes
31a9d2d0 — Yizhen Liu [keyboard] Graystudio Think6.5 V3 Support Revised (#21560) 1 year, 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "ridingqwerty.h"
#include "tapdances.h"

void braces_finished (tap_dance_state_t *state, void *user_data) {
    if ((state->count == 1) || (state->count == 3)) {
        register_code(KC_LSFT);
    }
}

void braces_reset (tap_dance_state_t *state, void *user_data) {
  // two or three taps for "[]"/"{}"
  if ((state->count == 2) || (state->count == 3)) {
    tap_code(KC_LBRC);
    tap_code(KC_RBRC);
  }
  // one tap for "()"
  else if (state->count == 1) {
    tap_code(KC_9);
    tap_code(KC_0);
  }

  // unregister the shift unconditionally
  unregister_code(KC_LSFT);

  // move back one space, inside the braces
  if (state->count <= 3) {
    tap_code(KC_LEFT);
  }
}

tap_dance_action_t tap_dance_actions[] = {
    [TD_BRACES] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, braces_finished, braces_reset)
};
Do not follow this link