Chrome/rust/wasm32/winit : grab cursor : how to detect movement

Context:

  1. Rust/wasm32 running on Chrome

  2. We are using winit

  3. We are building fps game and successfully grab cursor via Window in winit::window - Rust

  4. We try to print out the mouse movement via:

            WindowEvent::CursorMoved { position, .. } => {
                self.camera.borrow_mut().cursor_moved(position.x, position.y);
            }

understandably, position (type PhysicalPosition) does not change after cursor grab

What should I be monitoring ? there is MouseInput (fur button clicks) and MouseWheel (for wheel), but no MouseMoved event.

Thanks!

I wouldn't use WASM for mouse movement detection/monitoring, I would use JS (easier and you can do alot) and you can simply send the details to wasm (x,y, event)

I think the solution is DeviceEvent in winit::event - Rust but I need to figure uot how to receive DeviceEvents

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.