aboutsummaryrefslogtreecommitdiffstats
path: root/quantum/process_keycode/process_combo.h
diff options
context:
space:
mode:
authorBob <rsheldiii@gmail.com>2019-04-08 17:07:15 -0400
committerDrashna Jaelre <drashna@live.com>2019-04-08 14:07:15 -0700
commitbc536b9b6d98e5428a28f6e6ba69675bd77b79cc (patch)
tree1a22225476402e824957f77bd801d371a2622ed5 /quantum/process_keycode/process_combo.h
parentf8d365a47847f8e49fde5096aa065dbee08cf728 (diff)
downloadfirmware-bc536b9b6d98e5428a28f6e6ba69675bd77b79cc.tar.gz
firmware-bc536b9b6d98e5428a28f6e6ba69675bd77b79cc.tar.bz2
firmware-bc536b9b6d98e5428a28f6e6ba69675bd77b79cc.zip
Switch process_combo to using global register and timer (#2561)
Since combos keep local state about what keys have been previously pressed, when combos are layered, multiple keypresses will register for any key with multiple combos assigned to it. In order to fix this, I switched process_combo to use a global keycode / keyrecord register and timer. When a keypress is consumed by a combo, it gets stored in the register and the timer is updated; when the next keypress takes too long or a key is pressed that isn't part of any combo, the buffer is emitted and the timer reset. This has a few side effects. For instance, I couldn't _not_ fix combo keys printing out of order while also fixing this bug, so combo keys print in order correctly when a combo fails. since combos no longer have local timers, the logic around when combos time out has changed. now that there is a single timer pressing any combo key (including one in a different combo) will reset the timer for all combos, making combo entry a little more lenient. Since combos no longer have local keycode / keyrecord state, there is an edge case where incomplete combo keys can be consumed. if you have a combo for a+s = tab and a combo for b+n = space, if you press a+b+n, only a space will be emitted. This is because when b+n completes successfully, it drops the register.
Diffstat (limited to 'quantum/process_keycode/process_combo.h')
-rw-r--r--quantum/process_keycode/process_combo.h33
1 files changed, 17 insertions, 16 deletions
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h
index a5787c9ed..f06d2d345 100644
--- a/quantum/process_keycode/process_combo.h
+++ b/quantum/process_keycode/process_combo.h
@@ -17,33 +17,34 @@
#ifndef PROCESS_COMBO_H
#define PROCESS_COMBO_H
-#include <stdint.h>
#include "progmem.h"
#include "quantum.h"
+#include <stdint.h>
-typedef struct
-{
- const uint16_t *keys;
- uint16_t keycode;
#ifdef EXTRA_EXTRA_LONG_COMBOS
- uint32_t state;
+#define MAX_COMBO_LENGTH 32
#elif EXTRA_LONG_COMBOS
- uint16_t state;
+#define MAX_COMBO_LENGTH 16
#else
- uint8_t state;
+#define MAX_COMBO_LENGTH 8
#endif
- uint16_t timer;
- bool is_active;
-#ifdef COMBO_ALLOW_ACTION_KEYS
- keyrecord_t prev_record;
+
+typedef struct {
+ const uint16_t *keys;
+ uint16_t keycode;
+#ifdef EXTRA_EXTRA_LONG_COMBOS
+ uint32_t state;
+#elif EXTRA_LONG_COMBOS
+ uint16_t state;
#else
- uint16_t prev_key;
+ uint8_t state;
#endif
} combo_t;
-
-#define COMBO(ck, ca) {.keys = &(ck)[0], .keycode = (ca)}
-#define COMBO_ACTION(ck) {.keys = &(ck)[0]}
+#define COMBO(ck, ca) \
+ { .keys = &(ck)[0], .keycode = (ca) }
+#define COMBO_ACTION(ck) \
+ { .keys = &(ck)[0] }
#define COMBO_END 0
#ifndef COMBO_COUNT