tap_dances.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. Copyright 2021-2022 Rocco Meli <@RMeli>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. #include QMK_KEYBOARD_H
  16. // https://beta.docs.qmk.fm/using-qmk/software-features/feature_tap_dance#example-4-quad-function-tap-dance-id-example-4
  17. // + ---------- +
  18. // + TAP DANCES |
  19. // + ---------- +
  20. // Tap dance enums
  21. enum {
  22. TD_LSPO_CAPS, // Tap once for (, hold once for LSFT, tap twice for CAPS
  23. TD_RSPC_CAPS, // Tap once for ), hold once for RSFT, tap twice for CAPS
  24. TD_ESC_DEL, // Tap once for KC_ESC, twice for KC_DEL
  25. };
  26. // Rename tap dances for keymap with shortcuts
  27. #define TD_LSPC TD(TD_LSPO_CAPS)
  28. #define TD_RSPC TD(TD_RSPC_CAPS)
  29. #define TD_ED TD(TD_ESC_DEL)
  30. // + ----------- +
  31. // + KEY PRESSES |
  32. // + ----------- +
  33. // Different types of key presses
  34. typedef enum {
  35. TD_NONE,
  36. TD_SINGLE_TAP,
  37. TD_SINGLE_HOLD,
  38. TD_DOUBLE_TAP,
  39. } td_state_t;
  40. // Key press state
  41. typedef struct {
  42. bool is_press_action;
  43. td_state_t state;
  44. } td_tap_t;
  45. // + --------- +
  46. // + FUNCTIONS |
  47. // + --------- +
  48. // Tap dance for fast modifiers; favors being held over being tapped.
  49. td_state_t hold_cur_dance(qk_tap_dance_state_t *state);
  50. // Left Shift Parenthesis Open (LSPO) and Caps Lock (CAPS) on DOUBLE_TAP
  51. void LSPO_CAPS_finished(qk_tap_dance_state_t *state, void *user_data);
  52. void LSPO_CAPS_reset(qk_tap_dance_state_t *state, void *user_data);
  53. // Right Shift Parenthesis Close (RSPC) and Caps Lock (CAPS) on DOUBLE_TAP
  54. void RSPC_CAPS_finished(qk_tap_dance_state_t *state, void *user_data);
  55. void RSPC_CAPS_reset(qk_tap_dance_state_t *state, void *user_data);