feat(input): captured bool
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -2072,7 +2072,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "stardust-xr"
|
name = "stardust-xr"
|
||||||
version = "0.14.1"
|
version = "0.14.1"
|
||||||
source = "git+https://github.com/StardustXR/core.git#615d4b098f848b1699ac6763b22d6c8783328f10"
|
source = "git+https://github.com/StardustXR/core.git#975331f9739a9f6cb90ec75813b7720c86225848"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cluFlock",
|
"cluFlock",
|
||||||
"color-rs",
|
"color-rs",
|
||||||
@@ -2092,7 +2092,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "stardust-xr-schemas"
|
name = "stardust-xr-schemas"
|
||||||
version = "1.5.3"
|
version = "1.5.3"
|
||||||
source = "git+https://github.com/StardustXR/core.git#615d4b098f848b1699ac6763b22d6c8783328f10"
|
source = "git+https://github.com/StardustXR/core.git#975331f9739a9f6cb90ec75813b7720c86225848"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
"flexbuffers",
|
"flexbuffers",
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ impl Scenegraph {
|
|||||||
pub fn get_node(&self, path: &str) -> Option<Arc<Node>> {
|
pub fn get_node(&self, path: &str) -> Option<Arc<Node>> {
|
||||||
let mut node = self.nodes.lock().get(path)?.clone();
|
let mut node = self.nodes.lock().get(path)?.clone();
|
||||||
while let Some(alias) = node.alias.get() {
|
while let Some(alias) = node.alias.get() {
|
||||||
if alias.enabled.load(Ordering::Relaxed) {
|
if alias.enabled.load(Ordering::Acquire) {
|
||||||
node = alias.original.upgrade()?;
|
node = alias.original.upgrade()?;
|
||||||
} else {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ impl InputMethod {
|
|||||||
let method = InputMethod::get(node)?;
|
let method = InputMethod::get(node)?;
|
||||||
let handler = InputHandler::find(&calling_client, deserialize(message.as_ref())?)?;
|
let handler = InputHandler::find(&calling_client, deserialize(message.as_ref())?)?;
|
||||||
|
|
||||||
|
println!("Input method captured");
|
||||||
method.captures.add_raw(&handler);
|
method.captures.add_raw(&handler);
|
||||||
node.send_remote_signal("capture", message)
|
node.send_remote_signal("capture", message)
|
||||||
}
|
}
|
||||||
@@ -230,11 +231,11 @@ impl DistanceLink {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_input(&self, order: u32, datamap: Datamap) {
|
fn send_input(&self, order: u32, captured: bool, datamap: Datamap) {
|
||||||
self.handler.send_input(order, self, datamap);
|
self.handler.send_input(order, captured, self, datamap);
|
||||||
}
|
}
|
||||||
#[instrument(level = "debug", skip(self))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
fn serialize(&self, order: u32, datamap: Datamap) -> Vec<u8> {
|
fn serialize(&self, order: u32, captured: bool, datamap: Datamap) -> Vec<u8> {
|
||||||
let input = self.method.specialization.lock().serialize(
|
let input = self.method.specialization.lock().serialize(
|
||||||
self,
|
self,
|
||||||
Spatial::space_to_space_matrix(Some(&self.method.spatial), Some(&self.handler.spatial)),
|
Spatial::space_to_space_matrix(Some(&self.method.spatial), Some(&self.handler.spatial)),
|
||||||
@@ -246,6 +247,7 @@ impl DistanceLink {
|
|||||||
distance: self.method.true_distance(&self.handler.field),
|
distance: self.method.true_distance(&self.handler.field),
|
||||||
datamap,
|
datamap,
|
||||||
order,
|
order,
|
||||||
|
captured,
|
||||||
};
|
};
|
||||||
root.serialize()
|
root.serialize()
|
||||||
}
|
}
|
||||||
@@ -291,9 +293,15 @@ impl InputHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "debug", skip(self, distance_link))]
|
#[instrument(level = "debug", skip(self, distance_link))]
|
||||||
fn send_input(&self, order: u32, distance_link: &DistanceLink, datamap: Datamap) {
|
fn send_input(
|
||||||
|
&self,
|
||||||
|
order: u32,
|
||||||
|
captured: bool,
|
||||||
|
distance_link: &DistanceLink,
|
||||||
|
datamap: Datamap,
|
||||||
|
) {
|
||||||
let Some(node) = self.node.upgrade() else {return};
|
let Some(node) = self.node.upgrade() else {return};
|
||||||
let _ = node.send_remote_signal("input", distance_link.serialize(order, datamap));
|
let _ = node.send_remote_signal("input", distance_link.serialize(order, captured, datamap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl PartialEq for InputHandler {
|
impl PartialEq for InputHandler {
|
||||||
@@ -355,7 +363,7 @@ pub fn process_input() {
|
|||||||
const LIMIT: usize = 50;
|
const LIMIT: usize = 50;
|
||||||
for method in methods {
|
for method in methods {
|
||||||
for alias in method.node.upgrade().unwrap().aliases.get_valid_contents() {
|
for alias in method.node.upgrade().unwrap().aliases.get_valid_contents() {
|
||||||
alias.enabled.store(false, Ordering::Relaxed);
|
alias.enabled.store(false, Ordering::Release);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_span!("Process input method").in_scope(|| {
|
debug_span!("Process input method").in_scope(|| {
|
||||||
@@ -406,13 +414,18 @@ pub fn process_input() {
|
|||||||
.get(&(Arc::as_ptr(&distance_link.method) as usize))
|
.get(&(Arc::as_ptr(&distance_link.method) as usize))
|
||||||
.and_then(|a| a.alias.get().cloned())
|
.and_then(|a| a.alias.get().cloned())
|
||||||
{
|
{
|
||||||
method_alias.enabled.store(true, Ordering::Relaxed);
|
method_alias.enabled.store(true, Ordering::Release);
|
||||||
}
|
}
|
||||||
distance_link.send_input(i as u32, method.datamap.lock().clone().unwrap());
|
let captured = dbg!(captures.contains(&distance_link.handler));
|
||||||
|
distance_link.send_input(
|
||||||
|
i as u32,
|
||||||
|
captured,
|
||||||
|
method.datamap.lock().clone().unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
// If the current distance link is in the list of captured input handlers,
|
// If the current distance link is in the list of captured input handlers,
|
||||||
// break out of the loop to avoid sending input to the remaining distance links
|
// break out of the loop to avoid sending input to the remaining distance links
|
||||||
if captures.contains(&distance_link.handler) {
|
if captured {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user