-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
MouseScrollUnit handling is unprincipled and inconsistent #24508
Copy link
Copy link
Open
Labels
A-InputPlayer input via keyboard, mouse, gamepad, and morePlayer input via keyboard, mouse, gamepad, and moreC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed uponThis work is generally agreed upon
Metadata
Metadata
Assignees
Labels
A-InputPlayer input via keyboard, mouse, gamepad, and morePlayer input via keyboard, mouse, gamepad, and moreC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed uponThis work is generally agreed upon
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
StatusShow more project fields
Needs SME Triage
Problem
Bevy's
MouseScrollUnitenum has two values, inherited fromwinit:PixelandLine. 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
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.