From 684c821e964054e2f54834d5d6a7777fa945241d Mon Sep 17 00:00:00 2001 From: Branan Riley Date: Thu, 16 Dec 2021 00:04:34 +0000 Subject: [PATCH] Schedule gilrs system before input systems (#2989) # 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 #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. --- crates/bevy_gilrs/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/bevy_gilrs/src/lib.rs b/crates/bevy_gilrs/src/lib.rs index 3803e259c450a..37fa70a83316a 100644 --- a/crates/bevy_gilrs/src/lib.rs +++ b/crates/bevy_gilrs/src/lib.rs @@ -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), }