rust-windowing / rust-windowing/winit

Mouse Motion incorrect when using Remote Desktop

Open
#2,884 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

DS - win32
Dominant language
Rust
Stars
6.2k
Forks
1.3k
Avg merge
2d 19h
Merged PRs (30d)
9

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided test program on Windows 11 locally and through Remote Desktop, then compare the reported DeviceEvent::MouseMotion deltas. The issue is done when remote-session mouse movement reports usable deltas comparable to local movement and the regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
desktop-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.