aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_combo.c43
-rw-r--r--quantum/process_keycode/process_combo.h5
2 files changed, 47 insertions, 1 deletions
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index 2c6c9d0d5..d3c3b1673 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -28,6 +28,7 @@ static uint16_t timer = 0;
28static uint8_t current_combo_index = 0; 28static uint8_t current_combo_index = 0;
29static bool drop_buffer = false; 29static bool drop_buffer = false;
30static bool is_active = false; 30static bool is_active = false;
31static bool b_combo_enable = true; // defaults to enabled
31 32
32static uint8_t buffer_size = 0; 33static uint8_t buffer_size = 0;
33#ifdef COMBO_ALLOW_ACTION_KEYS 34#ifdef COMBO_ALLOW_ACTION_KEYS
@@ -128,6 +129,23 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
128 drop_buffer = false; 129 drop_buffer = false;
129 bool no_combo_keys_pressed = true; 130 bool no_combo_keys_pressed = true;
130 131
132 if (keycode == CMB_ON && record->event.pressed) {
133 combo_enable();
134 return true;
135 }
136
137 if (keycode == CMB_OFF && record->event.pressed) {
138 combo_disable();
139 return true;
140 }
141
142 if (keycode == CMB_TOG && record->event.pressed) {
143 combo_toggle();
144 return true;
145 }
146
147 if (!is_combo_enabled()) { return true; }
148
131 for (current_combo_index = 0; current_combo_index < COMBO_COUNT; 149 for (current_combo_index = 0; current_combo_index < COMBO_COUNT;
132 ++current_combo_index) { 150 ++current_combo_index) {
133 combo_t *combo = &key_combos[current_combo_index]; 151 combo_t *combo = &key_combos[current_combo_index];
@@ -166,7 +184,7 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) {
166} 184}
167 185
168void matrix_scan_combo(void) { 186void matrix_scan_combo(void) {
169 if (is_active && timer && timer_elapsed(timer) > COMBO_TERM) { 187 if (b_combo_enable && is_active && timer && timer_elapsed(timer) > COMBO_TERM) {
170 188
171 /* This disables the combo, meaning key events for this 189 /* This disables the combo, meaning key events for this
172 * combo will be handled by the next processors in the chain 190 * combo will be handled by the next processors in the chain
@@ -175,3 +193,26 @@ void matrix_scan_combo(void) {
175 dump_key_buffer(true); 193 dump_key_buffer(true);
176 } 194 }
177} 195}
196
197void combo_enable(void) {
198 b_combo_enable = true;
199}
200
201void combo_disable(void) {
202 b_combo_enable = is_active = false;
203 timer = 0;
204 dump_key_buffer(true);
205
206}
207
208void combo_toggle(void) {
209 if (b_combo_enable) {
210 combo_disable();
211 } else {
212 combo_enable();
213 }
214}
215
216bool is_combo_enabled(void) {
217 return b_combo_enable;
218}
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h
index f06d2d345..aab284957 100644
--- a/quantum/process_keycode/process_combo.h
+++ b/quantum/process_keycode/process_combo.h
@@ -58,4 +58,9 @@ bool process_combo(uint16_t keycode, keyrecord_t *record);
58void matrix_scan_combo(void); 58void matrix_scan_combo(void);
59void process_combo_event(uint8_t combo_index, bool pressed); 59void process_combo_event(uint8_t combo_index, bool pressed);
60 60
61void combo_enable(void);
62void combo_disable(void);
63void combo_toggle(void);
64bool is_combo_enabled(void);
65
61#endif 66#endif