use super::{CaptureManager, DistanceCalculator, get_sorted_handlers}; use crate::{ DbusConnection, ObjectRegistryRes, core::client::INTERNAL_CLIENT, nodes::{ Node, OwnedNode, fields::{EXPORTED_FIELDS, Field, FieldTrait, Ray}, input::{InputDataType, InputMethod, Pointer}, items::panel::KEYMAPS, spatial::Spatial, }, }; use bevy::{ input::{ ButtonState, keyboard::{KeyboardInput, NativeKey, NativeKeyCode}, mouse::{MouseMotion, MouseWheel}, }, prelude::*, window::PrimaryWindow, }; use color_eyre::eyre::Result; use glam::{Mat4, Vec3, vec3}; use mint::Vector2; use serde::{Deserialize, Serialize}; use slotmap::{DefaultKey, Key as SlotKey}; use stardust_xr::{ schemas::dbus::{interfaces::FieldRefProxy, object_registry::ObjectRegistry}, values::Datamap, }; use std::sync::Arc; use tokio::task::JoinSet; use tokio::time::{Duration, timeout}; use xkbcommon_rs::{Context, Keymap, KeymapFormat, xkb_keymap::CompileFlags}; use zbus::{Connection, names::OwnedInterfaceName}; pub struct FlatscreenInputPlugin; impl Plugin for FlatscreenInputPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, setup); // yes the input method will be delayed by one frame, its only for debugging anyways app.add_systems(Update, update_pointer); } } #[derive(Component)] #[require(Camera3d)] pub struct FlatscreenCam; fn setup(mut cmds: Commands) { let Ok(pointer) = MousePointer::new().inspect_err(|err| error!("unable to create mouse pointer: {err}")) else { return; }; cmds.spawn((FlatscreenCam, Name::new("Flatscreen Camera"))); cmds.insert_resource(pointer); } fn update_pointer( window: Single<(&Window), With>, mut cam: Single<(&Camera, &GlobalTransform, &mut Transform), With>, mut pointer: ResMut, connection: Res, object_registry: Res, mouse_buttons: Res>, keyboard_buttons: Res>, mut scroll: EventReader, mut motion: EventReader, mut keyboard_input_events: EventReader, time: Res