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.

70 lines
2.5 KiB

  1. /* Copyright 2020 Joseph Wasson
  2. *
  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. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "tapdance.h"
  17. int cur_dance (qk_tap_dance_state_t *state) {
  18. if (state->count == 1) {
  19. //If count = 1, and it has been interrupted - it doesn't matter if it is pressed or not: Send SINGLE_TAP
  20. if (state->interrupted) {
  21. // if (!state->pressed) return SINGLE_TAP;
  22. //need "permissive hold" here.
  23. // else return SINGLE_HOLD;
  24. //If the interrupting key is released before the tap-dance key, then it is a single HOLD
  25. //However, if the tap-dance key is released first, then it is a single TAP
  26. //But how to get access to the state of the interrupting key????
  27. return SINGLE_TAP;
  28. }
  29. else {
  30. if (!state->pressed) return SINGLE_TAP;
  31. else return SINGLE_HOLD;
  32. }
  33. }
  34. //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated
  35. //with single tap.
  36. else if (state->count == 2) {
  37. if (state->interrupted) return DOUBLE_SINGLE_TAP;
  38. else if (state->pressed) return DOUBLE_HOLD;
  39. else return DOUBLE_TAP;
  40. }
  41. else if ((state->count == 3) && ((state->interrupted) || (!state->pressed))) return TRIPLE_TAP;
  42. else if (state->count == 3) return TRIPLE_HOLD;
  43. else return SPECIAL;
  44. }
  45. int hold_cur_dance (qk_tap_dance_state_t *state) {
  46. if (state->count == 1) {
  47. if (state->interrupted) {
  48. if (!state->pressed) return SINGLE_TAP;
  49. else return SINGLE_HOLD;
  50. }
  51. else {
  52. if (!state->pressed) return SINGLE_TAP;
  53. else return SINGLE_HOLD;
  54. }
  55. }
  56. //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated
  57. //with single tap.
  58. else if (state->count == 2) {
  59. if (state->pressed) return DOUBLE_HOLD;
  60. else return DOUBLE_TAP;
  61. }
  62. else if (state->count == 3) {
  63. if (!state->pressed) return TRIPLE_TAP;
  64. else return TRIPLE_HOLD;
  65. }
  66. else return SPECIAL;
  67. }