aboutsummaryrefslogtreecommitdiff
path: root/quantum/quantum.c
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/quantum.c
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/quantum.c')
-rw-r--r--quantum/quantum.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 3329c1146..d17338871 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -143,7 +143,13 @@ void reset_keyboard(void) {
143} 143}
144 144
145/* Convert record into usable keycode via the contained event. */ 145/* Convert record into usable keycode via the contained event. */
146uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) { return get_event_keycode(record->event, update_layer_cache); } 146uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
147#ifdef COMBO_ENABLE
148 if (record->keycode) { return record->keycode; }
149#endif
150 return get_event_keycode(record->event, update_layer_cache);
151}
152
147 153
148/* Convert event into usable keycode. Checks the layer cache to ensure that it 154/* Convert event into usable keycode. Checks the layer cache to ensure that it
149 * retains the correct keycode after a layer change, if the key is still pressed. 155 * retains the correct keycode after a layer change, if the key is still pressed.
@@ -169,6 +175,18 @@ uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
169 return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key); 175 return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key);
170} 176}
171 177
178/* Get keycode, and then process pre tapping functionality */
179bool pre_process_record_quantum(keyrecord_t *record) {
180 if (!(
181#ifdef COMBO_ENABLE
182 process_combo(get_record_keycode(record, true), record) &&
183#endif
184 true)) {
185 return false;
186 }
187 return true; // continue processing
188}
189
172/* Get keycode, and then call keyboard function */ 190/* Get keycode, and then call keyboard function */
173void post_process_record_quantum(keyrecord_t *record) { 191void post_process_record_quantum(keyrecord_t *record) {
174 uint16_t keycode = get_record_keycode(record, false); 192 uint16_t keycode = get_record_keycode(record, false);
@@ -254,9 +272,6 @@ bool process_record_quantum(keyrecord_t *record) {
254#ifdef LEADER_ENABLE 272#ifdef LEADER_ENABLE
255 process_leader(keycode, record) && 273 process_leader(keycode, record) &&
256#endif 274#endif
257#ifdef COMBO_ENABLE
258 process_combo(keycode, record) &&
259#endif
260#ifdef PRINTING_ENABLE 275#ifdef PRINTING_ENABLE
261 process_printer(keycode, record) && 276 process_printer(keycode, record) &&
262#endif 277#endif