rust-windowing / winit

Window handling library in pure Rust
https://docs.rs/winit/
Apache License 2.0
4.86k stars 909 forks source link

Windows WSL2 GUI MouseMotion returning position instead of delta #2281

Open gtosh4 opened 2 years ago

gtosh4 commented 2 years ago

When running a bevy program in WSL2, the MouseMotion event appears to be returning the position:

[src/game/movement.rs:94] event.delta = Vec2(
    4144.0,
    1811.0,
)
[src/game/movement.rs:94] event.delta = Vec2(
    4148.0,
    1807.0,
)

And the values are never negative.

Whereas, when running the same program in native Windows, I see the correct deltas:

[src\game\movement.rs:94] event.delta = Vec2(
    0.0,
    2.0,
)
[src\game\movement.rs:94] event.delta = Vec2(
    0.0,
    -1.0,
)

I presume this is a winit issue, as bevy appears to just be forwarding the values (see bevy_winit); however, I'm not sure so I apologize if this is incorrect.

maroider commented 2 years ago

I suspect WSL2 is incorrectly reporting mouse motion to us through X11 or Wayland.

gtosh4 commented 2 years ago

Do you know who/how to track this down so that I may forward the issue? Do you think it might be here: https://github.com/microsoft/wslg ? Also, I could use some help gathering some additional context to help them out - is there a particular API or system I should specify that is used to help them figure out what's wrong?

maroider commented 2 years ago

First, you have to figure out whether it's happening with X11 or Wayland. Then, you can track down the places where we emit DeviceEvent::MouseMotion in the relevant backend to find the API that we get bad data through.