Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lighthouse-protocol/src/input/input_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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),
})
);
}
Expand Down
10 changes: 8 additions & 2 deletions lighthouse-protocol/src/input/mouse_event.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};

use crate::Pos;
use crate::{Delta, Pos};

use super::{EventSource, MouseButton};

Expand All @@ -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<f64>,
/// The mouse movement on the lighthouse grid.
pub movement: Delta<f64>,
}