fix: multiple axis inputs
This commit is contained in:
11
src/input.rs
11
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
|
||||
|
||||
Reference in New Issue
Block a user