From d1c8a8a6e84231f51bc74a7fd56ed3a289b0be6e Mon Sep 17 00:00:00 2001 From: Tomato <67799071+100-TomatoJuice@users.noreply.github.com> Date: Sat, 9 Sep 2023 18:46:50 -0700 Subject: [PATCH 1/4] Allow inputs from chords to be read --- src/input_streams.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/input_streams.rs b/src/input_streams.rs index f557dd72..5ff20a6a 100644 --- a/src/input_streams.rs +++ b/src/input_streams.rs @@ -330,6 +330,25 @@ impl<'a> InputStreams<'a> { UserInput::VirtualDPad { .. } => { self.input_axis_pair(input).unwrap_or_default().length() } + UserInput::Chord(inputs) => { + let mut value = 0.0; + + inputs.iter().for_each(|input| { + value += match input { + InputKind::SingleAxis(axis) => { + self.input_value(&UserInput::Single(InputKind::SingleAxis(*axis)), true) + } + InputKind::MouseWheel(axis) => { + self.input_value(&UserInput::Single(InputKind::MouseWheel(*axis)), true) + } + InputKind::MouseMotion(axis) => self + .input_value(&UserInput::Single(InputKind::MouseMotion(*axis)), true), + _ => use_button_value(), + }; + }); + + 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() { From 865388fb9342e4ee4dbb15db4c2a460d69567216 Mon Sep 17 00:00:00 2001 From: Tomato <67799071+100-TomatoJuice@users.noreply.github.com> Date: Sat, 9 Sep 2023 18:53:44 -0700 Subject: [PATCH 2/4] Update RELEASES.md --- RELEASES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASES.md b/RELEASES.md index 1081aba2..4293ee2d 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4,6 +4,7 @@ ### Bugs - Fixed system order ambiguity between bevy_ui and update_action_state systems +- Axis inputs in a `Chord` are now read as an axis instead of a button ### Docs From ec48b5d3cca47365671b9dd5f09e25a272690489 Mon Sep 17 00:00:00 2001 From: Tomato <67799071+100-TomatoJuice@users.noreply.github.com> Date: Sat, 9 Sep 2023 19:04:48 -0700 Subject: [PATCH 3/4] Prioritize axis over button --- src/input_streams.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/input_streams.rs b/src/input_streams.rs index 5ff20a6a..91b4233b 100644 --- a/src/input_streams.rs +++ b/src/input_streams.rs @@ -332,22 +332,35 @@ impl<'a> InputStreams<'a> { } UserInput::Chord(inputs) => { let mut value = 0.0; + let mut has_axis = false; - inputs.iter().for_each(|input| { + // 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) => self - .input_value(&UserInput::Single(InputKind::MouseMotion(*axis)), true), - _ => use_button_value(), - }; - }); + InputKind::MouseMotion(axis) => { + has_axis = true; + self.input_value( + &UserInput::Single(InputKind::MouseMotion(*axis)), + true, + ) + } + _ => 0.0, + } + } + + if has_axis { + return value; + } - 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)) => { From 143ec769ed48f120a401c5ae89742634e1f680e5 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Sun, 10 Sep 2023 10:07:13 -0400 Subject: [PATCH 4/4] Clarify RELASES.md --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 4293ee2d..7b1581c0 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4,7 +4,7 @@ ### Bugs - Fixed system order ambiguity between bevy_ui and update_action_state systems -- Axis inputs in a `Chord` are now read as an axis instead of a button +- The input values of axis inputs in a `Chord` are now prioritized over buttons ### Docs