Repository navigation
Require two fingers to scroll on Magic Mouse - #1382
corinna000 wants to merge 1 commit into
Conversation
The Magic Mouse scrolls on any single-finger contact by design, unlike a trackpad which requires two fingers. This causes frequent accidental scrolling from incidental palm/finger contact - a long-standing complaint with no supported fix from Apple. Adds an opt-in "Require two fingers to scroll" toggle (Scrolling settings, shown only when a Magic Mouse is selected) that gates scrolling on live finger count, read via Apple's private, undocumented MultitouchSupport.framework - the only way to get multitouch contact data off the device. - MultitouchSupportBridge: dlopen/dlsym wrapper around the private framework. Fails safe (returns false/nil) if any symbol is missing on a future macOS release, so a broken bridge disables the feature instead of breaking scrolling. - MagicMouseTouchTracker: attaches/detaches as DeviceManager reports the Magic Mouse connecting/disconnecting, exposes a thread-safe live finger count. - RequireTwoFingerScrollTransformer: suppresses scroll events with fewer than two fingers. Gates on live finger count for every event rather than trusting CGMomentumScrollPhase - the Magic Mouse tags most actively-touched scroll ticks (not just the post-lift glide) as "momentum changed", so trusting that field let most one-finger scrolling through unfiltered. Tracks its own "was this gesture qualified with two fingers" state instead, so a real two-finger scroll still glides to a natural stop after lift-off. - Device.isAppleMagicMouse: public accessor distinguishing the Magic Mouse from any other mouse, reusing the existing private vendor/product-ID check. - New requireTwoFingerScroll config field (Configuration.d.ts, regenerated JSON schema, Scheme.Scrolling), off by default. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019oS2EdqGSptPH8Mc21fe4z
|
@lujjjh What do I need to do to push this forward? Thank you! |
|
Thanks for working on this! At first glance, I’m also thinking about how this should be modeled in LinearMouse. |
|
I tested this on a physical Magic Mouse. On my end, two-finger scrolling is inconsistent: it often fails to start, or loses momentum. Once scrolling starts, lifting one finger can still work normally, so it does not seem to be simply related to releasing both fingers together. I also haven’t settled on how this should be modeled in the configuration or what its shape should be yet. We can continue discussing that. |
|
Thank you for the comments!
|
What
Adds an opt-in "Require two fingers to scroll" toggle (Scrolling settings, only shown when a Magic Mouse is the selected device) that
requires two fingers on the touch surface before scrolling starts, matching trackpad behavior instead of the Magic Mouse's default of scrolling
on any single-finger contact.
Off by default - existing behavior is unchanged unless a user opts in.
Why
The Magic Mouse scrolling on any single touch (rather than requiring two fingers, like a trackpad) causes frequent accidental scrolling from
incidental palm/finger contact. This has come up before with no resolution:
How
There's no public API for reading finger-count data off a Magic Mouse. This uses Apple's private, undocumented
MultitouchSupport.framework-the same one BetterTouchTool, Mos, and the (now largely unmaintained) MagicPrefs have historically relied on for the same purpose. I want to
flag this clearly up front since I know
IOHIDManager/public APIs are preferred where possible (per the discussion on #200) - I don't believea public alternative exists for multitouch contact data on this device, but happy to be corrected.
Given the private-API dependency, this is designed to fail safe everywhere:
MultitouchSupportBridgeresolves every symbol viadlopen/dlsymand reportsisAvailable = falseif anything is missing (e.g. on afuture macOS release), rather than crashing.
RequireTwoFingerScrollTransformerfails open (never blocks scrolling) whenever the finger-count signal isn't available.One correctness detail worth calling out for review: gating is based on live finger count for every scroll event, deliberately not on
CGMomentumScrollPhase. A trackpad reserves that field for the post-lift inertial tail, but the Magic Mouse has no real gesture-phase conceptmost one-finger scrolling through unfiltered during development. Instead, the transformer tracks its own "was this gesture qualified with two
fingers" state (with a time-gap fallback for when the device never sends an explicit momentum-end), so a real two-finger scroll still glides to
a natural stop after lift-off without that grace period leaking into unrelated one-finger scrolling later.
Testing
RequireTwoFingerScrollTransformercovering suppression, pass-through, the fail-open path, synthetic-event bypass, andthe gesture-qualification/momentum-glide logic (including the regression this exists to prevent - trusting
momentumPhasealone for a fresh,unqualified gesture).
after lifting fingers mid-gesture.
Config
New
scrolling.requireTwoFingerScrollboolean field (documented inConfiguration.d.ts, regenerated JSON schema), off by default.🤖 Generated with Claude Code