From 9cb237e88f31d85038d448e7865108e62011e59d Mon Sep 17 00:00:00 2001 From: Schmarni Date: Mon, 29 Apr 2024 18:49:07 +0200 Subject: [PATCH] fix status_changed_to, added OxrSuggestActionBindings event to app and fixed scheduling for run_action_binding_sugestion Signed-off-by: Schmarni --- crates/bevy_openxr/src/openxr/action_binding.rs | 3 ++- crates/bevy_openxr/src/openxr/action_set_attaching.rs | 3 ++- crates/bevy_xr/src/session.rs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/bevy_openxr/src/openxr/action_binding.rs b/crates/bevy_openxr/src/openxr/action_binding.rs index fc4b585..a5de40b 100644 --- a/crates/bevy_openxr/src/openxr/action_binding.rs +++ b/crates/bevy_openxr/src/openxr/action_binding.rs @@ -13,10 +13,11 @@ use crate::resources::OxrInstance; impl Plugin for OxrActionBindingPlugin { fn build(&self, app: &mut App) { app.add_schedule(Schedule::new(OxrSendActionBindings)); + app.add_event::(); app.add_systems( Update, run_action_binding_sugestion - .run_if(run_once().and_then(status_changed_to(XrStatus::Ready))), + .run_if(status_changed_to(XrStatus::Ready).and_then(run_once())), ); } } diff --git a/crates/bevy_openxr/src/openxr/action_set_attaching.rs b/crates/bevy_openxr/src/openxr/action_set_attaching.rs index fa139b0..f9abac8 100644 --- a/crates/bevy_openxr/src/openxr/action_set_attaching.rs +++ b/crates/bevy_openxr/src/openxr/action_set_attaching.rs @@ -14,8 +14,9 @@ impl Plugin for OxrActionAttachingPlugin { fn attach_sets(session: Res, mut events: EventReader) { let sets = events.read().map(|v| &v.0).collect::>(); + info!("attaching {} sessions", sets.len()); match session.attach_action_sets(&sets) { - Ok(_) => {} + Ok(_) => {info!("attached sessions!")} Err(openxr::sys::Result::ERROR_ACTIONSETS_ALREADY_ATTACHED) => { error!("Action Sets Already attached!"); } diff --git a/crates/bevy_xr/src/session.rs b/crates/bevy_xr/src/session.rs index 8eb29cb..f9dfba6 100644 --- a/crates/bevy_xr/src/session.rs +++ b/crates/bevy_xr/src/session.rs @@ -91,7 +91,7 @@ pub fn handle_session( /// A [`Condition`](bevy::ecs::schedule::Condition) that allows the system to run when the xr status changed to a specific [`XrStatus`]. pub fn status_changed_to(status: XrStatus) -> impl FnMut(EventReader) -> bool + Clone { move |mut reader: EventReader| { - reader.read().count() > 0 && reader.read().any(|new_status| new_status.0 == status) + reader.read().any(|new_status| new_status.0 == status) } }