Skip to content

Avoid showing a negative default pointer speed - #1515

Merged
lujjjh merged 1 commit into
mainfrom
clamp-default-pointer-speed
Nov 15, 2026
Merged

lujjjh merged 1 commit into
mainfrom
clamp-default-pointer-speed

Conversation

@lujjjh

@lujjjh lujjjh commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Closes #1497.
Closes #487.

Some devices, such as a Magic Mouse, report a pointer resolution outside the range LinearMouse maps to pointer speed. When no speed is configured, Pointer settings converted that resolution directly and showed a negative default speed, such as -0.0086.

The default speed shown for a device is now clamped to the slider's 0–1 range. This only changes what is displayed: the conversion, the configuration format and existing configurations are unchanged, and reverting to system settings still restores the device's original resolution.

Changes

  • Add Device.defaultPointerSpeed(fromPointerResolution:), which clamps the converted speed to 0–1, and use it for Device.pointerSpeed.
  • Add tests for resolutions inside the range, slower ones (shown as 0) and faster ones (shown as 1).

🤖 Generated with Claude Code

Some devices, such as a Magic Mouse, report a pointer resolution above
the range LinearMouse maps to pointer speed, so the default speed shown
in Pointer settings came out negative.

Clamp the default speed shown for a device to 0...1. The conversion and
the configuration are unchanged, and reverting to system settings still
writes the original resolution back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Resolution-derived default pointer speeds are now clamped to the range 0...1. The device uses the clamped value when it reports a pointer resolution. Unit tests cover in-range and out-of-range resolutions.

Changes: Pointer speed defaults

Layer / File(s) Summary
Clamp and test default pointer speed
LinearMouse/Device/Device.swift, LinearMouseUnitTests/Device/DefaultPointerSpeedTests.swift
Device.defaultPointerSpeed(fromPointerResolution:) clamps the converted speed to 0...1. pointerSpeed uses this helper for reported resolutions; its fallback is unchanged. Tests cover values within and outside the range.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: fraschm1998

Merge Risk: Minimal · up to 46cf3

The Pointer settings now show a default speed between 0 and 1 for devices such as the Magic Mouse, instead of a negative value. Configuration and device behavior are unchanged, so merge risk is minimal.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Coding requirements from directly linked issues [#487] and [#1497]:

1. [#487] Default pointer speed for Magic Mouse A1657 must be non-negative. Met. Device.swift adds `Device.defaultPointerSpeed(from…
Confirm the resolution that the reporter's Magic Mouse reports when Apple settings are at maximum speed, and confirm the displayed value for that state. Provide that evidence, or revise the PR description to state that a clamped 0 is the ex…
Passed Passed checks: 3 passed

Check name Status Explanation
Description check Passed The description explains the problem: some devices, such as a Magic Mouse, report a pointer resolution outside the mapped range, which produced a negative default speed. It states that the displayed d…
Out of Scope Changes check Passed All changes support the linked issues. The diff in LinearMouse/Device/Device.swift adds one helper and routes Device.pointerSpeed through it. The fallback path is unchanged. The conversion `pointerS…
Title check Passed The title "Avoid showing a negative default pointer speed" matches the main change. The PR adds Device.defaultPointerSpeed(fromPointerResolution:), clamps the displayed default to 0–1, and uses it in …
Full details: Description check

Explanation

The description explains the problem: some devices, such as a Magic Mouse, report a pointer resolution outside the mapped range, which produced a negative default speed. It states that the displayed default is now clamped to the 0–1 slider range, that conversion and configuration format are unchanged, and it lists the added helper and tests. It matches the changeset.

Full details: Out of Scope Changes check

Explanation

All changes support the linked issues. The diff in LinearMouse/Device/Device.swift adds one helper and routes Device.pointerSpeed through it. The fallback path is unchanged. The conversion pointerSpeed(fromPointerResolution:) and the configuration format are not modified. LinearMouseUnitTests/Device/DefaultPointerSpeedTests.swift covers the new helper only. No unrelated changes were found in the reviewed files.

Full details: Title check

Explanation

The title "Avoid showing a negative default pointer speed" matches the main change. The PR adds Device.defaultPointerSpeed(fromPointerResolution:), clamps the displayed default to 0–1, and uses it in Device.pointerSpeed. This fixes the negative default speed for devices such as the Magic Mouse, as described in linked issues #1497 and #487. The title is specific and concise, and it describes the displayed value that the change affects.

Full details: Linked Issues check

Explanation

Coding requirements from directly linked issues [#487] and [#1497]:

  1. [#487] Default pointer speed for Magic Mouse A1657 must be non-negative. Met. Device.swift adds Device.defaultPointerSpeed(fromPointerResolution:), which clamps pointerSpeed(fromPointerResolution:) to 0 ... 1. Device.pointerSpeed now calls this helper when device.pointerResolution is set. The reported -0.0086 cannot occur through this path.

  2. [#1497] Default speed for Magic Mouse should show a typically positive value, not a negative one. Partly met. The clamp removes the negative value. Per DefaultPointerSpeedTests, resolutions above 1200 (including 1600 and 1995) now display as 0. The issue reports the device at maximum speed in Apple settings. The PR does not show that a maximum Apple setting maps to a resolution in the slower-than-scale range. If it does, the display shows 0 (slowest) for a device set to maximum. That would not match the issue's expectation of a positive value. The evidence does not establish which resolution the reporter's device reports.

Tests cover in-range values, values above the scale (0), and values below the scale (1). They do not cover the reporter's device state.

Resolution

Confirm the resolution that the reporter's Magic Mouse reports when Apple settings are at maximum speed, and confirm the displayed value for that state. Provide that evidence, or revise the PR description to state that a clamped 0 is the expected display for that state and that #1497 is addressed only for the non-negative requirement.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e41abdc and 46cf3cb.

Files selected for processing: 2

  • LinearMouse/Device/Device.swift
  • LinearMouseUnitTests/Device/DefaultPointerSpeedTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@lujjjh lujjjh changed the title The default pointer speed of a Magic Mouse no longer shows as negative Avoid showing a negative default pointer speed Nov 15, 2026
@lujjjh lujjjh added the bug Something isn't working label Nov 15, 2026
@lujjjh
lujjjh merged commit a75a121 into main Nov 15, 2026
2 checks passed
@lujjjh
lujjjh deleted the clamp-default-pointer-speed branch November 15, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Magic Mouse pointer speed is negative ?! Negative pointer speed for Magic Mouse

1 participant