winit
winit copied to clipboard
Mouse Motion incorrect when using Remote Desktop
winit
Version 0.28.6
Here is a small app that just prints the Mouse Motion. There is a large discrepancy between running this app locally or on a remote machine via remote desktop. See output below:
When using remote desktop, these values for even the smallest movement is orders of magnitude larger.
Here is the test program:
use winit::{
event::{DeviceEvent, Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
fn main() {
let event_loop = EventLoop::new();
let _window = WindowBuilder::new().build(&event_loop).unwrap();
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
match event {
Event::DeviceEvent { event, .. } => match event {
DeviceEvent::MouseMotion { delta } => {
println!("Mouse moved by {:?}", delta);
}
_ => (),
},
Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
_ => (),
},
_ => (),
}
});
}
Output locally:
Mouse moved by (-1.0, 0.0)
Mouse moved by (-1.0, 0.0)
Mouse moved by (-1.0, -1.0)
Mouse moved by (-1.0, 0.0)
Mouse moved by (-1.0, 0.0)
Mouse moved by (0.0, -1.0)
Mouse moved by (-1.0, 0.0)
Mouse moved by (-1.0, -1.0)
Output when running on remote machine via Remote Desktop:
Mouse moved by (14150.0, 8476.0)
Mouse moved by (14163.0, 8453.0)
Mouse moved by (14163.0, 8430.0)
Mouse moved by (14163.0, 8430.0)
Mouse moved by (14163.0, 8430.0)
Mouse moved by (14163.0, 8408.0)
Mouse moved by (14163.0, 8408.0)
Mouse moved by (14163.0, 8385.0)
Mouse moved by (14163.0, 8385.0)
Mouse moved by (14176.0, 8385.0)
Mouse moved by (14176.0, 8385.0)
Mouse moved by (14176.0, 8385.0)
For context I am working on a 3D game using the Bevy Engine, which uses the winit
crate. Camera movement is completely broken when using the app over remote desktop, making it unusable. The root cause is incorrect mouse delta values.
I am using Remote Desktop from a Mac M1, remoting into a Windows 11 machine.