Skip to content

Commit

Permalink
Added OSCQuery support to OSC control
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphiiko committed Dec 19, 2023
1 parent 0b3b438 commit 814645b
Show file tree
Hide file tree
Showing 17 changed files with 564 additions and 244 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Option for ignoring specific basestations in automations.
- Support for setting custom hotkeys (With actions for sleep mode toggling/enabling/disabling, running sleep preparation, running the shutdown sequence, and turning devices on and off)
- Detection for initialization failures and error handling.
- Basic support for OSCQuery
- Added support for OSCQuery
- Status information view to the settings, for showing technical information regarding OyasumiVR and some of its internals.
- Automation for running a OSC script whenever the user prepares to go to sleep.
- Added OSC command for turning on and turning off all base stations.

### Changed

- When your VRChat session expires and you've opted to store your credentials, OyasumiVR will automatically attempt to log you back in.
- Improved reliability of base station power management
- Brightness automations no longer apply on start as a default setting
- Updated to Tauri v1.5
- Rewrote OSC control (Old OSC addresses remain supported, but check the wiki page on OSC control for any updates)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion src-core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ enumset = "1.1.3"

[dependencies.oyasumivr_oscquery]
git = "https://github.com/Raphiiko/oyasumivr_oscquery.git"
rev = "ef784f9"
rev = "2fe4ca1"
# path = "../../oyasumivr-oscquery"

[dependencies.tauri]
Expand Down
2 changes: 2 additions & 0 deletions src-core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ fn configure_command_handlers() -> impl Fn(tauri::Invoke) {
osc::commands::stop_osc_server,
osc::commands::get_vrchat_osc_address,
osc::commands::get_vrchat_oscquery_address,
osc::commands::add_osc_method,
osc::commands::set_osc_method_value,
system_tray::commands::set_close_to_system_tray,
system_tray::commands::set_start_in_system_tray,
elevated_sidecar::commands::elevated_sidecar_started,
Expand Down
12 changes: 12 additions & 0 deletions src-core/src/osc/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{OSC_RECEIVE_SOCKET, OSC_SEND_SOCKET};
use log::{debug, error, info};
use oyasumivr_oscquery::OSCMethod;
use rosc::{encoder, OscMessage, OscPacket, OscType};
use std::{
net::{SocketAddrV4, UdpSocket},
Expand Down Expand Up @@ -99,6 +100,17 @@ pub async fn start_osc_server() -> Option<(String, Option<String>)> {
Some((osc_addr_string, osc_query_addr_string))
}

#[tauri::command]
pub async fn add_osc_method(method: OSCMethod) {
oyasumivr_oscquery::server::add_osc_method(method).await;
}

#[tauri::command]
pub async fn set_osc_method_value(address: String, value: String) {
oyasumivr_oscquery::server::set_osc_method_value(address, Some(value)).await;
}


#[tauri::command]
pub async fn osc_send_int(addr: String, osc_addr: String, data: i32) -> Result<bool, String> {
debug!(
Expand Down
3 changes: 1 addition & 2 deletions src-ui/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import { SleepingAnimationPresetModalComponent } from './components/sleeping-ani
import { VRChatLogService } from './services/vrchat-log.service';
import { StatusChangeForPlayerCountAutomationService } from './services/status-automations/status-change-for-player-count-automation.service';
import { MainStatusBarComponent } from './components/main-status-bar/main-status-bar.component';
import { OscControlService } from './services/osc-control.service';
import { AutoInviteRequestAcceptViewComponent } from './views/dashboard-view/views/auto-invite-request-accept-view/auto-invite-request-accept-view.component';
import { FriendSelectionModalComponent } from './components/friend-selection-modal/friend-selection-modal.component';
import { CachedValue } from './utils/cached-value';
Expand Down Expand Up @@ -185,7 +184,7 @@ import { HotkeyHandlerService } from './services/hotkey-handler.service';
import { SettingsStatusInfoViewComponent } from './views/dashboard-view/views/settings-status-info-view/settings-status-info-view.component';
import { ask } from '@tauri-apps/api/dialog';
import { exit } from '@tauri-apps/api/process';
import { cloneDeep } from 'lodash';
import { OscControlService } from './services/osc-control/osc-control.service';

[
localeEN,
Expand Down
239 changes: 0 additions & 239 deletions src-ui/app/services/osc-control.service.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { OscMethod } from '../osc-method';
import { OscService } from '../../osc.service';
import { OSCBoolValue, OSCMessage } from '../../../models/osc-message';
import { info } from 'tauri-plugin-log-api';
import { distinctUntilChanged, map, switchMap } from 'rxjs';
import { AutomationConfigService } from '../../automation-config.service';

export class AutoAcceptVRCInviteRequestsOscMethod extends OscMethod<boolean> {
constructor(osc: OscService, private automationConfig: AutomationConfigService) {
super(osc, {
description:
'Enabled status of the automation for automatically accepting VRChat invite requests',
address: '/OyasumiVR/Automation/AutoAcceptVRCInviteRequests',
addressAliases: ['/Oyasumi/AutoAcceptInviteRequests'],
type: 'Bool',
initialValue: false,
isVRCAvatarParameter: true,
access: 'ReadWrite',
});
automationConfig.configs
.pipe(
map((c) => c.AUTO_ACCEPT_INVITE_REQUESTS.enabled),
distinctUntilChanged(),
switchMap((enabled) => this.setValue(enabled))
)
.subscribe();
}

async handleOSCMessage(message: OSCMessage) {
const { value: enable } = message.values[0] as OSCBoolValue;
if (this.value === enable) return;
await this.setValue(enable);
if (enable) info('[OSCControl] Enabling automatic invite request acceptance');
else info('[OSCControl] Disabling automatic invite request acceptance');
await this.automationConfig.updateAutomationConfig('AUTO_ACCEPT_INVITE_REQUESTS', {
enabled: enable,
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { OscService } from '../../osc.service';
import { OscMethod } from '../osc-method';
import { OSCMessage, OSCStringValue } from '../../../models/osc-message';
import { OscControlService } from '../osc-control.service';

export class AvatarChangeOscMethod extends OscMethod<string> {
constructor(osc: OscService, private oscControl: OscControlService) {
super(osc, {
description: 'Notify OyasumiVR of the user switching avatar in VRChat',
address: '/avatar/change',
addressAliases: [],
type: 'String',
initialValue: '',
isVRCAvatarParameter: false,
access: 'Write',
});
}

async handleOSCMessage(message: OSCMessage) {
const { value: avatarId } = message.values[0] as OSCStringValue;
if (this.value === avatarId) return;
await this.setValue(avatarId);
// Trigger resync of all VRChat parameters
await this.oscControl.resyncAllVRCParameters();
}
}
Loading

0 comments on commit 814645b

Please sign in to comment.