diff --git a/RELEASES.md b/RELEASES.md index 1081aba2..7b1581c0 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4,6 +4,7 @@ ### Bugs - Fixed system order ambiguity between bevy_ui and update_action_state systems +- The input values of axis inputs in a `Chord` are now prioritized over buttons ### Docs diff --git a/src/input_streams.rs b/src/input_streams.rs index f557dd72..91b4233b 100644 --- a/src/input_streams.rs +++ b/src/input_streams.rs @@ -330,6 +330,38 @@ impl<'a> InputStreams<'a> { UserInput::VirtualDPad { .. } => { self.input_axis_pair(input).unwrap_or_default().length() } + UserInput::Chord(inputs) => { + let mut value = 0.0; + let mut has_axis = false; + + // Prioritize axis over button input values + for input in inputs.iter() { + value += match input { + InputKind::SingleAxis(axis) => { + has_axis = true; + self.input_value(&UserInput::Single(InputKind::SingleAxis(*axis)), true) + } + InputKind::MouseWheel(axis) => { + has_axis = true; + self.input_value(&UserInput::Single(InputKind::MouseWheel(*axis)), true) + } + InputKind::MouseMotion(axis) => { + has_axis = true; + self.input_value( + &UserInput::Single(InputKind::MouseMotion(*axis)), + true, + ) + } + _ => 0.0, + } + } + + if has_axis { + return value; + } + + use_button_value() + } // This is required because upstream bevy::input still waffles about whether triggers are buttons or axes UserInput::Single(InputKind::GamepadButton(button_type)) => { if let Some(gamepad) = self.guess_gamepad() {