]> git.donarmstrong.com Git - qmk_firmware.git/blob - quantum/process_keycode/process_combo.h
Allow Combo feature to be enabled/disabled live (#6318)
[qmk_firmware.git] / quantum / process_keycode / process_combo.h
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
17 #ifndef PROCESS_COMBO_H
18 #define PROCESS_COMBO_H
19
20 #include "progmem.h"
21 #include "quantum.h"
22 #include <stdint.h>
23
24 #ifdef EXTRA_EXTRA_LONG_COMBOS
25 #define MAX_COMBO_LENGTH 32
26 #elif EXTRA_LONG_COMBOS
27 #define MAX_COMBO_LENGTH 16
28 #else
29 #define MAX_COMBO_LENGTH 8
30 #endif
31
32 typedef struct {
33   const uint16_t *keys;
34   uint16_t keycode;
35 #ifdef EXTRA_EXTRA_LONG_COMBOS
36   uint32_t state;
37 #elif EXTRA_LONG_COMBOS
38   uint16_t state;
39 #else
40   uint8_t state;
41 #endif
42 } combo_t;
43
44 #define COMBO(ck, ca)                                                          \
45   { .keys = &(ck)[0], .keycode = (ca) }
46 #define COMBO_ACTION(ck)                                                       \
47   { .keys = &(ck)[0] }
48
49 #define COMBO_END 0
50 #ifndef COMBO_COUNT
51 #define COMBO_COUNT 0
52 #endif
53 #ifndef COMBO_TERM
54 #define COMBO_TERM TAPPING_TERM
55 #endif
56
57 bool process_combo(uint16_t keycode, keyrecord_t *record);
58 void matrix_scan_combo(void);
59 void process_combo_event(uint8_t combo_index, bool pressed);
60
61 void combo_enable(void);
62 void combo_disable(void);
63 void combo_toggle(void);
64 bool is_combo_enabled(void);
65
66 #endif