Skip to content

Commit

Permalink
Add Oculus Dash watch dog (Not responding = writing to Textbox + /inp…
Browse files Browse the repository at this point in the history
…ut/Voice =1)
  • Loading branch information
Sergey004 committed Jul 29, 2023
1 parent 0463461 commit 87f1ba9
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 24 deletions.
1 change: 1 addition & 0 deletions Quest2-VRC.GUI/Form2.Designer.cs

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

1 change: 1 addition & 0 deletions Quest2-VRC.GUI/Form2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@ private void materialButton2_Click(object sender, EventArgs e)

}


}
}
43 changes: 42 additions & 1 deletion Quest2-VRC.GUI/OculusStaff.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Printing;
using static Quest2_VRC.PacketSender;
using static Quest2_VRC.Logger;

namespace Quest2_VRC
{
Expand Down Expand Up @@ -61,7 +65,6 @@ public async static void HighPriority()


}

public async static void NormalPriority()

Check warning on line 68 in Quest2-VRC.GUI/OculusStaff.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 68 in Quest2-VRC.GUI/OculusStaff.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
Process[] OculusClient = Process.GetProcessesByName("OculusClient");
Expand All @@ -88,5 +91,43 @@ public async static void NormalPriority()
Console.WriteLine("Priority set to Normal");

}
public async static void DashWatchDog()

Check warning on line 94 in Quest2-VRC.GUI/OculusStaff.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 94 in Quest2-VRC.GUI/OculusStaff.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
string OculusBase = "OculusBase";
var value = System.Environment.GetEnvironmentVariable(OculusBase);
while (true)
{
Process[] procs;
procs = Process.GetProcessesByName("OculusDash");
bool restartRequired = false;
foreach (Process proc in procs)
{
if (!proc.Responding)
{
string inputbox = "input";
restartRequired = true;
LogToConsole("Error: Oculus dash crashed, waiting for app restart and enabling Voice Chat");
VRChatMessage MsgErr = new VRChatMessage(inputbox, "Error: Oculus dash crashed, waiting for app restart and enabling Voice Chat");
SendPacket(MsgErr);
string input = "Voice";
VRChatMessage VoiceReleased = new VRChatMessage(input, 0);
SendPacket(VoiceReleased);
VRChatMessage VoicePressed = new VRChatMessage(input, 1);
SendPacket(VoicePressed);

proc.Kill();
break;
}
}

if (restartRequired)
{
Process procRun = new Process();
procRun.StartInfo.FileName = value + "Support\\oculus-dash\\dash\\bin\\OculusDash.exe";
procRun.Start();
}
}
}

}
}
6 changes: 6 additions & 0 deletions Quest2-VRC.GUI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Globalization;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;


Expand Down Expand Up @@ -36,6 +37,11 @@ static void Main(string[] args)
case "--enhanced-oculus-control":
OculusStaff.DisableASW();
OculusStaff.HighPriority();
var tasks = new[]
{
Task.Factory.StartNew(() => OculusStaff.DashWatchDog(), TaskCreationOptions.LongRunning),
};

GUI();
break;
default:
Expand Down
8 changes: 8 additions & 0 deletions Quest2-VRC.GUI/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"Quest2-VRC.GUI": {
"commandName": "Project",
"commandLineArgs": "--enhanced-oculus-control\r\n"
}
}
}
66 changes: 43 additions & 23 deletions Quest2-VRC/Services/PacketSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Linq;
using System.Net;
using static Quest2_VRC.Logger;

Expand Down Expand Up @@ -43,33 +44,50 @@ static public void SendPacket(params VRChatMessage[] Params)
OscBundle VRBundle = new OscBundle(VRChat);

// Create the message, and append the parameter to it
if (Param.Parameter == "input")
switch (Param.Parameter)
{

OscMessage Message = new OscMessage(VRChat, String.Format("/chatbox/{0}", Param.Parameter));
Message.Append(Param.Data);
Message.Append(true);
// Append the message to the bundle
VRBundle.Append(Message);

// Send the bundle to the target address and port
VRBundle.Send(VRChat);
}
else
{
OscMessage Message = new OscMessage(VRChat, String.Format("/avatar/parameters/{0}", Param.Parameter));
Message.Append(Param.Data);

// Append the message to the bundle

VRBundle.Append(Message);

// Send the bundle to the target address and port
VRBundle.Send(VRChat);
case var s when new[] { "MoveForward", "MoveBackward", "MoveLeft", "LookRight", "Jump", "Run", "ComfortLeft", "ComfortRight", "DropRight", "UseRight", "GrabRight", "DropLeft", "UseLeft", "GrabLeft", "PanicButton", "QuickMenuToggleLeft", "QuickMenuToggleRight", "Voice" }.Contains(s):
{
OscMessage Message = new OscMessage(VRChat, String.Format("/input/{0}", Param.Parameter));
Message.Append(Param.Data);
// Append the message to the bundle
VRBundle.Append(Message);

// Send the bundle to the target address and port
VRBundle.Send(VRChat);
break;
}
case "input":
{
OscMessage Message = new OscMessage(VRChat, String.Format("/chatbox/{0}", Param.Parameter));
Message.Append(Param.Data);
Message.Append(true);
// Append the message to the bundle
VRBundle.Append(Message);

// Send the bundle to the target address and port
VRBundle.Send(VRChat);
break;

}


default:
{
OscMessage Message = new OscMessage(VRChat, String.Format("/avatar/parameters/{0}", Param.Parameter));
Message.Append(Param.Data);

// Append the message to the bundle

VRBundle.Append(Message);

// Send the bundle to the target address and port
VRBundle.Send(VRChat);
break;
}
}



}
catch (Exception ex)
{
Expand All @@ -85,13 +103,15 @@ public class VRChatMessage
// The target of the data
public string? Parameter { get; }

Check warning on line 104 in Quest2-VRC/Services/PacketSender.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 104 in Quest2-VRC/Services/PacketSender.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 104 in Quest2-VRC/Services/PacketSender.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 104 in Quest2-VRC/Services/PacketSender.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.


// The data itself
public object? Data { get; }

Check warning on line 108 in Quest2-VRC/Services/PacketSender.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 108 in Quest2-VRC/Services/PacketSender.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

public VRChatMessage(string A, object B)
{
Parameter = A;
Data = B;

}

}
Expand Down

0 comments on commit 87f1ba9

Please sign in to comment.