Skip to content

Honor acceleration=0 and inertia=0 in SmoothedScrollingEngine - #1337

Merged
lujjjh merged 3 commits into
linearmouse:mainfrom
YuriNachos:fix/smoothed-scrolling-zero-1303
Aug 7, 2026
Merged

lujjjh merged 3 commits into
linearmouse:mainfrom
YuriNachos:fix/smoothed-scrolling-zero-1303

Conversation

@YuriNachos

Copy link
Copy Markdown
Contributor

Summary

Honor the lower bound of the "Scroll acceleration" and "Inertia" sliders in SmoothedScrollingEngine so that the extreme "off" positions behave as users expect:

  • acceleration = 0 → bypass the rate-dependent pow(normalizedMagnitude, inputExponent) curve (and the acceleration gain, which is already 1 here) so each wheel tick travels a constant distance — velocity becomes strictly proportional to input.
  • inertia = 0 → momentumDecay == 0, so scrolling stops the moment the wheel stops, with no synthetic momentum phase.

Both changes sit behind a clean == Scheme.Scrolling.Smoothed.<range>.lowerBound short-circuit. The non-zero (legacy) code path is byte-for-byte unchanged, so the behavior is trivially reversible.

Root cause: pow(normalizedMagnitude, profile.inputExponent) amplified distance regardless of the acceleration slider, and momentumDecay was clamped to 0.72 ... decayCeiling, leaving residual velocity even at inertia = 0.

Verification

SmoothedScrollingEngine.AxisTuning was widened from private to internal so its velocity/decay contracts can be unit-tested via @testable. 8 focused tests were added:

  • Linearity at acceleration=0 across 4 presets × 2 speeds (v(100) == v(25) * 4, v(50) == v(25) * 2).
  • Boundary just above lowerBound (acceleration=0.001, inertia=0.001) still routes through the legacy curve — pins the == lowerBound contract so it can't silently widen to <=.
  • Legacy curve still active at acceleration=1.2, pinned to golden value 3455.117.
  • momentumDecay == 0 at inertia=0 (three dt values); end-to-end: no momentumBegan ever emitted.
  • Legacy carry preserved at default inertia 0.65 (golden pow(0.89, 0.5)) and at the 0.25 clamp boundary.
  • Mid-range regression checks for both acceleration and inertia.

Gate green: SwiftFormat + SwiftLint clean (0 serious; 95 pre-existing warnings in unrelated files); SmoothedScrollingEngineTests 27/0; full suite 531 tests, 0 failures.

Related issues

Closes #1303.

YuriNachos and others added 2 commits August 6, 2026 23:23
…ngine

When "Scroll acceleration" is at its lower bound (0), bypass the
rate-dependent input curve (and the acceleration gain, which is already
1 here) so each wheel tick travels a constant distance and velocity is
strictly proportional to input. When "Inertia" is at its lower bound
(0), return a momentum decay of 0 so scrolling stops with the wheel and
no synthetic momentum is carried.

Both changes are gated behind a clean `== lowerBound` short-circuit; the
non-zero (legacy) code path is byte-for-byte unchanged, keeping the
behavior trivially reversible. AxisTuning is widened from private to
internal so the velocity/decay contracts can be exercised directly via
@testable unit tests.

Adds 7 tests: linearity at acceleration=0 across 4 presets x 2 speeds,
golden locks for the legacy desiredVelocity and momentumDecay formulas,
momentumDecay==0 at inertia=0, and an end-to-end check that no momentum
phase is emitted. Full suite: 530 tests, 0 failures.

Closes linearmouse#1303.

Co-Authored-By: Claude <[email protected]>
Add testValuesJustAboveLowerBoundStayOnLegacyPath: a value just above the
lower bound (0.001) must stay on the legacy path, turning the ==
lowerBound short-circuit into a verified contract. Catches a future
change of == to <= (or a shifted lowerBound): the rate curve stays active
at acceleration=0.001 (v(100) > v(25)*4) and legacy decay stays positive
at inertia=0.001 (momentumDecay > 0).

Full suite: 531 tests, 0 failures.

Co-Authored-By: Claude <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates SmoothedScrollingEngine to honor the “off” positions of the smooth scrolling acceleration and inertia sliders (issue #1303), ensuring that 0 disables the rate curve / momentum behavior instead of leaving residual effects due to the legacy formulas and clamps.

Changes:

  • Add an acceleration == lowerBound short-circuit in AxisTuning.desiredVelocity(for:) to bypass the rate-dependent pow(normalizedMagnitude, inputExponent) curve and keep velocity strictly proportional to wheel input.
  • Add an inertia == lowerBound short-circuit in AxisTuning.momentumDecay(for:) so momentum decay becomes 0 and scrolling stops immediately when wheel input stops.
  • Widen AxisTuning visibility (still nested) and add focused unit tests covering linearity at acceleration=0, decay behavior at inertia=0, and boundary/legacy-path regressions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
LinearMouse/EventTransformer/SmoothedScrollingEngine.swift Adds explicit lower-bound bypasses for acceleration and inertia in the tuning logic while preserving the legacy path for non-zero values.
LinearMouseUnitTests/EventTransformer/SmoothedScrollingEngineTests.swift Adds unit coverage to lock in the new zero-boundary behavior and ensure legacy behavior remains unchanged when values are non-zero.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lujjjh

lujjjh commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks! I was initially concerned that inertia 0 might make smooth scrolling stop too abruptly, but 0 does reasonably imply that inertia is fully disabled. I think this is reasonable to merge and evaluate based on user feedback.

@lujjjh
lujjjh merged commit 37c0a8e into linearmouse:main Aug 7, 2026
1 check passed
@YuriNachos
YuriNachos deleted the fix/smoothed-scrolling-zero-1303 branch August 10, 2026 13:44
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.

Scroll acceleration and inertia remain active when set to 0

3 participants