Begin implement input management
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 8m4s

This commit is contained in:
Florian RICHER 2025-05-25 23:48:02 +02:00
parent 2c3392c3ea
commit c4c691c4dd
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
3 changed files with 99 additions and 1 deletions

View file

@ -16,6 +16,7 @@ use winit::event::WindowEvent;
use winit::event_loop::ActiveEventLoop;
use winit::window::WindowId;
use super::input::InputState;
use super::vulkan_context::VulkanContext;
pub struct App {
@ -24,6 +25,7 @@ pub struct App {
gui: HashMap<WindowId, Gui>,
scene: Option<Scene>,
clear_color: [f32; 3],
input_state: InputState,
}
impl From<VulkanoContext> for App {
@ -34,6 +36,7 @@ impl From<VulkanoContext> for App {
gui: HashMap::new(),
scene: None,
clear_color: [0.0, 0.0, 0.0],
input_state: InputState::default(),
}
}
}
@ -80,7 +83,10 @@ impl ApplicationHandler for App {
fn window_event(&mut self, event_loop: &ActiveEventLoop, id: WindowId, event: WindowEvent) {
let renderer = self.vulkano_windows.get_renderer_mut(id).unwrap();
let gui = self.gui.get_mut(&id).unwrap();
gui.update(&event);
if !gui.update(&event) {
self.input_state.process_event(&event);
}
match event {
WindowEvent::CloseRequested => {
@ -94,6 +100,8 @@ impl ApplicationHandler for App {
renderer.resize();
}
WindowEvent::RedrawRequested => {
self.input_state.update();
let acquire_future = renderer.acquire(None, |_| {}).unwrap();
let mut builder = AutoCommandBufferBuilder::primary(