tap_dances.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. tap_code16(ALGR(KC_A));
  9. }
  10. }
  11. void dance_1_reset(qk_tap_dance_state_t *state, void *user_data) {
  12. if (state->count == 2) {
  13. unregister_code(KC_SCLN);
  14. } else {
  15. unregister_code16(ALGR(KC_A));
  16. }
  17. }
  18. // Tap dance 2
  19. void dance_2_finished(qk_tap_dance_state_t *state, void *user_data) {
  20. if (state->count == 2) {
  21. tap_code(KC_QUOT);
  22. } else {
  23. tap_code16(ALGR(KC_W));
  24. }
  25. }
  26. void dance_2_reset(qk_tap_dance_state_t *state, void *user_data) {
  27. if (state->count == 2) {
  28. unregister_code(KC_QUOT);
  29. } else {
  30. unregister_code16(ALGR(KC_W));
  31. }
  32. }
  33. // Tap dance 3
  34. void dance_3_finished(qk_tap_dance_state_t *state, void *user_data) {
  35. // if (state->count == 2)
  36. if (state->count == 2) {
  37. tap_code(KC_SLSH);
  38. } else {
  39. tap_code16(ALGR(KC_O));
  40. }
  41. }
  42. void dance_3_reset(qk_tap_dance_state_t *state, void *user_data) {
  43. if (state->count == 2) {
  44. unregister_code(KC_SLSH);
  45. } else {
  46. unregister_code16(ALGR(KC_O));
  47. }
  48. }
  49. // Tap dance 4
  50. void dance_4_finished(qk_tap_dance_state_t *state, void *user_data) {
  51. // if (state->count == 2)
  52. if (state->count == 2) {
  53. tap_code(KC_DOT);
  54. } else {
  55. tap_code16(ALGR(KC_W));
  56. }
  57. }
  58. void dance_4_reset(qk_tap_dance_state_t *state, void *user_data) {
  59. if (state->count == 2) {
  60. unregister_code(KC_DOT);
  61. } else {
  62. unregister_code16(ALGR(KC_W));
  63. }
  64. }
  65. // Tap dance 5
  66. void dance_5_finished(qk_tap_dance_state_t *state, void *user_data) {
  67. // if (state->count == 2)
  68. if (state->count == 2) {
  69. tap_code(KC_DOT);
  70. } else {
  71. tap_code16(ALGR(KC_O));
  72. }
  73. }
  74. void dance_5_reset(qk_tap_dance_state_t *state, void *user_data) {
  75. if (state->count == 2) {
  76. unregister_code(KC_DOT);
  77. } else {
  78. unregister_code16(ALGR(KC_O));
  79. }
  80. }
  81. // Tap Dance Definitions
  82. qk_tap_dance_action_t tap_dance_actions[] = {
  83. // simple tap dance
  84. [TD1] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_1_finished, dance_1_reset),
  85. [TD2] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_2_finished, dance_2_reset),
  86. [TD3] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_3_finished, dance_3_reset),
  87. [TD4] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_4_finished, dance_4_reset),
  88. [TD5] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_5_finished, dance_5_reset)};