use AppState to get device roles
i _understand_ now! basically, i did it the "wrong" way first by modifying openxr.rs and openvr.rs to pass battery levels to osc, when really i could have just made osc get the pre-formatted device details from AppState. live and learn, i'm new to rust anyway.
This commit is contained in:
@@ -324,7 +324,7 @@ pub fn openvr_run(running: Arc<AtomicBool>, show_by_default: bool) -> Result<(),
|
||||
|
||||
#[cfg(feature = "osc")]
|
||||
if let Some(ref mut sender) = osc_sender {
|
||||
let _ = sender.send_params(&overlays);
|
||||
let _ = sender.send_params(&overlays, &state); // i love inconsistent naming; in openxr.rs `state` is called `app_state`
|
||||
};
|
||||
|
||||
#[cfg(feature = "wayvr")]
|
||||
|
||||
@@ -304,7 +304,7 @@ pub fn openxr_run(running: Arc<AtomicBool>, show_by_default: bool) -> Result<(),
|
||||
|
||||
#[cfg(feature = "osc")]
|
||||
if let Some(ref mut sender) = osc_sender {
|
||||
let _ = sender.send_params(&overlays);
|
||||
let _ = sender.send_params(&overlays, &app_state);
|
||||
};
|
||||
|
||||
let (_, views) = xr_state.session.locate_views(
|
||||
|
||||
@@ -8,6 +8,11 @@ use rosc::{OscMessage, OscPacket, OscType};
|
||||
|
||||
use crate::overlays::{keyboard::KEYBOARD_NAME, watch::WATCH_NAME};
|
||||
|
||||
use crate::{
|
||||
backend::input::{TrackedDevice, TrackedDeviceRole},
|
||||
state::{AppState},
|
||||
};
|
||||
|
||||
use super::common::OverlayContainer;
|
||||
|
||||
pub struct OscSender {
|
||||
@@ -46,7 +51,7 @@ impl OscSender {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn send_params<D>(&mut self, overlays: &OverlayContainer<D>) -> anyhow::Result<()>
|
||||
pub fn send_params<D>(&mut self, overlays: &OverlayContainer<D>, app: &AppState) -> anyhow::Result<()>
|
||||
where
|
||||
D: Default,
|
||||
{
|
||||
@@ -90,6 +95,32 @@ impl OscSender {
|
||||
vec![OscType::Int(num_overlays)],
|
||||
)?;
|
||||
|
||||
// battery levels
|
||||
let mut tracker_idx = 0;
|
||||
|
||||
let devices = &app.input_state.devices;
|
||||
for device in devices {
|
||||
match device.role {
|
||||
TrackedDeviceRole::None => {
|
||||
|
||||
}
|
||||
TrackedDeviceRole::Hmd => {
|
||||
|
||||
}
|
||||
TrackedDeviceRole::LeftHand => {
|
||||
|
||||
}
|
||||
TrackedDeviceRole::RightHand => {
|
||||
|
||||
}
|
||||
TrackedDeviceRole::Tracker => {
|
||||
|
||||
tracker_idx += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user