Skip to content

Allow swipe recording after a provisional long press - #1392

Closed
lamhoangtung wants to merge 1 commit into
linearmouse:mainfrom
lamhoangtung:codex/fix-swipe-recording-after-hold
Closed

lamhoangtung wants to merge 1 commit into
linearmouse:mainfrom
lamhoangtung:codex/fix-swipe-recording-after-hold

Conversation

@lamhoangtung

Copy link
Copy Markdown
Contributor

When a user holds a button for 500 ms before dragging in the advanced Button Mappings recorder, the preview becomes Long Press and all later movement is ignored. This makes recording a swipe require racing the long-press timer.

Allow a swipe to replace the provisional long press while the button remains held, matching the recorder's existing behavior for ordered button and wheel inputs. Release without sufficient movement still records Long Press; committed swipe and released outcomes remain unchanged. Runtime recognition is unchanged.

Closes #1391.

Validation: 21 ButtonMappingRecordingEngineTests passed with xcodebuild test on macOS. Regression tests cover all four directions with Logitech Control 0xC3, accumulated movement after the long-press threshold, and movement after release. SwiftFormat and SwiftLint passed for the changed files.

guard !pressedButtons.isEmpty,
wheelMapping == nil,
recognition == nil else {
recognition == nil || recognition == .longPress else {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also allows a long press to become a swipe after the trigger button has already been released, as long as another button remains held.

For example:

  1. Hold A, then press and hold B until Long Press is recognized.
  2. Release B while keeping A held.
  3. Move the pointer past the swipe threshold.

The recorder now produces “hold A + swipe B,” even though B was already released before the movement.

Could we require all buttons participating in the recorded trigger to remain held before allowing this reclassification, or freeze the outcome on the first release? The new release test only covers a single button; ordered and simultaneous combinations with both release orders would help cover this case.

lujjjh added a commit that referenced this pull request Oct 3, 2026
Allow swipes to replace the recorder’s provisional long press while all
participating buttons remain held. Releasing any participating button
prevents further swipe reclassification. Runtime recognition is
unchanged.

Supersedes #1392 by @lamhoangtung and addresses its review feedback on
partially released button combinations.

Closes #1391.

Validation: all 972 tests pass, including coverage for ordered and
simultaneous combinations in both release orders. SwiftFormat and
SwiftLint pass.

Co-authored-by: lamhoangtung <[email protected]>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved swipe and long-press recognition in button mappings. A swipe
can now take precedence over a provisional long press while the
participating buttons remain held; releasing a button before the swipe
is recognized preserves the long press.
* Swipes continue to trigger when no long-press action is configured or
the setting is **Auto**. Once a long press or swipe is recognized, later
movement no longer changes the result.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: lamhoangtung <[email protected]>
@lujjjh

lujjjh commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Closing this in favor of #1413, with you credited as a co-author.

@lujjjh lujjjh closed this Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Button Mappings recorder cannot record swipes after provisional long press

2 participants