tap_dances.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include "tap_dances.h"
  2. // Tap dance function for enable swedish characters on first layer. Unregister to not let tap bleed over to next keypress.
  3. // Tap dance 1
  4. void dance_1_finished(qk_tap_dance_state_t *state, void *user_data) {
  5. if (state->count == 2) {
  6. tap_code(KC_SCLN);
  7. } else {
  8. register_code(KC_RALT);
  9. register_code(KC_O);
  10. unregister_code(KC_RALT);
  11. unregister_code(KC_O);
  12. }
  13. }
  14. void dance_1_reset(qk_tap_dance_state_t *state, void *user_data) {
  15. if (state->count == 2) {
  16. unregister_code(KC_SCLN);
  17. } else {
  18. unregister_code(KC_RALT);
  19. unregister_code(KC_O);
  20. }
  21. }
  22. // Tap dance 2
  23. void dance_2_finished(qk_tap_dance_state_t *state, void *user_data) {
  24. if (state->count == 2) {
  25. tap_code(KC_QUOT);
  26. } else {
  27. register_code(KC_RALT);
  28. register_code(KC_A);
  29. unregister_code(KC_RALT);
  30. unregister_code(KC_A);
  31. }
  32. }
  33. void dance_2_reset(qk_tap_dance_state_t *state, void *user_data) {
  34. if (state->count == 2) {
  35. unregister_code(KC_QUOT);
  36. } else {
  37. unregister_code(KC_RALT);
  38. unregister_code(KC_A);
  39. }
  40. }
  41. // Tap dance 3
  42. void dance_3_finished(qk_tap_dance_state_t *state, void *user_data) {
  43. // if (state->count == 2)
  44. if (state->count == 2) {
  45. tap_code(KC_SLSH);
  46. } else {
  47. register_code(KC_RALT);
  48. register_code(KC_W);
  49. unregister_code(KC_RALT);
  50. unregister_code(KC_W);
  51. }
  52. }
  53. void dance_3_reset(qk_tap_dance_state_t *state, void *user_data) {
  54. if (state->count == 2) {
  55. unregister_code(KC_SLSH);
  56. } else {
  57. unregister_code(KC_RALT);
  58. unregister_code(KC_W);
  59. }
  60. }
  61. // Tap Dance Definitions
  62. qk_tap_dance_action_t tap_dance_actions[] = {
  63. // simple tap dance
  64. [TD1] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_1_finished, dance_1_reset),
  65. [TD2] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_2_finished, dance_2_reset),
  66. [TD3] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_3_finished, dance_3_reset)};