Skip to content

MouseScrollUnit handling is unprincipled and inconsistent #24508

@alice-i-cecile

Description

@alice-i-cecile

Problem

Bevy's MouseScrollUnit enum has two values, inherited from winit: Pixel and Line. The ratio between physical mouse movement and reported values is inconsistent across OSes. In some cases, a single click of the mouse wheel may be equal to 1 line or 14 pixels. In other cases, it varies, and I haven't been able to track down good documentation on this.

When responding to these changes, most users should attempt to have consistent values regardless of which enum value is active. Zooming your camera out by a fixed number of lines makes no sense. We have a constant for that at SCROLL_UNIT_CONVERSION_FACTOR, but this is a) not used throughout the engine and b) only a heuristic

The exception here is genuinely text-like variants: text, maybe lists. Those should respect the setting, and scroll an equivalent number of lines.

Proposed solution

  1. Move this value to a resource to make it dyamically configurable.
  2. Audit internal uses and always access that resource value.

Future work

Find some way to check this from the OS, and prepopulate that resource with that value. Feature-gate that if it introduces additional dependencies: this is a very minor concern.

This appears to be platform-specific in complex ways. 3 should definitely be left to its own PR, and there's a very real chance that the actual fix for it is upstream in winit. My research suggests that there's two conversion steps here: notches -> lines, and lines -> pixels.

We may actually want to cut the MouseScrollUnit out completely, and only report a single normalized value, while having a separate message stream for completely raw values.

Previous discussions: rust-windowing/winit#3493, #5823.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-InputPlayer input via keyboard, mouse, gamepad, and moreC-BugAn unexpected or incorrect behaviorC-Code-QualityA section of code that is hard to understand or changeD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Needs SME Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions