- Notifications
You must be signed in to change notification settings - Fork0
Limited OSCQuery implementation in Rust for use with VRChat.
License
Raphiiko/oyasumivr_oscquery
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Limited OSCQuery implementation in Rust, for use with VRChat.
This library allows for:
- Advertising your OSC server to VRChat using OSCQuery. (For receiving OSC data from VRChat)
- Finding VRChat's own OSC and OSCQuery servers. (For sending OSC data to VRChat)
It isnot a full implementation of OSCQuery: Itonly implements the parts that are needed for interacting with VRChat. It does not handle the sending and receiving of OSC packets, for that you'll need to use a crate likerosc.
Its main reason for existence is to add OSCQuery support toOyasumiVR.Pull requests are welcome, however feature requests will likely go ignored, as this library is more of a personal means to an end.
Roughly based on specifications from theOSCQuery Proposal andVRChat's OSCQuery documentation.
Below you'll find some simple examples of how to use this library. For more detailed examples that you can run straight out of the box, please check theexamples directory.
Add the following dependency to yourCargo.toml
:
[dependencies]oyasumivr_oscquery = {git ="https://github.com/Raphiiko/oyasumivr_oscquery.git" }
This library depends on a dotnet based sidecar executable that needs to be included with your project. You can find it by:
- Downloading thebuilt executable from this repository
or
- Building it yourself by cloning this repository and running
./build.sh
. The executable will end up inlib/mdns-sidecar.exe
.
You will need to ship this executable with your project, with the rest of your program's files. The upcoming examples will show you how to refer to it.
You can find the addresses for VRChat's OSC and OSCQuery servers as follows.Note that these can only be found while VRChat is running.When VRChat is restarted or OSC is disabled/enabled, these addresses (and ports especially)may change, so make sure to check these functions for changes regularly.
// Start looking for VRChat's OSC & OSCQuery services.oyasumivr_oscquery::client::init("./lib/mdns-sidecar.exe"// The (relative) path to the mdns-sidecar.exe executable).await.unwrap();// Wait a bit for the MDNS daemon to find the servicestokio::time::sleep(tokio::time::Duration::from_millis(2000)).await;// Get the address of the VRChat OSC serverlet(host, port) = oyasumivr_oscquery::client::get_vrchat_osc_address().await.unwrap();println!("VRChat OSC address: {}:{}", host, port);// Get the address of the VRChat OSCQuery serverlet(host, port) = oyasumivr_oscquery::client::get_vrchat_oscquery_address().await.unwrap();println!("VRChat OSC Query address: {}:{}", host, port);
// Initialize the OSCQuery serveroyasumivr_oscquery::server::init("OyasumiVR Test",// The name of your application (Shows in VRChat's UI)8085,// The port your OSC server receives data on"./lib/mdns-sidecar.exe",// The (relative) path to the MDNS sidecar executable).await.unwrap();// Configure which data we want to receive from VRChatoyasumivr_oscquery::server::receive_vrchat_avatar_parameters().await;// /avatar/*, /avatar/parameters/*, etc.oyasumivr_oscquery::server::receive_vrchat_tracking_data().await;// /tracking/vrsystem/*// Now we can start broadcasting the advertisement for the OSC and OSCQuery serveroyasumivr_oscquery::server::advertise().await.unwrap();
Before you saw how to easily expose the right OSC methods for use with VRChat, by calling functions likereceive_vrchat_avatar_parameters
andreceive_vrchat_tracking_data
.
If you want to expose your own OSC methods, you can do so like follows:
// Initialize the OSCQuery serveroyasumivr_oscquery::server::init(...).await.unwrap();// Configure the OSC Query server by registering addresses we're interesting in receiving// Getting VRChat avatar parametersoyasumivr_oscquery::server::add_osc_method(OSCMethod{description:Some("VRChat Avatar Parameters".to_string()),address:"/avatar".to_string(),// Write: We only want to receive these values from VRChat, not send themad_type: oyasumivr_oscquery::OSCMethodAccessType::Write,value_type:None,value:None,}).await;// Now we can start broadcasting the advertisement for the OSC and OSCQuery serveroyasumivr_oscquery::server::advertise().await.unwrap();
If you change the address your OSC server runs on, you can update the advertised port at any time, even after you've already started (advertising) your OSC & OSCQuery servers.You can do this by calling theset_osc_port
function:
oyasumivr_oscquery::server::set_osc_port(8082).await;
The advertisements will automatically be updated!
Although irrelevant for use with VRChat, with this library you can also expose values for your OSC methods over OSCQuery, so that they become queryable.
oyasumivr_oscquery::server::set_osc_method_value("/foo/bar".to_string(),Some("1".to_string())).await;
About
Limited OSCQuery implementation in Rust for use with VRChat.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.