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

* osc: start adding osc buttons

a button action that sends an osc parameter.
struggling with borrows in openxr.rs and openvr.rs when getting the osc sender.

* osc: fix osc sender buttons

by passing a ref to the device list to send_params instead of the entire app state.

* osc: fix warnings

* osc: conditionally use OscSender crate in state.rs

* osc: fix button.rs compile errors without osc/wayvr features

* osc: add other types: int, bool, string. play thump noise when sent.

* osc: fix build without osc feature

i just want to use OscType directly, but since it doesn't derive serde::Deserialize, i can't just have one OscType action or list of actions...

* merge typed actions to one action, support multiple values.

i added a new struct OscValue that has Deserialize, and now the action just converts that to the corresponding OscType when sending the parameters.
perhaps not the most elegant solution, but it's the best i can think of without modifying the rosc crate.

* run `cargo fmt`
This commit is contained in:
Jay
2025-01-26 22:23:18 +11:00
committed by GitHub
parent 52298ccfdf
commit da129b62b3
5 changed files with 97 additions and 30 deletions

View File

@@ -124,10 +124,6 @@ pub fn openvr_run(running: Arc<AtomicBool>, show_by_default: bool) -> Result<(),
let mut playspace = playspace::PlayspaceMover::new();
playspace.playspace_changed(&mut compositor_mgr, &mut chaperone_mgr);
#[cfg(feature = "osc")]
let mut osc_sender =
crate::backend::osc::OscSender::new(state.session.config.osc_out_port).ok();
set_action_manifest(&mut input_mgr)?;
let mut input_source = OpenVrInputSource::new(&mut input_mgr)?;
@@ -333,8 +329,8 @@ 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, &state);
if let Some(ref mut sender) = state.osc_sender {
let _ = sender.send_params(&overlays, &state.input_state.devices);
};
#[cfg(feature = "wayvr")]