feat: initial IDL
This commit is contained in:
@@ -10,7 +10,7 @@ use color_eyre::eyre::Result;
|
||||
use glam::Mat4;
|
||||
use nanoid::nanoid;
|
||||
use serde::Serialize;
|
||||
use stardust_xr::schemas::{flat::Datamap, flex::flexbuffers};
|
||||
use stardust_xr::{schemas::flex::flexbuffers, values::Datamap};
|
||||
use std::sync::Arc;
|
||||
use stereokit::StereoKitMultiThread;
|
||||
|
||||
@@ -48,7 +48,7 @@ impl EyePointer {
|
||||
let mut map = fbb.start_map();
|
||||
map.push("eye", 2);
|
||||
map.end_map();
|
||||
*self.pointer.datamap.lock() = Datamap::new(fbb.take_buffer()).ok();
|
||||
*self.pointer.datamap.lock() = Datamap::from_raw(fbb.take_buffer()).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
core::{client::INTERNAL_CLIENT, typed_datamap::TypedDatamap},
|
||||
core::client::INTERNAL_CLIENT,
|
||||
nodes::{
|
||||
data::{mask_matches, Mask, PulseSender, KEYMAPS, PULSE_RECEIVER_REGISTRY},
|
||||
fields::Ray,
|
||||
@@ -12,6 +12,7 @@ use color_eyre::eyre::Result;
|
||||
use glam::{vec2, vec3, Mat4, Vec2, Vec3};
|
||||
use nanoid::nanoid;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use stardust_xr::values::Datamap;
|
||||
use std::{convert::TryFrom, sync::Arc};
|
||||
use stereokit::{ray_from_mouse, ButtonState, Key, StereoKitMultiThread};
|
||||
use xkbcommon::xkb::{Context, Keymap, FORMAT_TEXT_V1};
|
||||
@@ -49,8 +50,8 @@ pub struct MousePointer {
|
||||
node: Arc<Node>,
|
||||
spatial: Arc<Spatial>,
|
||||
pointer: Arc<InputMethod>,
|
||||
mouse_datamap: TypedDatamap<MouseEvent>,
|
||||
keyboard_datamap: TypedDatamap<KeyboardEvent>,
|
||||
mouse_datamap: MouseEvent,
|
||||
keyboard_datamap: KeyboardEvent,
|
||||
keyboard_sender: Arc<PulseSender>,
|
||||
}
|
||||
impl MousePointer {
|
||||
@@ -122,7 +123,7 @@ impl MousePointer {
|
||||
};
|
||||
self.mouse_datamap.scroll_continuous = vec2(0.0, mouse.scroll_change / 120.0);
|
||||
self.mouse_datamap.scroll_discrete = vec2(0.0, mouse.scroll_change / 120.0);
|
||||
*self.pointer.datamap.lock() = self.mouse_datamap.to_datamap().ok();
|
||||
*self.pointer.datamap.lock() = Datamap::from_typed(&self.mouse_datamap).ok();
|
||||
}
|
||||
self.send_keyboard_input(sk);
|
||||
}
|
||||
@@ -169,8 +170,14 @@ impl MousePointer {
|
||||
|
||||
self.keyboard_datamap.keys = keys;
|
||||
if !self.keyboard_datamap.keys.is_empty() {
|
||||
rx.send_data(&self.node.uid, self.keyboard_datamap.serialize().unwrap())
|
||||
.unwrap();
|
||||
rx.send_data(
|
||||
&self.node.uid,
|
||||
Datamap::from_typed(&self.keyboard_datamap)
|
||||
.unwrap()
|
||||
.raw()
|
||||
.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
core::{client::INTERNAL_CLIENT, typed_datamap::TypedDatamap},
|
||||
core::client::INTERNAL_CLIENT,
|
||||
nodes::{
|
||||
input::{tip::Tip, InputMethod, InputType},
|
||||
spatial::Spatial,
|
||||
@@ -9,6 +9,7 @@ use crate::{
|
||||
use color_eyre::eyre::Result;
|
||||
use glam::{Mat4, Vec2, Vec3};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use stardust_xr::values::Datamap;
|
||||
use std::sync::Arc;
|
||||
use stereokit::{
|
||||
named_colors::WHITE, ButtonState, Handed, Model, RenderLayer, StereoKitDraw,
|
||||
@@ -27,7 +28,7 @@ pub struct SkController {
|
||||
input: Arc<InputMethod>,
|
||||
model: Model,
|
||||
handed: Handed,
|
||||
datamap: TypedDatamap<ControllerDatamap>,
|
||||
datamap: ControllerDatamap,
|
||||
}
|
||||
impl SkController {
|
||||
pub fn new(sk: &impl StereoKitMultiThread, handed: Handed) -> Result<Self> {
|
||||
@@ -73,6 +74,6 @@ impl SkController {
|
||||
self.datamap.select = controller.trigger;
|
||||
self.datamap.grab = controller.grip;
|
||||
self.datamap.scroll = controller.stick;
|
||||
*self.input.datamap.lock() = self.datamap.to_datamap().ok();
|
||||
*self.input.datamap.lock() = Datamap::from_typed(&self.datamap).ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
core::{client::INTERNAL_CLIENT, typed_datamap::TypedDatamap},
|
||||
core::client::INTERNAL_CLIENT,
|
||||
nodes::{
|
||||
input::{hand::Hand, InputMethod, InputType},
|
||||
spatial::Spatial,
|
||||
@@ -10,7 +10,10 @@ use color_eyre::eyre::Result;
|
||||
use glam::Mat4;
|
||||
use nanoid::nanoid;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use stardust_xr::schemas::flat::{Hand as FlatHand, Joint};
|
||||
use stardust_xr::{
|
||||
schemas::flat::{Hand as FlatHand, Joint},
|
||||
values::Datamap,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use stereokit::{ButtonState, HandJoint, Handed, StereoKitMultiThread};
|
||||
|
||||
@@ -33,7 +36,7 @@ pub struct SkHand {
|
||||
_node: Arc<Node>,
|
||||
input: Arc<InputMethod>,
|
||||
handed: Handed,
|
||||
datamap: TypedDatamap<HandDatamap>,
|
||||
datamap: HandDatamap,
|
||||
}
|
||||
impl SkHand {
|
||||
pub fn new(handed: Handed) -> Result<Self> {
|
||||
@@ -98,6 +101,6 @@ impl SkHand {
|
||||
}
|
||||
self.datamap.pinch_strength = sk_hand.pinch_activation;
|
||||
self.datamap.grab_strength = sk_hand.grip_activation;
|
||||
*self.input.datamap.lock() = self.datamap.to_datamap().ok();
|
||||
*self.input.datamap.lock() = Datamap::from_typed(&self.datamap).ok();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user