feat: basic input

This commit is contained in:
Nova
2022-07-01 03:51:28 -04:00
parent cd7627a183
commit a30b6d02b7
3 changed files with 55 additions and 2 deletions

View File

@@ -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<Arc<Item>>,
pub item_acceptor: OnceCell<Arc<ItemAcceptor>>,
pub item_ui: OnceCell<Arc<ItemUI>>,
pub input_method: OnceCell<Arc<InputMethod>>,
pub input_handler: OnceCell<Arc<InputHandler>>,
}
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

47
src/nodes/input.rs Normal file
View File

@@ -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<InputMethod> = Default::default();
static ref INPUT_HANDLER_REGISTRY: Registry<InputHandler> = Default::default();
}
pub struct InputMethod {
spatial: Weak<Spatial>,
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<Spatial>,
field: Weak<Field>,
}
pub fn create_interface(client: &Arc<Client>) {
let node = Node::create(client, "", "data", false);
// node.add_local_signal("createInputHandler", create_input_handler_flex);
node.add_to_scenegraph();
}

View File

@@ -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;