From a10b59880ad24c43feeeebb54c7b5e20a70398ce Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Sun, 15 Jan 2023 23:18:03 +0100 Subject: [PATCH] weird camera --- src/game.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/game.rs b/src/game.rs index 62d2cfe..a69fcac 100644 --- a/src/game.rs +++ b/src/game.rs @@ -57,12 +57,21 @@ pub fn run() { event_loop.run(move |event, _, control_flow| { *control_flow = ControlFlow::Poll; match event { - Event::MainEventsCleared => (), + // Mouse motion Event::DeviceEvent { event: DeviceEvent::MouseMotion{ delta, }, .. } => { state.controls.process_mouse_input(delta.0, delta.1); + return } + // Keyboard input + Event::DeviceEvent { event: DeviceEvent::Key(input), .. } => { + if let Some(key) = input.virtual_keycode { + state.controls.process_keyboard_input(key, input.state); + } + return + } + // Window events Event::WindowEvent { event, .. } => { match event { WindowEvent::CloseRequested => { @@ -70,17 +79,10 @@ pub fn run() { *control_flow = ControlFlow::Exit; return }, - WindowEvent::KeyboardInput { - input: KeyboardInput { - virtual_keycode: Some(key), - state: el_state, .. - }, .. - } => { - state.controls.process_keyboard_input(key, el_state); - }, _ => return } }, + Event::MainEventsCleared => (), _ => return }