diff --git a/src/nodes/core.rs b/src/nodes/core.rs index 09ff875..b194023 100644 --- a/src/nodes/core.rs +++ b/src/nodes/core.rs @@ -1,5 +1,6 @@ use super::data::{PulseReceiver, PulseSender}; use super::field::Field; +use super::input::{InputHandler, InputMethod}; use super::item::{Item, ItemAcceptor, ItemUI}; use super::spatial::Spatial; use crate::core::client::Client; @@ -38,6 +39,8 @@ pub struct Node { pub item: OnceCell>, pub item_acceptor: OnceCell>, pub item_ui: OnceCell>, + pub input_method: OnceCell>, + pub input_handler: OnceCell>, } impl Node { @@ -77,6 +80,8 @@ impl Node { item: OnceCell::new(), item_acceptor: OnceCell::new(), item_ui: OnceCell::new(), + input_method: OnceCell::new(), + input_handler: OnceCell::new(), }; node.add_local_signal("destroy", Node::destroy_flex); node diff --git a/src/nodes/input.rs b/src/nodes/input.rs new file mode 100644 index 0000000..1d901a3 --- /dev/null +++ b/src/nodes/input.rs @@ -0,0 +1,47 @@ +use super::core::{Alias, Node}; +use super::field::Field; +use super::spatial::{get_spatial_parent_flex, get_transform_pose_flex, Spatial}; +use crate::core::client::Client; +use crate::core::nodelist::LifeLinkedNodeList; +use crate::core::registry::Registry; +use anyhow::{anyhow, ensure, Result}; +use glam::{vec3a, Mat4}; +use lazy_static::lazy_static; +use libstardustxr::flex::flexbuffer_from_vector_arguments; +use libstardustxr::{flex_to_quat, flex_to_vec3}; +use parking_lot::Mutex; +use std::ops::Deref; +use std::sync::{Arc, Weak}; + +lazy_static! { + static ref INPUT_METHOD_REGISTRY: Registry = Default::default(); + static ref INPUT_HANDLER_REGISTRY: Registry = Default::default(); +} + +pub struct InputMethod { + spatial: Weak, + specialization: InputType, +} +trait InputMethodSpecialization { + fn distance(&self, space: &Spatial, field: &Field) -> f32; +} +enum InputType {} +impl Deref for InputType { + type Target = dyn InputMethodSpecialization; + fn deref(&self) -> &Self::Target { + todo!() + // match self { + // Field::Box(field) => field, + // } + } +} +pub struct InputHandler { + spatial: Weak, + field: Weak, +} + +pub fn create_interface(client: &Arc) { + let node = Node::create(client, "", "data", false); + // node.add_local_signal("createInputHandler", create_input_handler_flex); + node.add_to_scenegraph(); +} diff --git a/src/nodes/mod.rs b/src/nodes/mod.rs index ee8aa3e..25d4ae0 100644 --- a/src/nodes/mod.rs +++ b/src/nodes/mod.rs @@ -1,6 +1,7 @@ -pub mod item; -pub mod root; pub mod core; pub mod data; pub mod field; +pub mod input; +pub mod item; +pub mod root; pub mod spatial;