logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

process_combo.h (2236B)


  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 <stdbool.h>
  19. #include "action.h"
  20. #include "keycodes.h"
  21. #include "quantum_keycodes.h"
  22. #ifdef EXTRA_SHORT_COMBOS
  23. # define MAX_COMBO_LENGTH 6
  24. #elif defined(EXTRA_EXTRA_LONG_COMBOS)
  25. # define MAX_COMBO_LENGTH 32
  26. #elif defined(EXTRA_LONG_COMBOS)
  27. # define MAX_COMBO_LENGTH 16
  28. #else
  29. # define MAX_COMBO_LENGTH 8
  30. #endif
  31. #ifndef COMBO_KEY_BUFFER_LENGTH
  32. # define COMBO_KEY_BUFFER_LENGTH MAX_COMBO_LENGTH
  33. #endif
  34. #ifndef COMBO_BUFFER_LENGTH
  35. # define COMBO_BUFFER_LENGTH 4
  36. #endif
  37. typedef struct combo_t {
  38. const uint16_t *keys;
  39. uint16_t keycode;
  40. #ifdef EXTRA_SHORT_COMBOS
  41. uint8_t state;
  42. #else
  43. bool disabled;
  44. bool active;
  45. # if defined(EXTRA_EXTRA_LONG_COMBOS)
  46. uint32_t state;
  47. # elif defined(EXTRA_LONG_COMBOS)
  48. uint16_t state;
  49. # else
  50. uint8_t state;
  51. # endif
  52. #endif
  53. } combo_t;
  54. #define COMBO(ck, ca) \
  55. { .keys = &(ck)[0], .keycode = (ca) }
  56. #define COMBO_ACTION(ck) \
  57. { .keys = &(ck)[0] }
  58. #define COMBO_END 0
  59. #ifndef COMBO_TERM
  60. # define COMBO_TERM 50
  61. #endif
  62. #ifndef COMBO_HOLD_TERM
  63. # define COMBO_HOLD_TERM TAPPING_TERM
  64. #endif
  65. /* check if keycode is only modifiers */
  66. #define KEYCODE_IS_MOD(code) (IS_MODIFIER_KEYCODE(code) || (IS_QK_MODS(code) && !QK_MODS_GET_BASIC_KEYCODE(code)))
  67. bool process_combo(uint16_t keycode, keyrecord_t *record);
  68. void combo_task(void);
  69. void process_combo_event(uint16_t combo_index, bool pressed);
  70. void combo_enable(void);
  71. void combo_disable(void);
  72. void combo_toggle(void);
  73. bool is_combo_enabled(void);