aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode/process_combo.h
diff options
context:
space:
mode:
authorPete Sevander <pete.sevander@gmail.com>2021-08-06 02:44:57 +0300
committerGitHub <noreply@github.com>2021-08-06 09:44:57 +1000
commit7e983796e18e7401c062c158f23966aeb7b1405b (patch)
tree88d6897d7ca4f6103f03c1941dac6736ba477361 /quantum/process_keycode/process_combo.h
parent07553b41f0a03ca6549c09cecf9cd3dec7332346 (diff)
downloadqmk_firmware-7e983796e18e7401c062c158f23966aeb7b1405b.tar.gz
qmk_firmware-7e983796e18e7401c062c158f23966aeb7b1405b.zip
Process combos earlier & overlapping combos (#8591)
* Combo processing improvements. Now it is possible to use ModTap and LayerTap keys as part of combos. Overlapping combos also don't trigger all the combos, just exactly the one that you press. New settings: - COMBO_MUST_HOLD_MODS - COMBO_MOD_TERM - COMBO_TERM_PER_COMBO - COMBO_MUST_HOLD_PER_COMBO - COMBO_STRICT_TIMER - COMBO_NO_TIMER * Remove the size flags from combo_t struct boolean members. This in the end actually saves space as the members are accessed so many times. The amount of operations needed to access the bits uses more memory than setting the size saves. * Fix `process_combo_key_release` not called correctly with tap-only combos * Fix not passing a pointer when NO_ACTION_TAPPING is defined. * Docs for `COMBO_ONLY_FROM_LAYER` * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update quantum/process_keycode/process_combo.c Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Add `EXTRA_SHORT_COMBOS` option. Stuff combo's `disabled` and `active` flags into `state`. Possibly can save some space. * Add more examples and clarify things with dict management system. - Simple examples now has a combo that has modifiers included. - The slightly more advanced examples now are actually more advanced instead of just `tap_code16(<modded-keycode>)`. - Added a note that `COMBO_ACTION`s are not needed anymore as you can just use custom keycodes. - Added a note that the `g/keymap_combo.h` macros use the `process_combo_event` function and that it is not usable in one's keymap afterwards. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Change "the" combo action example to "email" example. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Fix sneaky infinite loop with `combo_disable()` No need to call `dump_key_buffer` when disabling combos because the buffer is either being dumped if a combo-key was pressed, or the buffer is empty if a non-combo-key is pressed. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'quantum/process_keycode/process_combo.h')
-rw-r--r--quantum/process_keycode/process_combo.h36
1 files changed, 27 insertions, 9 deletions
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h
index 9af97588b..43c36d79e 100644
--- a/quantum/process_keycode/process_combo.h
+++ b/quantum/process_keycode/process_combo.h
@@ -20,23 +20,38 @@
20#include "quantum.h" 20#include "quantum.h"
21#include <stdint.h> 21#include <stdint.h>
22 22
23#ifdef EXTRA_EXTRA_LONG_COMBOS 23#ifdef EXTRA_SHORT_COMBOS
24# define MAX_COMBO_LENGTH 6
25#elif defined(EXTRA_EXTRA_LONG_COMBOS)
24# define MAX_COMBO_LENGTH 32 26# define MAX_COMBO_LENGTH 32
25#elif EXTRA_LONG_COMBOS 27#elif defined(EXTRA_LONG_COMBOS)
26# define MAX_COMBO_LENGTH 16 28# define MAX_COMBO_LENGTH 16
27#else 29#else
28# define MAX_COMBO_LENGTH 8 30# define MAX_COMBO_LENGTH 8
29#endif 31#endif
30 32
33#ifndef COMBO_KEY_BUFFER_LENGTH
34# define COMBO_KEY_BUFFER_LENGTH MAX_COMBO_LENGTH
35#endif
36#ifndef COMBO_BUFFER_LENGTH
37# define COMBO_BUFFER_LENGTH 4
38#endif
39
31typedef struct { 40typedef struct {
32 const uint16_t *keys; 41 const uint16_t *keys;
33 uint16_t keycode; 42 uint16_t keycode;
34#ifdef EXTRA_EXTRA_LONG_COMBOS 43#ifdef EXTRA_SHORT_COMBOS
44 uint8_t state;
45#else
46 bool disabled;
47 bool active;
48# if defined(EXTRA_EXTRA_LONG_COMBOS)
35 uint32_t state; 49 uint32_t state;
36#elif EXTRA_LONG_COMBOS 50# elif defined(EXTRA_LONG_COMBOS)
37 uint16_t state; 51 uint16_t state;
38#else 52# else
39 uint8_t state; 53 uint8_t state;
54# endif
40#endif 55#endif
41} combo_t; 56} combo_t;
42 57
@@ -46,12 +61,15 @@ typedef struct {
46 { .keys = &(ck)[0] } 61 { .keys = &(ck)[0] }
47 62
48#define COMBO_END 0 63#define COMBO_END 0
49#ifndef COMBO_COUNT
50# define COMBO_COUNT 0
51#endif
52#ifndef COMBO_TERM 64#ifndef COMBO_TERM
53# define COMBO_TERM TAPPING_TERM 65# define COMBO_TERM 50
54#endif 66#endif
67#ifndef COMBO_HOLD_TERM
68# define COMBO_HOLD_TERM TAPPING_TERM
69#endif
70
71/* check if keycode is only modifiers */
72#define KEYCODE_IS_MOD(code) (IS_MOD(code) || (code >= QK_MODS && code <= QK_MODS_MAX && !(code & QK_BASIC_MAX)))
55 73
56bool process_combo(uint16_t keycode, keyrecord_t *record); 74bool process_combo(uint16_t keycode, keyrecord_t *record);
57void combo_task(void); 75void combo_task(void);