diff --git a/config/input.toml b/config/input.toml index 2ea6cfd..c6eb1fe 100644 --- a/config/input.toml +++ b/config/input.toml @@ -7,10 +7,22 @@ name = "RELOAD_SHADERS" scan_code = 19 ctrl = true +[[button]] +name = "FORWARD" +scan_code = 17 + +[[button]] +name = "BACK" +scan_code = 31 + +[[axis]] +name = "FORWARD_AXIS" +positive_button = "FORWARD" +negative_button = "BACK" + [[axis]] name = "FORWARD_AXIS" mouse_wheel = true -ctrl = true [config] line_height_px = 16 \ No newline at end of file diff --git a/src/input.rs b/src/input.rs index b8af56e..ea43795 100644 --- a/src/input.rs +++ b/src/input.rs @@ -193,17 +193,12 @@ impl InputState { pub fn get_axis(self: &Self, axis_code: &str) -> f32 { if let Some(axis) = self.virtual_axes.get(axis_code) { - axis.axis_inputs.iter().fold(0.0, |fold, item| { - let val = match item { + axis.axis_inputs.iter().map(|item| { + match item { AxisInput::Wheel(modifiers) => if self.modifiers_are_pressed(*modifiers) { self.analog_wheel_state } else { 0.0 }, AxisInput::Digital(positive_button, negative_button) => self.virtual_button_to_float(positive_button) - self.virtual_button_to_float(negative_button), - }; - if f32::abs(val) > fold { - val - } else { - fold } - }) + }).fold(0.0, |fold, it| if f32::abs(it) > f32::abs(fold) { it } else { fold }) } else { assert!(false, format!("Axis {:?} not found!", axis_code)); 0.0 diff --git a/src/main.rs b/src/main.rs index f8ccbf2..9e24edc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,10 @@ struct TestGame { } impl Game for TestGame { + fn validation_layers_enabled(self: &Self) -> bool { + self.log_config.vulkan_validation_layers + } + fn update(self: &mut Self, game_data: &mut GameData) { // User interaction if self.input.button_just_released("QUIT") { @@ -44,7 +48,7 @@ impl Game for TestGame { Rad::from(Deg(45.0)), game_data.dimensions[0] as f32 / game_data.dimensions[1] as f32, 0.1, - 10.0 + 100.0 ); proj.y.y *= -1.0; @@ -99,10 +103,6 @@ impl Game for TestGame { _ => {} } } - - fn validation_layers_enabled(self: &Self) -> bool { - self.log_config.vulkan_validation_layers - } } fn main() {