diff options
author | Pete Sevander <[email protected]> | 2021-08-06 02:44:57 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-08-06 09:44:57 +1000 |
commit | 7e983796e18e7401c062c158f23966aeb7b1405b (patch) | |
tree | 88d6897d7ca4f6103f03c1941dac6736ba477361 /tmk_core/common/action.c | |
parent | 07553b41f0a03ca6549c09cecf9cd3dec7332346 (diff) | |
download | qmk_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 <[email protected]>
* Update quantum/process_keycode/process_combo.c
Co-authored-by: precondition <[email protected]>
* 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 <[email protected]>
* Update docs/feature_combo.md
Co-authored-by: precondition <[email protected]>
* Update docs/feature_combo.md
Co-authored-by: precondition <[email protected]>
* Update docs/feature_combo.md
Co-authored-by: precondition <[email protected]>
* Update docs/feature_combo.md
Co-authored-by: precondition <[email protected]>
* Change "the" combo action example to "email" example.
* Update docs/feature_combo.md
Co-authored-by: precondition <[email protected]>
* 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 <[email protected]>
* Update docs/feature_combo.md
Co-authored-by: precondition <[email protected]>
Co-authored-by: precondition <[email protected]>
Co-authored-by: Drashna Jaelre <[email protected]>
Diffstat (limited to 'tmk_core/common/action.c')
-rw-r--r-- | tmk_core/common/action.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index bd41d28b66..d19fd2a045 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -55,6 +55,8 @@ __attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrec __attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) { return false; } #endif +__attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) { return true; } + #ifndef TAP_CODE_DELAY # define TAP_CODE_DELAY 0 #endif @@ -106,9 +108,13 @@ void action_exec(keyevent_t event) { #endif #ifndef NO_ACTION_TAPPING - action_tapping_process(record); + if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) { + action_tapping_process(record); + } #else - process_record(&record); + if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) { + process_record(&record); + } if (!IS_NOEVENT(record.event)) { dprint("processed: "); debug_record(record); @@ -206,7 +212,16 @@ void process_record(keyrecord_t *record) { } void process_record_handler(keyrecord_t *record) { +#ifdef COMBO_ENABLE + action_t action; + if (record->keycode) { + action = action_for_keycode(record->keycode); + } else { + action = store_or_get_action(record->event.pressed, record->event.key); + } +#else action_t action = store_or_get_action(record->event.pressed, record->event.key); +#endif dprint("ACTION: "); debug_action(action); #ifndef NO_ACTION_LAYER @@ -994,6 +1009,24 @@ bool is_tap_key(keypos_t key) { * * FIXME: Needs documentation. */ +bool is_tap_record(keyrecord_t *record) { +#ifdef COMBO_ENABLE + action_t action; + if (record->keycode) { + action = action_for_keycode(record->keycode); + } else { + action = layer_switch_get_action(record->event.key); + } +#else + action_t action = layer_switch_get_action(record->event.key); +#endif + return is_tap_action(action); +} + +/** \brief Utilities for actions. (FIXME: Needs better description) + * + * FIXME: Needs documentation. + */ bool is_tap_action(action_t action) { switch (action.kind.id) { case ACT_LMODS_TAP: |