From ed99cf113f1b44bc2b51233c1b85f1f79d3d6466 Mon Sep 17 00:00:00 2001 From: Louis Capitanchik <contact@louiscap.co> Date: Sun, 25 Feb 2024 00:30:35 +0000 Subject: [PATCH] Update to bevy 0.13 --- Cargo.toml | 13 +++++++------ src/bevy.rs | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 06b4fc3..52ed5f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "micro_bevy_web_utils" -version = "0.3.0" +version = "0.4.0" edition = "2021" description = "Utilities for patching various missing parts from Bevy web/touch support" authors = [ @@ -11,9 +11,10 @@ homepage = "https://lab.lcr.gr/microhacks/bevy-web-utils" license = "Apache-2.0" [dependencies] -bevy_ecs = "0.11.0" -bevy_input = "0.11.0" -bevy_math = "0.11.0" +bevy_ecs = "0.13.0" +bevy_input = "0.13.0" +bevy_math = "0.13.0" +bevy_window = "0.13.0" wasm-bindgen = "0.2.83" -serde = "1.0.151" -serde_json = "1.0.91" \ No newline at end of file +serde = "1.0" +serde_json = "1.0" \ No newline at end of file diff --git a/src/bevy.rs b/src/bevy.rs index 4cba45c..a2971ed 100644 --- a/src/bevy.rs +++ b/src/bevy.rs @@ -1,6 +1,10 @@ +use bevy_ecs::entity::Entity; use bevy_ecs::event::EventWriter; +use bevy_ecs::query::With; +use bevy_ecs::system::Query; use bevy_input::touch::{TouchInput, TouchPhase}; use bevy_math::Vec2; +use bevy_window::{PrimaryWindow, Window}; use std::fmt::{Display, Formatter}; #[derive(serde::Deserialize)] @@ -39,10 +43,19 @@ fn inner_touch_events() -> Result<impl IntoIterator<Item = InnerTouchInput>, Tou Ok(touch_events.into_iter()) } -pub fn emit_touch_events(mut events: EventWriter<TouchInput>) { +pub fn emit_touch_events( + windows: Query<Entity, With<PrimaryWindow>>, + mut events: EventWriter<TouchInput>, +) { + let window = match windows.iter().next() { + Some(window) => window, + None => return, + }; + if let Ok(inner_events) = inner_touch_events() { for input in inner_events { events.send(TouchInput { + window, phase: input.phase, position: input.position, id: input.id, -- GitLab