process_combo.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 <stdint.h>
  19. #include "progmem.h"
  20. #include "quantum.h"
  21. typedef struct
  22. {
  23. const uint16_t *keys;
  24. uint16_t keycode;
  25. #ifdef EXTRA_EXTRA_LONG_COMBOS
  26. uint32_t state;
  27. #elif EXTRA_LONG_COMBOS
  28. uint16_t state;
  29. #else
  30. uint8_t state;
  31. #endif
  32. uint16_t timer;
  33. bool is_active;
  34. #ifdef COMBO_ALLOW_ACTION_KEYS
  35. keyrecord_t prev_record;
  36. #else
  37. uint16_t prev_key;
  38. #endif
  39. } combo_t;
  40. #define COMBO(ck, ca) {.keys = &(ck)[0], .keycode = (ca)}
  41. #define COMBO_ACTION(ck) {.keys = &(ck)[0]}
  42. #define COMBO_END 0
  43. #ifndef COMBO_COUNT
  44. #define COMBO_COUNT 0
  45. #endif
  46. #ifndef COMBO_TERM
  47. #define COMBO_TERM TAPPING_TERM
  48. #endif
  49. bool process_combo(uint16_t keycode, keyrecord_t *record);
  50. void matrix_scan_combo(void);
  51. void process_combo_event(uint8_t combo_index, bool pressed);
  52. #endif