Skip to content

Add per-profile toggle to disable swipe gestures#222

Open
YouHusam wants to merge 6 commits into
TomBadash:masterfrom
YouHusam:Disable-swipe-gestures
Open

Add per-profile toggle to disable swipe gestures#222
YouHusam wants to merge 6 commits into
TomBadash:masterfrom
YouHusam:Disable-swipe-gestures

Conversation

@YouHusam

Copy link
Copy Markdown

Add per-profile toggle to disable swipe gestures

What this does
Adds a per-profile "Enable swipe gestures" toggle for the thumb/gesture button. When swipes are turned off, the gesture button behaves like a real held key instead of a swipe pad:

  • Real key-down / key-up on press and release (no more fixed ~50 ms tap)
  • Cursor stays free while the button is held — the firmware no longer locks movement for swipe detection
  • Per-profile, so a game profile can disable swipes while the desktop keeps them

Why the related input changes
To make held keys actually work in games:

  • Scancode injection — keyboard actions are now injected as hardware scancodes, so they register in titles using Raw Input / DirectInput (Squad, etc.), not just in text boxes
  • Correct extended-key flags — Tab and main Return are no longer wrongly marked extended; the Windows keys, right-hand modifiers, menu key, numpad-divide and the nav cluster are. (Uses MAPVK_VK_TO_VSC + an explicit extended-VK set; the _EX mapping variant was tested and rejected because it drops the 0xE0 prefix for arrow/nav keys.)

Performance

  • In-place swipe/hold swap over the live HID++ connection — toggling the mode re-issues a single CID-reporting write instead of a full reconnect, which on a USB receiver was taking 20+ seconds and dropping button events

Safety / robustness

  • Held-action auto-release backstop (20 s) covers both mouse buttons and keyboard keys now — if an UP event is ever lost (disconnect, profile switch mid-hold), the key/button is released instead of sticking down

Other

  • Per-profile setting with migration to config v10; new profiles inherit the source profile's value
  • zh-CN / zh-TW strings for the new UI
  • Tests added/updated for the migration, event registration, and in-place re-divert

Notes for reviewers

  • The scancode + held-key injection change affects all keyboard actions app-wide, not just the gesture button — intentional, but worth a look.
  • send_key_combo now actually honors its hold_ms (previously the param was ignored and down+up went out in one batch), so one-shot keyboard actions hold for ~50 ms to satisfy polling-based games.

Written with Claude Opus, manually reviewed, the code looks fine to me.
Tested with MX Master 3

YouHusam and others added 6 commits June 27, 2026 17:50
Toggling swipe gestures (or switching profiles that differ on it)
previously called force_reconnect(), which on a USB receiver re-scans
devIdx slots with ~2s-per-timeout retries and could take 20+ seconds,
dropping the device and losing button events during the window.

The only thing that actually changes is one CID-reporting byte, so
set_rawxy_preference() now queues an in-place re-divert applied on the
listener thread instead of reconnecting. Use 0x23 (not 0x03) to disable
RawXY: the flags byte only updates a field when its valid bit is set, so
0x03 left the firmware rawXY state (and the cursor lock) unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The swipe-gestures-enabled flag was a single global setting, so it
couldn't differ between, say, a game profile (held button, cursor free)
and the desktop (swipes). Move it into each profile dict and have the
engine read it from the active profile. Combined with the in-place
re-divert, switching apps now flips swipe<->hold mode instantly.

The flag lived only in the (unreleased) v10 config on this branch, so the
v10 migration is folded to seed it per-profile instead of bumping the
version. Backend exposes get/setProfileSwipeGesturesEnabled; the UI
checkbox now edits the selected profile like button mappings do.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ncodes

Reinstate the 20s safety auto-release that was dropped when held-button
handling was generalized, and extend it to cover held keyboard keys too
(routed through _release_action), so a missed UP event can no longer leave
a key or mouse button stuck down. The press handler arms the timer; the
release handler cancels it.

Complete the _EXTENDED_VKS set (right-hand modifiers, both Windows keys,
the menu key and numpad-divide) so scancode injection sets the
KEYEVENTF_EXTENDEDKEY flag correctly for those keys. Keep MAPVK_VK_TO_VSC
rather than the _EX variant: _EX does not encode the 0xE0 prefix for the
arrow/navigation cluster in practice, which would drop the extended flag.

Also drop the dead is_up local in the event-pairing loop.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant