Skip to content

Commit

Permalink
Merge pull request #23 from rogermiranda1000/fix-sa-init
Browse files Browse the repository at this point in the history
Fix SA/BS init
  • Loading branch information
miranda1000 authored Apr 14, 2024
2 parents 27a199d + 996b9ee commit c59326f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion PicoStreamingAssistantFTUDP/Pico4SAFTExtTrackingModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public override (bool eyeSuccess, bool expressionSuccess) Initialize(bool eyeAva
}

Logger.LogInformation("Initializing {} data stream.", this.connector.GetProcessName());
while (!this.disposedValue && !this.connector.Connect()) Thread.Sleep(4_000);
/*while (!this.disposedValue && !*/this.connector.Connect()/*) Thread.Sleep(4_000)*/;

if (this.disposedValue)
{
Expand Down
34 changes: 18 additions & 16 deletions PicoStreamingAssistantFTUDP/PicoConnectors/LegacyConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public bool Connect()
{
fixed (PxrFTInfo* pData = &data)
{
result = ReceivePxrData(pData);
result = ReceivePxrData(pData, reinit: false);
}
}

Expand All @@ -114,7 +114,7 @@ public bool Connect()
retry++;
// Magic
// Close the pico_et_ft_bt_bridge.exe process and reinitialize it.
// It will listen to UDP port 29763 before pico_et_ft_bt_bridge.exe runs.
// It will listen to UDP port before pico_et_ft_bt_bridge.exe runs.
// Note: exclusively to simplify older versions of the FT bridge,
// the bridge now works without any need for process killing.
Process proc = new()
Expand Down Expand Up @@ -195,7 +195,7 @@ public void Teardown()
}
}

private unsafe bool ReceivePxrData(PxrFTInfo* pData)
private unsafe bool ReceivePxrData(PxrFTInfo* pData, bool reinit = true)
{
if (this.IsDisposed()) return false;

Expand All @@ -217,19 +217,21 @@ private unsafe bool ReceivePxrData(PxrFTInfo* pData)
{
// socket time out
Logger.LogDebug("Data was not sent within the timeout. {msg}", ex.Message);
Logger.LogInformation("Data was not sent within the timeout (is headset hibernated?), reinitialize...");

// try to reinitialize
this.Teardown();
lock(this.socketLock) {
this.tryReinitializeThread = new Thread(new ThreadStart(() => {
bool connected;
do {
connected = this.Connect();
if (!connected) Thread.Sleep(200); // try again; we have to set a low number because VRCFT won't call `Teardown()` until all the updates are done
} while (!this.IsDisposed() && !connected);
}));
this.tryReinitializeThread.Start();
if (reinit) {
Logger.LogInformation("Data was not sent within the timeout (is headset hibernated?), reinitialize...");

// try to reinitialize
this.Teardown();
lock(this.socketLock) {
this.tryReinitializeThread = new Thread(new ThreadStart(() => {
bool connected;
do {
connected = this.Connect();
if (!connected) Thread.Sleep(200); // try again; we have to set a low number because VRCFT won't call `Teardown()` until all the updates are done
} while (!this.IsDisposed() && !connected);
}));
this.tryReinitializeThread.Start();
}
}

return false; // got byte failed
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ face tracking data.

You'll find the module in `PicoStreamingAssistantFTUDP\PicoStreamingAssistantFTUDP\bin\Debug\net7.0\Pico4SAFTExtTrackingModule.dll`.

#### Compiling VRCFaceTracking.Core

- If you get an error about `vcruntime140.dll`, modify (in the file `VRCFaceTracking\VRCFaceTracking.Core\VRCFaceTracking.Core.csproj`) the reference to `C:\Windows\System32\vcruntime140.dll`
- If you get an error about `fti_osc.dll`, modify (in the file `VRCFaceTracking\VRCFaceTracking.Core\VRCFaceTracking.Core.csproj`) the reference to ? (I just removed it lmao)

## Credits
- [Ben](https://github.com/benaclejames/) for VRCFaceTracking!
- [TofuLemon](https://github.com/ULemon/) with help testing, troubleshooting and providing crucial information that lead to the development of this module!
Expand Down
18 changes: 9 additions & 9 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"ModuleId": "4d885bd8-e97f-4e0d-be40-55c8503e0620",
"AuthorName": "Mitchell Taylor",
"DllFileName": "Pico4SAFTExtTrackingModule.dll",
"Downloads": 16,
"DownloadUrl": "https://github.com/regzo2/PicoStreamingAssistantFTUDP/releases/download/1.3.0/Pico4ProModule.zip",
"LastUpdated": "2023-04-20T01:08:01Z",
"ModuleDescription": "The module provides eye and face tracking compatibility with the Pico Steaming Assistant.",
"Downloads": 9892,
"DownloadUrl": "https://github.com/regzo2/PicoStreamingAssistantFTUDP/releases/download/1.4.1/Pico4ProModule.zip",
"LastUpdated": "2024-04-14T15:00:00Z",
"ModuleDescription": "The module provides eye and face tracking compatibility with PICO Connect, Streaming Assistant and Business Streaming.",
"ModuleName": "Pico4SAFTExtTrackingModule",
"ModulePageUrl": "https://github.com/regzo2/PicoStreamingAssistantFTUDP/tree/vrcfacetracking-module",
"Rating": 0,
"Ratings": 0,
"RatingSum": 0,
"UsageInstructions": "REQUIRES THE LATEST (currently unreleased) STREAMING ASSISTANT. This module will listen for any face tracking data coming from the Pico Streaming Assistant.",
"Version": "1.3"
"Rating": 4.341463414634147,
"Ratings": 164,
"RatingSum": 712,
"UsageInstructions": "Requires PICO Connect/Streaming Assistant (for PICO 4 PRO) or Business Streaming (for PICO 4 enterprise). This module will listen for any face tracking data coming from the Pico Streaming Assistant.",
"Version": "1.4.1"
}

0 comments on commit c59326f

Please sign in to comment.