Skip to content

Commit

Permalink
Schedule gilrs system before input systems
Browse files Browse the repository at this point in the history
Previously, the gilrs system had no explicit relationship to the input
systems. This could potentially cause it to be scheduled after the
input systems, leading to a one-frame lag in gamepad inputs.

This adds an explicit `before` relationship to the gilrs plugin,
ensuring that raw gamepad events will be processed on the same frame
that they are generated.
branan committed Oct 18, 2021

Verified

This commit was signed with the committer’s verified signature.
branan Branan Riley
1 parent d65fbd7 commit 943784a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/bevy_gilrs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@ mod converter;
mod gilrs_system;

use bevy_app::{App, CoreStage, Plugin, StartupStage};
use bevy_ecs::schedule::ParallelSystemDescriptorCoercion;
use bevy_input::InputSystem;
use bevy_utils::tracing::error;
use gilrs::GilrsBuilder;
use gilrs_system::{gilrs_event_startup_system, gilrs_event_system};
@@ -22,7 +24,10 @@ impl Plugin for GilrsPlugin {
StartupStage::PreStartup,
gilrs_event_startup_system,
)
.add_system_to_stage(CoreStage::PreUpdate, gilrs_event_system);
.add_system_to_stage(
CoreStage::PreUpdate,
gilrs_event_system.before(InputSystem),
);
}
Err(err) => error!("Failed to start Gilrs. {}", err),
}

0 comments on commit 943784a

Please sign in to comment.