-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into steam-beta
- Loading branch information
Showing
8 changed files
with
179 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src-ui/app/services/hotfixes/f-b-t-avatar-reload-hotfix.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { OpenVRService } from '../openvr.service'; | ||
import { | ||
asyncScheduler, | ||
distinctUntilChanged, | ||
filter, | ||
map, | ||
pairwise, | ||
switchMap, | ||
take, | ||
throttleTime, | ||
} from 'rxjs'; | ||
import { isEqual } from 'lodash'; | ||
import { OscService } from '../osc.service'; | ||
import { sleep } from '../../utils/promise-utils'; | ||
import { info } from 'tauri-plugin-log-api'; | ||
import { SleepingAnimationsAutomationService } from '../osc-automations/sleeping-animations-automation.service'; | ||
import { VRChatService } from '../vrchat.service'; | ||
import { AutomationConfigService } from '../automation-config.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class FBTAvatarReloadHotfixService { | ||
private enabled = false; | ||
|
||
constructor( | ||
private openvr: OpenVRService, | ||
private osc: OscService, | ||
private vrchat: VRChatService, | ||
private sleepAnimations: SleepingAnimationsAutomationService, | ||
private automationConfig: AutomationConfigService | ||
) {} | ||
|
||
async init() { | ||
this.automationConfig.configs | ||
.pipe(map((configs) => configs.SLEEPING_ANIMATIONS.enableAvatarReloadOnFBTDisableHotfix)) | ||
.subscribe((enabled) => (this.enabled = enabled)); | ||
this.openvr.devices | ||
.pipe( | ||
// Only run if this hotfix is enabled | ||
filter(() => this.enabled), | ||
// Detect all trackers turning off | ||
map((devices) => | ||
devices | ||
.filter((d) => d.class === 'GenericTracker' && (d.canPowerOff || d.isTurningOff)) | ||
.map((d) => d.serialNumber) | ||
), | ||
pairwise(), | ||
distinctUntilChanged((a, b) => isEqual(a, b)), | ||
filter(([prev, curr]) => prev.length > 0 && curr.length === 0), | ||
// Only run while VRChat is active | ||
switchMap(() => this.vrchat.vrchatProcessActive.pipe(take(1))), | ||
filter(Boolean), | ||
// Only trigger once every 5s max | ||
throttleTime(5000, asyncScheduler, { leading: true, trailing: false }) | ||
) | ||
.subscribe(() => this.triggerHotfix()); | ||
} | ||
|
||
private async triggerHotfix() { | ||
info( | ||
'[FBTAvatarReloadHotfix] All trackers have been turned off. Running hotfix to reload avatar' | ||
); | ||
// Wait for VRC to process the trackers fully turning off | ||
await sleep(3000); | ||
|
||
// Open the quick menu | ||
await this.osc.send_int('/input/QuickMenuToggleLeft', 0); | ||
await sleep(150); | ||
await this.osc.send_int('/input/QuickMenuToggleLeft', 1); | ||
await sleep(150); | ||
await this.osc.send_int('/input/QuickMenuToggleLeft', 0); | ||
|
||
// Wait a bit | ||
await sleep(500); | ||
|
||
// Close the quick menu | ||
await this.osc.send_int('/input/QuickMenuToggleLeft', 0); | ||
await sleep(150); | ||
await this.osc.send_int('/input/QuickMenuToggleLeft', 1); | ||
await sleep(150); | ||
await this.osc.send_int('/input/QuickMenuToggleLeft', 0); | ||
|
||
// Inform sleeping automations to reapply | ||
await this.sleepAnimations.retrigger(); | ||
|
||
info('[FBTAvatarReloadHotfix] Hotfix applied'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters