Skip to content

Commit

Permalink
Schedule gilrs system before input systems (bevyengine#2989)
Browse files Browse the repository at this point in the history
# Objective

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 was a regression introduced in bevyengine#1606 which removed the `PreEvent` stage

## Solution

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.
  • Loading branch information
branan committed Dec 16, 2021
1 parent 49a4009 commit 684c821
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
Expand Up @@ -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};
Expand All @@ -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),
}
Expand Down

0 comments on commit 684c821

Please sign in to comment.