qmk_firmware/tests
Pascal Getreuer 73e2ef486a
[Bug][Core] Fix for Flow Tap: fix handling of distinct taps and timer updates. (#25175)
* Flow Tap bug fix.

As reported by @amarz45 and @mwpardue, there is a bug where if two
tap-hold keys are pressed in distinct taps back to back, then Flow Tap
is not applied on the second tap-hold key, but it should be.

In a related bug reported by @NikGovorov, if a tap-hold key is held
followed by a tap of a tap-hold key, then Flow Tap updates its timer on
the release of the held tap-hold key, but it should be ignored.

The problem common to both these bugs is that I incorrectly assumed
`tapping_key` is cleared to noevent once it is released, when actually
`tapping_key` is still maintained for `TAPPING_TERM` ms after release
(for Quick Tap). This commit fixes that. Thanks to @amarz45, @mwpardue,
and @NikGovorov for reporting!

Details:

* Logic for converting the current tap-hold event to a tap is extracted
  to `flow_tap_key_if_within_term()`, which is now invoked also in the
  post-release "interfered with other tap key" case. This fixes the
  distinct taps bug.

* The Flow Tap timer is now updated at the beginning of each call to
  `process_record()`, provided that there is no unsettled tap-hold key
  at that time and that the record is not for a mod or layer switch key.
  By moving this update logic to `process_record()`, it is conceptually
  simpler and more robust.

* Unit tests extended to cover the reported scenarios.

* Fix formatting.

* Revision to fix @NikGovorov's scenario.

The issue is that when another key is pressed while a layer-tap hasn't
been settled yet, the `prev_keycode` remembers the keycode from before
the layer switched. This can then enable Flow Tap for the following key
when it shouldn't, or vice versa.

Thanks to @NikGovorov for reporting!

This commit revises Flow Tap in the following ways:

* The previous key and timer are both updated from `process_record()`.
  This is slightly later in the sequence of processing than before, and
  by this point, a just-settled layer-tap should have taken effect so
  that the keycode from the correct layer is remembered.

* The Flow Tap previous key and timer are updated now also on key
  release events, except for releases of modifiers and held layer
  switches.

* The Flow Tap previous key and timer are now updated together, for
  simplicity. This makes the logic easier to think about.

* A few additional unit tests, including @NikGovorov's scenario as
  "layer_tap_ignored_with_disabled_key_complex."
2025-04-22 09:59:49 +02:00
..
audio [Core] Simplify audio_duration_to_ms() and audio_ms_to_duration(), reduce firmware size by a few bytes. (#21427) 2023-07-08 00:47:16 +10:00
auto_shift Improve test invocation, fix Retro Shift bugs, and add Auto+Retro Shift test cases (#15889) 2023-09-25 12:45:49 +10:00
autocorrect Introduce VERIFY_AND_CLEAR shorthand (#19370) 2022-12-18 21:55:14 +01:00
basic [Core] use keycode_string in unit tests (#25042) 2025-03-21 08:47:22 +01:00
caps_word Ignore the Layer Lock key in Repeat Key and Caps Word. (#25171) 2025-04-19 11:57:00 -07:00
combo [Core] use keycode_string in unit tests (#25042) 2025-03-21 08:47:22 +01:00
housekeeping Add housekeeping execution to unit tests (#22999) 2024-05-13 18:15:52 +01:00
keycode_string [Core] get_keycode_string(): function to format keycodes as strings, for more readable debug logging. (#24787) 2025-03-19 20:45:56 +01:00
layer_lock [Core] Add Layer Lock feature (#23430) 2024-11-21 17:31:54 +11:00
leader Refactor Leader key feature (#19632) 2023-02-13 03:19:02 +11:00
mousekeys Add pointing tests (#24513) 2024-11-23 16:34:32 +00:00
no_tapping Add EOL to non-keyboard files (#24990) 2025-03-06 23:17:51 +00:00
pointing Add pointing tests (#24513) 2024-11-23 16:34:32 +00:00
repeat_key Ignore the Layer Lock key in Repeat Key and Caps Word. (#25171) 2025-04-19 11:57:00 -07:00
secure Introduce VERIFY_AND_CLEAR shorthand (#19370) 2022-12-18 21:55:14 +01:00
tap_dance Tap dance introspection (#24049) 2024-07-06 00:57:54 +01:00
tap_hold_configurations [Bug][Core] Fix for Flow Tap: fix handling of distinct taps and timer updates. (#25175) 2025-04-22 09:59:49 +02:00
test_common Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
tri_layer [Core] Tri Layer Keys (#19795) 2023-02-12 10:23:07 +11:00
unicode Unicode, Unicodemap and UCIS refactor (#21659) 2023-08-27 13:30:19 +10:00