summaryrefslogtreecommitdiff
path: root/client/src/window.rs
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/window.rs')
-rw-r--r--client/src/window.rs32
1 files changed, 13 insertions, 19 deletions
diff --git a/client/src/window.rs b/client/src/window.rs
index dcfb1e8..665aa01 100644
--- a/client/src/window.rs
+++ b/client/src/window.rs
@@ -96,18 +96,15 @@ impl ApplicationHandler for WindowState {
return;
}
if event.state == ElementState::Pressed {
- match event.physical_key {
- PhysicalKey::Code(KeyCode::Escape) => {
- win.set_cursor_grab(if self.lock {
- CursorGrabMode::None
- } else {
- CursorGrabMode::Locked
- })
- .unwrap();
- self.lock = !self.lock;
- win.set_cursor(CursorIcon::Default);
- }
- _ => (),
+ if let PhysicalKey::Code(KeyCode::Escape) = event.physical_key {
+ win.set_cursor_grab(if self.lock {
+ CursorGrabMode::None
+ } else {
+ CursorGrabMode::Locked
+ })
+ .unwrap();
+ self.lock = !self.lock;
+ win.set_cursor(CursorIcon::Default);
}
}
sta.input_state.move_dir += match event.physical_key {
@@ -141,14 +138,11 @@ impl ApplicationHandler for WindowState {
event: winit::event::DeviceEvent,
) {
if let Some((_win, sta)) = &mut self.window {
- match event {
- DeviceEvent::MouseMotion { delta } => {
- if self.lock {
- sta.input_state.mouse_acc.x += delta.0 as f32;
- sta.input_state.mouse_acc.y += delta.1 as f32;
- }
+ if let DeviceEvent::MouseMotion { delta } = event {
+ if self.lock {
+ sta.input_state.mouse_acc.x += delta.0 as f32;
+ sta.input_state.mouse_acc.y += delta.1 as f32;
}
- _ => (),
}
}
}