You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
826 B

  1. #include "ridingqwerty.h"
  2. #include "tapdances.h"
  3. void braces_finished (qk_tap_dance_state_t *state, void *user_data) {
  4. if ((state->count == 1) || (state->count == 3)) {
  5. register_code(KC_LSFT);
  6. }
  7. }
  8. void braces_reset (qk_tap_dance_state_t *state, void *user_data) {
  9. // two or three taps for "[]"/"{}"
  10. if ((state->count == 2) || (state->count == 3)) {
  11. tap_code(KC_LBRC);
  12. tap_code(KC_RBRC);
  13. }
  14. // one tap for "()"
  15. else if (state->count == 1) {
  16. tap_code(KC_9);
  17. tap_code(KC_0);
  18. }
  19. // unregister the shift unconditionally
  20. unregister_code(KC_LSFT);
  21. // move back one space, inside the braces
  22. if (state->count <= 3) {
  23. tap_code(KC_LEFT);
  24. }
  25. }
  26. qk_tap_dance_action_t tap_dance_actions[] = {
  27. [TD_BRACES] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, braces_finished, braces_reset)
  28. };