process_combo.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright 2016 Jack Humbert
  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. #ifndef PROCESS_COMBO_H
  17. #define PROCESS_COMBO_H
  18. #include "progmem.h"
  19. #include "quantum.h"
  20. #include <stdint.h>
  21. #ifdef EXTRA_EXTRA_LONG_COMBOS
  22. # define MAX_COMBO_LENGTH 32
  23. #elif EXTRA_LONG_COMBOS
  24. # define MAX_COMBO_LENGTH 16
  25. #else
  26. # define MAX_COMBO_LENGTH 8
  27. #endif
  28. typedef struct {
  29. const uint16_t *keys;
  30. uint16_t keycode;
  31. #ifdef EXTRA_EXTRA_LONG_COMBOS
  32. uint32_t state;
  33. #elif EXTRA_LONG_COMBOS
  34. uint16_t state;
  35. #else
  36. uint8_t state;
  37. #endif
  38. } combo_t;
  39. #define COMBO(ck, ca) \
  40. { .keys = &(ck)[0], .keycode = (ca) }
  41. #define COMBO_ACTION(ck) \
  42. { .keys = &(ck)[0] }
  43. #define COMBO_END 0
  44. #ifndef COMBO_COUNT
  45. # define COMBO_COUNT 0
  46. #endif
  47. #ifndef COMBO_TERM
  48. # define COMBO_TERM TAPPING_TERM
  49. #endif
  50. bool process_combo(uint16_t keycode, keyrecord_t *record);
  51. void matrix_scan_combo(void);
  52. void process_combo_event(uint8_t combo_index, bool pressed);
  53. void combo_enable(void);
  54. void combo_disable(void);
  55. void combo_toggle(void);
  56. bool is_combo_enabled(void);
  57. #endif