diff --git a/lighthouse-protocol/src/input/input_event.rs b/lighthouse-protocol/src/input/input_event.rs index fa2d7f2..0fe5fd8 100644 --- a/lighthouse-protocol/src/input/input_event.rs +++ b/lighthouse-protocol/src/input/input_event.rs @@ -53,7 +53,7 @@ impl InputEvent { mod tests { use serde_json::json; - use crate::{EventSource, GamepadAxis2DEvent, GamepadAxisEvent, GamepadButtonEvent, GamepadControlEvent, GamepadEvent, InputEvent, KeyEvent, KeyModifiers, MouseButton, MouseEvent, Pos, Vec2}; + use crate::{Delta, EventSource, GamepadAxis2DEvent, GamepadAxisEvent, GamepadButtonEvent, GamepadControlEvent, GamepadEvent, InputEvent, KeyEvent, KeyModifiers, MouseButton, MouseEvent, Pos, Vec2}; #[test] fn key_event() { @@ -88,15 +88,24 @@ mod tests { "type": "mouse", "source": 1, "button": "left", + "down": true, + "pointerLocked": false, "pos": { "x": 2, "y": 4, }, + "movement": { + "x": 6, + "y": -3, + }, })).unwrap(), InputEvent::Mouse(MouseEvent { source: EventSource::Int(1), button: MouseButton::Left, + down: true, + pointer_locked: false, pos: Pos::new(2.0, 4.0), + movement: Delta::new(6.0, -3.0), }) ); } diff --git a/lighthouse-protocol/src/input/mouse_event.rs b/lighthouse-protocol/src/input/mouse_event.rs index d09ece0..9d61462 100644 --- a/lighthouse-protocol/src/input/mouse_event.rs +++ b/lighthouse-protocol/src/input/mouse_event.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -use crate::Pos; +use crate::{Delta, Pos}; use super::{EventSource, MouseButton}; @@ -10,8 +10,14 @@ use super::{EventSource, MouseButton}; pub struct MouseEvent { /// The client identifier. pub source: EventSource, + /// Whether the button was pressed. + pub down: bool, + /// Whether the mouse pointer was locked (e.g. to the frontend's canvas) + pub pointer_locked: bool, /// The mouse button. pub button: MouseButton, - /// The mouse position. + /// The mouse position on the lighthouse grid. pub pos: Pos, + /// The mouse movement on the lighthouse grid. + pub movement: Delta, }