Best way to implement a 3d fly control that locks the mouse in position

Hi,
I'm using three-d and want to create a 3d camera fly control which hides the mouse and keeps it in the same position that it was when you first clicked the mouse button down. So far I've implemented the rest of the fly control but need a way to hide the mouse and keep it locked in position. I tried to use rdev to teleport the mouse back to a saved position, but rdev uses window coords whereas three-d sends coords relative to the window. This also means that, in a dual monitor setup, rdev will always teleport the mouse to the primary monitor. What is the best way to implement this that will cause the fewest issues?
Here is the code I have so far for handling mouse move and mouse down events (I have removed my attempt at using rdev):

for event in events.iter_mut() {
    match event {
        Event::MouseMotion {
            delta,
            button,
            handled,
            ..
        } => {
            if !*handled && button.is_some() {
                if let Some(b) = button {
                    if let MouseButton::Right = b {
                        // horizontal
                        *handled = self.handle_action(
                            camera,
                            CameraAction::Yaw {
                                speed: std::f32::consts::PI / 1800.0,
                            },
                            -delta.0 as f32,
                        );
                        // vertical
                        *handled |= self.handle_action(
                            camera,
                            CameraAction::Pitch {
                                speed: std::f32::consts::PI / 1800.0,
                            },
                            -delta.1 as f32,
                        );
                        change |= *handled;
                    }
                }
            }
        }

        Event::MousePress {
            button,
            position,
            modifiers: _,
            handled: _,
        } => {
            if let MouseButton::Right = button {
                self.right_mouse_down = true;
            }
        }
        Event::MouseRelease {
            button,
            position: _,
            modifiers: _,
            handled: _,
        } => {
            if let MouseButton::Right = button {
                self.right_mouse_down = false;
            }
        }

        ...

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.