Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions crates/bevy_gilrs/src/gilrs_system.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::converter::{convert_axis, convert_button, convert_gamepad_id};
use bevy_ecs::event::EventWriter;
use bevy_ecs::system::{NonSend, NonSendMut, Res};
use bevy_ecs::system::{NonSend, NonSendMut, Res, ResMut};
use bevy_input::gamepad::{
GamepadAxisChangedEvent, GamepadButtonChangedEvent, GamepadConnection, GamepadConnectionEvent,
GamepadSettings,
Expand Down Expand Up @@ -29,8 +29,8 @@ pub fn gilrs_event_startup_system(
pub fn gilrs_event_system(
mut gilrs: NonSendMut<Gilrs>,
mut events: EventWriter<GamepadEvent>,
mut gamepad_buttons: ResMut<Axis<GamepadButton>>,
gamepad_axis: Res<Axis<GamepadAxis>>,
gamepad_buttons: Res<Axis<GamepadButton>>,
gamepad_settings: Res<GamepadSettings>,
) {
while let Some(gilrs_event) = gilrs
Expand Down Expand Up @@ -65,6 +65,9 @@ pub fn gilrs_event_system(
GamepadButtonChangedEvent::new(gamepad, button_type, filtered_value)
.into(),
);
// Update the current value prematurely so that `old_value` is correct in
// future iterations of the loop.
gamepad_buttons.set(button, filtered_value);
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions crates/bevy_input/src/gamepad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,6 @@ pub fn gamepad_axis_event_system(
pub fn gamepad_button_event_system(
mut button_events: EventReader<GamepadButtonChangedEvent>,
mut button_input: ResMut<Input<GamepadButton>>,
mut button_axis: ResMut<Axis<GamepadButton>>,
settings: Res<GamepadSettings>,
) {
for button_event in button_events.iter() {
Expand All @@ -1149,8 +1148,6 @@ pub fn gamepad_button_event_system(
} else if button_property.is_pressed(value) {
button_input.press(button);
};

button_axis.set(button, value);
}
}

Expand Down