From 8c1406f7a42822d1b020cc672ed99d02eb34d22f Mon Sep 17 00:00:00 2001 From: tcmal Date: Sun, 25 Aug 2024 17:44:22 +0100 Subject: feat(render-bsp): process into inputmanager --- examples/render-bsp/Cargo.toml | 2 ++ examples/render-bsp/src/main.rs | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/render-bsp/Cargo.toml b/examples/render-bsp/Cargo.toml index 82e9cb5..dccc9c2 100644 --- a/examples/render-bsp/Cargo.toml +++ b/examples/render-bsp/Cargo.toml @@ -6,6 +6,8 @@ edition = "2018" [dependencies] stockton-render = { path = "../../stockton-render", features = ["vulkan"] } +stockton-input = { path = "../../stockton-input" } +stockton-input-codegen = { path = "../../stockton-input-codegen" } stockton-types = { path = "../../stockton-types" } stockton-levels = { path = "../../stockton-levels" } winit = "^0.21" diff --git a/examples/render-bsp/src/main.rs b/examples/render-bsp/src/main.rs index b18d7f2..96d5e42 100644 --- a/examples/render-bsp/src/main.rs +++ b/examples/render-bsp/src/main.rs @@ -17,6 +17,10 @@ //! Renders ./example.bsp +use stockton_input::{Axis, InputManager}; +#[macro_use] +extern crate stockton_input_codegen; +use std::collections::BTreeMap; use winit::{event::Event, event_loop::EventLoop, window::WindowBuilder}; use stockton_levels::{prelude::*, q3::Q3BSPFile}; @@ -25,6 +29,18 @@ use stockton_render::{ }; use stockton_types::Session; +#[derive(InputManager, Default, Clone, Debug)] +struct MovementInputs { + #[axis] + x: Axis, + + #[axis] + y: Axis, + + #[axis] + z: Axis, +} + fn main() { // Initialise logger simple_logger::SimpleLogger::new() @@ -54,15 +70,24 @@ fn main() { let (renderer, tx) = Renderer::new(&window, &bsp); let new_control_flow = renderer.update_control_flow.clone(); + // Create the input manager + let manager = { + let actions = BTreeMap::new(); + // TODO: An actual control schema + + MovementInputsManager::new(actions) + }; + // Load everything into the session let mut session = Session::new( move |resources| { resources.insert(renderer); resources.insert(bsp); + resources.insert(manager); }, move |schedule| { schedule - .add_system(process_window_events_system()) + .add_system(process_window_events_system::()) .add_thread_local(do_render_system::>()); }, ); -- cgit v1.2.3