process_combo.h 1.4 KB

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