From fe61319fc2740592a66e4e4a515cb1b61048089d Mon Sep 17 00:00:00 2001 From: Jay <157681441+cubee-cb@users.noreply.github.com> Date: Fri, 16 Jan 2026 13:13:44 +1100 Subject: [PATCH] OSC: Change `::OscSend` format and restore String support to Button Actions. (#388) * OscSend: support strings poc - change value delimiter to `;` - default convert values to String when not converted to another type * add `_arg=""` format instead of `;` delimiter that is, vrchat chatbox is controlled like `_press="::OscSend /chatbox/input" _arg0="${send}" _arg1="true" _arg2="true"` now old format still supported as shorthand, with same "strings can't have spaces" limit as before. `_arg` are appended after these. * fix accidentally resetting `osc_args` to empty between formats * update readme to document `::OscSend` paramter-form * clean up, use `while let` instead of `while match` * merge `parse_osc_value` into while condition * remove second log from shortform arg parsing --- wayvr/src/gui/README.md | 30 ++++++++++++++++++++++++------ wayvr/src/gui/panel/button.rs | 23 ++++++++++++++++++----- wayvr/src/subsystem/osc.rs | 2 +- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/wayvr/src/gui/README.md b/wayvr/src/gui/README.md index 463e2cf..9c3bb44 100644 --- a/wayvr/src/gui/README.md +++ b/wayvr/src/gui/README.md @@ -80,22 +80,40 @@ This button action executes a shell script using the `sh` shell. + +``` + +```xml + + + +``` + +The two can be combined; parameter-form arguments will be appended after shorthand-form arguments: +```xml + + + ``` Available argument value types (case insensitive): - Bool: `true` or `false` - Nil: `nil` - Inf: `inf` -- Int: `-1i32`, `1i32`, etc -- Long: `-1i64`, `1i64`, etc -- Float: `1f32`, `1.0f32`, etc -- Double: `1f64`, `1.0f64`, etc +- Int: suffix `i32` (`-1i32`, `1i32`, etc) +- Long: suffix `i64` (`-1i64`, `1i64`, etc) +- Float: suffix `f32` (`1f32`, `1.0f32`, etc) +- Double: suffix `f64` (`1f64`, `1.0f64`, etc) +- String: any other value + - Shorthand form will treat Strings with spaces as multiple arguments. Use parameter form if you need spaces. ##### `::SendKey ` diff --git a/wayvr/src/gui/panel/button.rs b/wayvr/src/gui/panel/button.rs index 67a7819..2453a58 100644 --- a/wayvr/src/gui/panel/button.rs +++ b/wayvr/src/gui/panel/button.rs @@ -692,15 +692,28 @@ pub(super) fn setup_custom_button( }; let mut osc_args = vec![]; + + // collect arguments specified in the initial string for arg in args { - let Ok(osc_arg) = parse_osc_value(arg) - .inspect_err(|e| log::warn!("Could not parse OSC value '{arg}': {e:?}")) - else { - let msg = format!("expected OscValue, found \"{arg}\""); + if let Ok(osc_arg) = parse_osc_value(arg).inspect_err(|e| { + let msg = format!("Could not parse OSC value \"{arg}\": {e:?}"); log_cmd_invalid_arg(parser_state, TAG, name, command, &msg); return; - }; + }) { + osc_args.push(osc_arg); + } + } + + // collect arguments from _arg attributes. + let mut arg_index = 0; + while let Some(arg) = attribs.get_value(&format!("_arg{arg_index}")) + && let Ok(osc_arg) = parse_osc_value(arg).inspect_err(|e| { + let msg = format!("Could not parse OSC value \"{arg}\": {e:?}"); + log_cmd_invalid_arg(parser_state, TAG, name, command, &msg); + }) + { osc_args.push(osc_arg); + arg_index += 1; } Box::new(move |_common, data, app, _| { diff --git a/wayvr/src/subsystem/osc.rs b/wayvr/src/subsystem/osc.rs index c73fe87..0a1f26b 100644 --- a/wayvr/src/subsystem/osc.rs +++ b/wayvr/src/subsystem/osc.rs @@ -243,7 +243,7 @@ pub fn parse_osc_value(s: &str) -> anyhow::Result { } } - anyhow::bail!("Unknown OSC type literal: {s}") + Ok(OscType::String(s.to_string())) } } }