Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UI button actions to send arbitrary OSC values. #140

Merged
merged 9 commits into from
Jan 26, 2025
Prev Previous commit
Next Next commit
osc: fix osc sender buttons
by passing a ref to the device list to send_params instead of the entire app state.
  • Loading branch information
cubee-cb committed Jan 20, 2025
commit daabfd4a3b092ed3a33fed567ecac73d458f3caf
2 changes: 1 addition & 1 deletion src/backend/openvr/mod.rs
Original file line number Diff line number Diff line change
@@ -330,7 +330,7 @@ pub fn openvr_run(running: Arc<AtomicBool>, show_by_default: bool) -> Result<(),

#[cfg(feature = "osc")]
if let Some(ref mut sender) = state.osc_sender {
let _ = sender.send_params(&overlays, &mut state);
let _ = sender.send_params(&overlays, &state.input_state.devices);
};

#[cfg(feature = "wayvr")]
2 changes: 1 addition & 1 deletion src/backend/openxr/mod.rs
Original file line number Diff line number Diff line change
@@ -312,7 +312,7 @@ pub fn openxr_run(running: Arc<AtomicBool>, show_by_default: bool) -> Result<(),

#[cfg(feature = "osc")]
if let Some(ref mut sender) = app_state.osc_sender {
let _ = sender.send_params(&overlays, &app_state);
let _ = sender.send_params(&overlays, &app_state.input_state.devices);
};

let (_, views) = xr_state.session.locate_views(
6 changes: 3 additions & 3 deletions src/backend/osc.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ use crate::{
state::AppState,
};

use super::common::OverlayContainer;
use super::{common::OverlayContainer, input::TrackedDevice};

pub struct OscSender {
last_sent_overlay: Instant,
@@ -53,7 +53,7 @@ impl OscSender {
Ok(())
}

pub fn send_params<D>(&mut self, overlays: &OverlayContainer<D>, app: &AppState) -> anyhow::Result<()>
pub fn send_params<D>(&mut self, overlays: &OverlayContainer<D>, devices: &Vec<TrackedDevice>) -> anyhow::Result<()>
where
D: Default,
{
@@ -108,7 +108,7 @@ impl OscSender {
let mut tracker_total_bat = 0.0;
let mut controller_total_bat = 0.0;

for device in &app.input_state.devices {
for device in devices {
let tracker_param;

// soc is the battery level (set to device status.charge)