Mouse wheel scrolling values are not normalized, and vary largely depending on `MouseScrollUnit`
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
0.8.1
## \[Optional\] Relevant system information
Examples built on:
* Linux
* Wasm32 (Chrome)
## What you did
Implemented a mouse scroll event handler.
## What went wrong
Mouse scrolling on Wasm32/Chrome is multiple (20+) times faster than on desktop environment (Linux), providing suboptimal experience. Added custom code to mitigate the difference.
## Additional information
Ideally, some kind of normalization of the event delta (y) should happen on bevy-side.
An UI example (https://github.com/bevyengine/bevy/blob/675607a7e64a760dfb254d8cb401e81ea3898391/examples/ui/ui.rs#L319) currently solves this using a matcher for the event unit:
```rust
let dy = match mouse_wheel_event.unit {
MouseScrollUnit::Line => mouse_wheel_event.y * 20.,
MouseScrollUnit::Pixel => mouse_wheel_event.y,
};
```
Possibly the `mouse_wheel_event.y` could be exposed through a getter (`.normalized_y()`) which would internally do some normalization? Alternatively, it would be good to add a note to `MouseWheel.y` documentation.
Additional links to winit-specific code:
* https://github.com/rust-windowing/winit/blob/9e6f666616341ddd76fc61c6a0ed8dcbf3392a28/src/platform_impl/linux/wayland/seat/pointer/handlers.rs#L210-L220
* https://github.com/rust-windowing/winit/blob/9e6f666616341ddd76fc61c6a0ed8dcbf3392a28/src/platform_impl/linux/wayland/seat/pointer/handlers.rs#L272-L299
Contributor guide
Research direction
Start with the mouse wheel handler in examples/ui/ui.rs and the MouseWheel.y and MouseScrollUnit definitions. Compare the Linux and Wasm32/Chrome behavior against the linked winit handling to establish the unit differences and decide whether an API or documentation change is appropriate. Done means the cross-platform behavior is normalized or the units and required conversion are clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100