Skip to content

Require two fingers to scroll on Magic Mouse - #1382

Open
corinna000 wants to merge 1 commit into
linearmouse:mainfrom
corinna000:magic-mouse-two-finger-scroll
Open

corinna000 wants to merge 1 commit into
linearmouse:mainfrom
corinna000:magic-mouse-two-finger-scroll

Conversation

@corinna000

Copy link
Copy Markdown

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 believe
a 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:

  • MultitouchSupportBridge resolves every symbol via dlopen/dlsym and reports isAvailable = false if anything is missing (e.g. on a
    future macOS release), rather than crashing.
  • RequireTwoFingerScrollTransformer fails 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 concept

  • empirically it tags most actively-touched scroll ticks (not just the glide after lift-off) as "momentum changed". Trusting that field let
    most 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

  • New unit tests for RequireTwoFingerScrollTransformer covering suppression, pass-through, the fail-open path, synthetic-event bypass, and
    the gesture-qualification/momentum-glide logic (including the regression this exists to prevent - trusting momentumPhase alone for a fresh,
    unqualified gesture).
  • Full existing suite still green.
  • Manually verified against a physical Magic Mouse: one-finger scroll blocked, two-finger scroll works, two-finger scroll glides naturally
    after lifting fingers mid-gesture.

Config

New scrolling.requireTwoFingerScroll boolean field (documented in Configuration.d.ts, regenerated JSON schema), off by default.

🤖 Generated with Claude Code

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
@corinna000

Copy link
Copy Markdown
Author

@lujjjh What do I need to do to push this forward? Thank you!

@lujjjh

lujjjh commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Thanks for working on this!

At first glance, firstExternalDevice() may have an issue since an external Magic Trackpad could also be picked up there. If all goes well, I’ll test this on a Magic Mouse and do a more detailed review tomorrow.

I’m also thinking about how this should be modeled in LinearMouse. requireTwoFingerScroll feels a bit too specific. Maybe Magic Mouse gestures like one finger and two fingers should be treated as inputs that can be mapped to different actions or behaviors. I’d like to think a bit more about the scope here.

@lujjjh

lujjjh commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

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.

@corinna000

Copy link
Copy Markdown
Author

Thank you for the comments!

  1. I don't have an external Magic Trackpad for testing, but your comment makes a lot of sense. I'll see if there's a way to gate the code so it's only on the Magic Mouse.
  2. The surface of the Magic Mouse is multi-touch, so one risk of accepting this PR is that if you wanted to support pinch/zoom functionality in the future then change may require a refactor.
  3. The Magic Mouse I'm testing on is the old, battery driven model. It's entirely possible the newer models have different behaviors, which if true would be sad. Short of my finding a newer model I'm not sure how to move forward. But I can partially confirm your observation by adding this clarification: Once a two-finger scroll is started it no longer counts the number of mice on the device, so you can lift your second finger and still scroll until the first finger (so zero contact with the mouse) remains. This may explain some of the jank.

This branch has not been deployed

No deployments
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.

2 participants