From 9af9fc6e9981fbb582fad9f69ad6bb0d96856b5e Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 7 Jan 2025 15:33:42 +0100 Subject: remove pbr prefix --- client/src/window.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'client/src/window.rs') diff --git a/client/src/window.rs b/client/src/window.rs index ac90f71..8b3ee9e 100644 --- a/client/src/window.rs +++ b/client/src/window.rs @@ -7,7 +7,7 @@ use winit::{ event::{DeviceEvent, ElementState, WindowEvent}, event_loop::ActiveEventLoop, keyboard::{KeyCode, PhysicalKey}, - window::{Window, WindowAttributes, WindowId}, + window::{CursorGrabMode, Window, WindowAttributes, WindowId}, }; pub struct WindowState { @@ -53,6 +53,14 @@ impl ApplicationHandler for WindowState { if event.repeat { return; } + if event.state == ElementState::Pressed { + match event.physical_key { + PhysicalKey::Code(KeyCode::Escape) => { + win.set_cursor_grab(CursorGrabMode::Locked).unwrap(); + } + _ => (), + } + } sta.delta.move_dir += match event.physical_key { PhysicalKey::Code(KeyCode::KeyW) => Vec3::X, PhysicalKey::Code(KeyCode::KeyS) => Vec3::NEG_X, -- cgit v1.2.3-70-g09d2