MouseRewire legacy conditional scroll-direction algorithm archive
Archived: 2026-08-19 (Asia/Shanghai)

This file is bundled for auditability and possible future recovery only. It is
not compiled, linked, loaded, or called by the active MouseRewire input path.
The active algorithm is strict: reverseVertical == true always reverses the
external mouse vertical wheel direction; reverseVertical == false preserves
the incoming event direction. The macOS natural-scrolling preference and raw
HID direction metadata are used only for virtual-HID reinjection compensation,
not to cancel the user's explicit reversal choice.

The previous conditional implementation was:

private func legacyConditionalShouldReverseVerticalForPageDirection(
    event: ScrollEvent,
    profile: ScrollProfile
) -> Bool {
    // Disabling reversal bypasses all physical/system direction inference.
    guard profile.reverseVertical else { return false }

    if let physicalDeltaY = event.physicalDeltaY,
       physicalDeltaY.isFinite,
       physicalDeltaY != 0,
       event.deltaY != 0 {
        // CoreGraphics reports a wheel movement toward the palm as a negative
        // physical delta. Page-scrolling consumers use the opposite sign for
        // moving down, so always deliver the inverse physical direction.
        return (physicalDeltaY < 0) == (event.deltaY < 0)
    }

    return !event.isDirectionInvertedFromDevice
}

Re-enable only after a deliberate product decision, a new regression suite, and
manual verification with an external mouse on every supported output backend.
