qmk_firmware/quantum
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 Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
backlight Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
bootmagic
connection Implement connection keycode logic (#25176) 2025-04-21 22:27:56 +01:00
debounce Consolidate timer_elapsed implementations (#24830) 2025-01-19 17:07:11 +00:00
encoder/tests
keymap_extras [CI] Regenerate Files (#24772) 2025-01-01 02:22:28 +00:00
led_matrix Allow for disabling EEPROM subsystem entirely. (#25173) 2025-04-19 20:20:00 +01:00
logging Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
midi
nvm Implement connection keycode logic (#25176) 2025-04-21 22:27:56 +01:00
os_detection/tests Merge remote-tracking branch 'origin/master' into develop 2025-01-29 19:28:06 +00:00
painter Created SH1107 driver for quantum painter (#24724) 2025-02-17 08:41:07 +11:00
pointing_device [chore]: move and rename mouse/scroll min/max defines (#25141) 2025-04-13 18:36:13 +02:00
process_keycode Implement connection keycode logic (#25176) 2025-04-21 22:27:56 +01:00
rgb_matrix Allow for disabling EEPROM subsystem entirely. (#25173) 2025-04-19 20:20:00 +01:00
rgblight Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
send_string Consolidate send_string implementations. (#24817) 2025-01-21 08:24:39 +11:00
sequencer Consolidate timer_elapsed implementations (#24830) 2025-01-19 17:07:11 +00:00
split_common Add EOL to non-keyboard files (#24990) 2025-03-06 23:17:51 +00:00
unicode Allow for disabling EEPROM subsystem entirely. (#25173) 2025-04-19 20:20:00 +01:00
wear_leveling Add EOL to non-keyboard files (#24990) 2025-03-06 23:17:51 +00:00
action.c [Bug][Core] Fix for Flow Tap: fix handling of distinct taps and timer updates. (#25175) 2025-04-22 09:59:49 +02:00
action.h [Core] Flow Tap tap-hold option to disable HRMs during fast typing (#25125) 2025-04-14 09:46:24 -07:00
action_code.h
action_layer.c
action_layer.h
action_tapping.c [Bug][Core] Fix for Flow Tap: fix handling of distinct taps and timer updates. (#25175) 2025-04-22 09:59:49 +02:00
action_tapping.h [Bug][Core] Fix for Flow Tap: fix handling of distinct taps and timer updates. (#25175) 2025-04-22 09:59:49 +02:00
action_util.c Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
action_util.h
basic_profiling.h
bits.h Fix path typo related RP2040 (#25069) 2025-03-28 21:03:59 +11:00
bitwise.c
bitwise.h
caps_word.c
caps_word.h
color.c Rename RGB and HSV structs (#24471) 2024-10-12 00:10:02 +01:00
color.h Rename RGB and HSV structs (#24471) 2024-10-12 00:10:02 +01:00
command.c Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
command.h
crc.c
crc.h
debounce.h
deferred_exec.c
deferred_exec.h
digitizer.c
digitizer.h
dip_switch.c Fix missing wait.h include in Dip Switch Map (#24863) 2025-01-25 03:11:38 +00:00
dip_switch.h
dynamic_keymap.c Allow for disabling EEPROM subsystem entirely. (#25173) 2025-04-19 20:20:00 +01:00
dynamic_keymap.h Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
eeconfig.c Implement connection keycode logic (#25176) 2025-04-21 22:27:56 +01:00
eeconfig.h Implement connection keycode logic (#25176) 2025-04-21 22:27:56 +01:00
encoder.c
encoder.h
haptic.c Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
haptic.h Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
joystick.c Joystick: add support for 8-way hat switch (#24515) 2024-11-09 14:10:10 -08:00
joystick.h Joystick: add support for 8-way hat switch (#24515) 2024-11-09 14:10:10 -08:00
keyboard.c Implement connection keycode logic (#25176) 2025-04-21 22:27:56 +01:00
keyboard.h
keycode.h
keycode_config.c
keycode_config.h Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
keycode_string.c [Core] get_keycode_string(): function to format keycodes as strings, for more readable debug logging. (#24787) 2025-03-19 20:45:56 +01:00
keycode_string.h [Core] get_keycode_string(): function to format keycodes as strings, for more readable debug logging. (#24787) 2025-03-19 20:45:56 +01:00
keycodes.h Community modules (#24848) 2025-02-26 22:25:41 +11:00
keymap_common.c
keymap_common.h
keymap_introspection.c Community modules (#24848) 2025-02-26 22:25:41 +11:00
keymap_introspection.h
layer_lock.c Review fixes for layer lock feature (#24627) 2024-11-21 13:02:49 +00:00
layer_lock.h Review fixes for layer lock feature (#24627) 2024-11-21 13:02:49 +00:00
leader.c Add leader_add_user callback (#24266) 2025-01-01 23:12:58 -08:00
leader.h Add leader_add_user callback (#24266) 2025-01-01 23:12:58 -08:00
led.c
led.h
led_tables.c
led_tables.h
main.c
matrix.c
matrix.h
matrix_common.c
modifiers.h
mousekey.c
mousekey.h
os_detection.c Community modules (#24848) 2025-02-26 22:25:41 +11:00
os_detection.h Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
pointing_device_internal.h
programmable_button.c
programmable_button.h
quantum.c Implement connection keycode logic (#25176) 2025-04-21 22:27:56 +01:00
quantum.h [Core] get_keycode_string(): function to format keycodes as strings, for more readable debug logging. (#24787) 2025-03-19 20:45:56 +01:00
quantum_keycodes.h [Feature] Add keycode PDF(layer) to set the default layer in EEPROM (#24630) 2024-11-23 10:09:34 +00:00
quantum_keycodes_legacy.h
raw_hid.h
repeat_key.c
repeat_key.h
ring_buffer.h
secure.c
secure.h
steno_keycodes.h
sync_timer.c
sync_timer.h
tri_layer.c
tri_layer.h
util.h [Core] quantum: util: add bit and bitmask helpers (#24229) 2024-10-12 18:48:00 +02:00
variable_trace.c
variable_trace.h
via.c Allow for disabling EEPROM subsystem entirely. (#25173) 2025-04-19 20:20:00 +01:00
via.h Non-volatile memory data repository pattern (#24356) 2025-03-21 23:38:34 +11:00
virtser.h
wpm.c
wpm.h