Skip to content

Commit

Permalink
Push new Overlay build.
Browse files Browse the repository at this point in the history
  • Loading branch information
Soapwood committed Apr 29, 2024
1 parent ee0b794 commit 170d5b6
Show file tree
Hide file tree
Showing 22 changed files with 106 additions and 36 deletions.
2 changes: 1 addition & 1 deletion VXMusicDesktop/MVVM/ViewModel/SharedViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private void OnVXMusicOverlayRunningChanged()
if (!IsRecognitionRunning && !IsOverlayRunning && VXMusicOverlayInterface.OverlayWasRunning)
{
Logger.LogError("VXMusicOverlay has timed out!");
VXMusicSession.NotificationClient.SendNotification("VXMusic Overlay has disconnected.", "", 4);
//VXMusicSession.NotificationClient.SendNotification("VXMusic Overlay has disconnected.", "", 4);
VXMusicOverlayInterface.OverlayWasRunning = false;
}
}
Expand Down
Binary file not shown.
Binary file modified VXMusicDesktop/Overlay/bin/VXMOverlay_Data/globalgamemanagers
Binary file not shown.
Binary file not shown.
Binary file modified VXMusicDesktop/Overlay/bin/VXMOverlay_Data/level0
Binary file not shown.
11 changes: 11 additions & 0 deletions VXMusicDesktop/Theme/ColourSchemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public class ColourSchemeManager
public static readonly string LightmodeSaveButton = "Images/SaveIconBlack.png";

public static readonly string VXMusicOverlayButton = "Images/VXLogoTinyButton.png";

public static readonly string LeftHandButton = "Images/LeftHandIcon.png";
public static readonly string RightHandButton = "Images/RightHandIcon.png";

public static SolidColorBrush PrimaryColour { get; set; }
public static SolidColorBrush SecondaryColour { get; set; }
Expand All @@ -85,6 +88,8 @@ public class ColourSchemeManager
public static BitmapImage MinimiseImage { get; set; }
public static BitmapImage SaveButtonImage { get; set; }
public static BitmapImage VXMusicOverlayImage { get; set; }
public static BitmapImage LeftHandImage { get; set; }
public static BitmapImage RightHandImage { get; set; }

// This is used to access the values of the DesktopTheme Enum in XAML
public static DesktopTheme[] DesktopThemeValues
Expand Down Expand Up @@ -135,6 +140,8 @@ private static void SetThemeDarkmode1()
MinimiseImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.DarkmodeMinimiseButton}"));
SaveButtonImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.DarkmodeSaveButton}"));
VXMusicOverlayImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.VXMusicOverlayButton}"));
LeftHandImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.LeftHandButton}"));
RightHandImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.RightHandButton}"));
Transparent = new SolidColorBrush(FromHex(TransparentColour));
}

Expand All @@ -151,6 +158,8 @@ private static void SetThemeDarkmode2()
MinimiseImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.DarkmodeMinimiseButton}"));
SaveButtonImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.DarkmodeSaveButton}"));
VXMusicOverlayImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.VXMusicOverlayButton}"));
LeftHandImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.LeftHandButton}"));
RightHandImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.RightHandButton}"));
Transparent = new SolidColorBrush(FromHex(TransparentColour));
}

Expand All @@ -167,6 +176,8 @@ private static void SetThemeLightmode1()
MinimiseImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.LightmodeMinimiseButton}"));
SaveButtonImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.LightmodeSaveButton}"));
VXMusicOverlayImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.VXMusicOverlayButton}"));
LeftHandImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.LeftHandButton}"));
RightHandImage = new BitmapImage(new Uri($"pack://application:,,,/VXMusicDesktop;component/{ColourSchemeManager.RightHandButton}"));
Transparent = new SolidColorBrush(FromHex(TransparentColour));
}

Expand Down
78 changes: 66 additions & 12 deletions VXMusicOverlay/Assets/Plugins/VXMusicInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,28 @@ public class VXMusicInterface : MonoBehaviour
private StreamReader ClientReader;
private StreamWriter ClientWriter;
public event Action<string> ServerResponseReceived;

public bool IsInRecognitionState = false;
public bool IsAnimationRunning = false;
public event Action<bool> OnRecognitionStateTriggered;

public bool IsListening = false;

private void Start()
{
IsVXMusicServerRunning();
}

public void IsVXMusicServerRunning()
{
// Create and connect the ClientStream
ClientStream = new NamedPipeClientStream(".", "VXMusicOverlayEventPipe", PipeDirection.InOut);
ClientStream.Connect();

// Initialize ClientReader and ClientWriter
ClientReader = new StreamReader(ClientStream);
ClientWriter = new StreamWriter(ClientStream) { AutoFlush = true };

string messageToSend = "VX_CONNECT_REQ";
ClientWriter.WriteLine(messageToSend);
ClientStream.WaitForPipeDrain();
Expand All @@ -43,19 +45,71 @@ public void IsVXMusicServerRunning()
{
Debug.Log("Received response from .NET: " + response);
}

ClientStream.Close();
ClientStream = null;

ClientReader.Close();
ClientReader = null;
ClientWriter.Close();
ClientWriter = null;
}

public void IsVXMusicOverlayRunning()
public async void ListenForVXMusicDesktopEvent()
{

// Create and connect the ClientStream
//ClientStream = new NamedPipeClientStream(".", "VXMusicOverlayEventPipeHandUpdate", PipeDirection.InOut);
//ClientStream.Connect();

// Initialize ClientReader and ClientWriter
//ClientReader = new StreamReader(ClientStream);
//ClientWriter = new StreamWriter(ClientStream) { AutoFlush = true };

using (NamedPipeServerStream serverStream =
new NamedPipeServerStream("VXMusicOverlayEventPipeHandUpdate", PipeDirection.InOut))
{
Debug.Log("Waiting for Overlay request from VXMusicDesktop");
IsListening = true;
serverStream.WaitForConnection();
//_isProcessing = true;

using (StreamReader reader = new StreamReader(serverStream))
using (StreamWriter writer = new StreamWriter(serverStream) { AutoFlush = true })
{
writer.WriteLine("VX_CONNECT_ACK");

string eventData = await reader.ReadLineAsync();
Debug.Log($"Received event from VXMusic Desktop Client: {eventData}");
//await ProcessIncomingUnityEventMessage(writer, eventData);
}
}

//string messageToSend = "VX_CONNECT_REQ";
//ClientWriter.WriteLine(messageToSend);
// ClientStream.WaitForPipeDrain();

// Read the response from the .NET server
// string response = ClientReader.ReadLine();
//
// if (response == "VX_OVERLAY_ANCHOR_LEFTHAND_REQ")
// {
// Debug.Log("Received response from .NET: " + response);
// }
//
// if (response == "VX_OVERLAY_ANCHOR_RIGHTHAND_REQ")
// {
// Debug.Log("Received response from .NET: " + response);
// }

ClientStream.Close();
ClientStream = null;

ClientReader.Close();
ClientReader = null;
ClientWriter.Close();
ClientWriter = null;

IsListening = false;
}

public async Task SendMessageToServer(string request)
Expand All @@ -67,15 +121,15 @@ public async Task SendMessageToServer(string request)

ClientStream = new NamedPipeClientStream(".", "VXMusicOverlayEventPipe", PipeDirection.InOut);
ClientStream.Connect();

//ClientStream.Connect();
// This is also fucked
ClientWriter = new StreamWriter(ClientStream) { AutoFlush = true };
ClientWriter.WriteLine(request);
//ClientWriter.Flush();

ClientReader = new StreamReader(ClientStream);

// Read the response from the .NET server
string response = await ClientReader.ReadLineAsync();

Expand All @@ -88,7 +142,7 @@ public async Task SendMessageToServer(string request)
}

response = await ClientReader.ReadLineAsync();

if (response == "VX_RECOGNITION_FIN")
{
Debug.Log("Received REC FIN response from .NET: " + response);
Expand Down
21 changes: 13 additions & 8 deletions VXMusicOverlay/Assets/Plugins/VXMusicOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
using System.Text;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Purchasing;
using Valve.VR;

namespace Plugins
Expand Down Expand Up @@ -347,10 +348,10 @@ private void Start()
#pragma warning restore 0219
Debug.Log(Tag + "Begin");

LeftDebugSphere = Instantiate(spherePrefab, Vector3.zero, Quaternion.identity);
LeftDebugSphere.GetComponent<Renderer>().material.color = Color.green;
RightDebugSphere = Instantiate(spherePrefab, Vector3.zero, Quaternion.identity);
RightDebugSphere.GetComponent<Renderer>().material.color = Color.green;
//LeftDebugSphere = Instantiate(spherePrefab, Vector3.zero, Quaternion.identity);
//LeftDebugSphere.GetComponent<Renderer>().material.color = Color.green;
//RightDebugSphere = Instantiate(spherePrefab, Vector3.zero, Quaternion.identity);
//RightDebugSphere.GetComponent<Renderer>().material.color = Color.green;

var openVRError = EVRInitError.None;
var overlayError = EVROverlayError.None;
Expand Down Expand Up @@ -448,6 +449,10 @@ private void Update()
_VXMusicInterface.SendMessageToServer("VX_HEARTBEAT_REQ");
_timeSinceLastHeartbeat = 0f;
}

// Listen for incoming event
//if (!_VXMusicInterface.IsListening)
//_VXMusicInterface.ListenForVXMusicDesktopEvent();

if (show)
{
Expand Down Expand Up @@ -895,15 +900,15 @@ private void updateVRTouch()
{
SteamVR_Utils.RigidTransform leftControllerTransform = new SteamVR_Utils.RigidTransform(allDevicePose[Leftidx].mDeviceToAbsoluteTracking);

LeftDebugSphere.transform.position = leftControllerTransform.pos;
//LeftDebugSphere.transform.position = leftControllerTransform.pos;

// Calculate finger offset from controller
Vector3 fingerOffset = new Vector3(FingerOffsetX, FingerOffsetY, FingerOffsetZ); // Tweak these offsets!
Quaternion fingerRotationOffset = Quaternion.Euler(FingerRotationOffsetX, FingerRotationOffsetY, FingerRotationOffsetZ); // Assuming the finger points slightly differently
Vector3 fingerPosition = leftControllerTransform.TransformPoint(fingerOffset);
Quaternion fingerRotation = leftControllerTransform.rot * fingerRotationOffset;

Debug.DrawLine(fingerPosition, fingerPosition + (fingerRotation * Vector3.forward) * 2.0f, Color.blue);
//Debug.DrawLine(fingerPosition, fingerPosition + (fingerRotation * Vector3.forward) * 2.0f, Color.blue);

//if (checkRay(Leftidx, allDevicePose, ref results))
if (checkRay(Leftidx, fingerPosition, fingerRotation * Vector3.forward, ref results))
Expand All @@ -930,15 +935,15 @@ private void updateVRTouch()
{
SteamVR_Utils.RigidTransform rightControllerTransform = new SteamVR_Utils.RigidTransform(allDevicePose[Rightidx].mDeviceToAbsoluteTracking);

RightDebugSphere.transform.position = rightControllerTransform.pos;
//RightDebugSphere.transform.position = rightControllerTransform.pos;

// Calculate finger offset from controller
Vector3 fingerOffset = new Vector3(FingerOffsetX, FingerOffsetY, FingerOffsetZ); // Tweak these offsets!
Quaternion fingerRotationOffset = Quaternion.Euler(FingerRotationOffsetX, FingerRotationOffsetY, FingerRotationOffsetZ); // Assuming the finger points slightly differently
Vector3 fingerPosition = rightControllerTransform.TransformPoint(fingerOffset);
Quaternion fingerRotation = rightControllerTransform.rot * fingerRotationOffset;

Debug.DrawLine(fingerPosition, fingerPosition + (fingerRotation * Vector3.forward) * 2.0f, Color.blue);
//Debug.DrawLine(fingerPosition, fingerPosition + (fingerRotation * Vector3.forward) * 2.0f, Color.blue);

if (checkRay(Rightidx, fingerPosition, fingerRotation * Vector3.forward, ref results))
{
Expand Down
Binary file modified VXMusicOverlay/Library/ArtifactDB
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file modified VXMusicOverlay/Library/LastBuild.buildreport
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified VXMusicOverlay/Library/PlayerDataCache/Win64/Data/level0
Binary file not shown.
22 changes: 11 additions & 11 deletions VXMusicOverlay/Library/PlayerDataCache/Win64/ScriptsOnlyCache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,25 @@ ScriptsOnlyBuild:
- Class: 108
Script: {instanceID: 0}
- Class: 114
Script: {instanceID: 2580}
Script: {instanceID: 2582}
- Class: 114
Script: {instanceID: 2600}
Script: {instanceID: 2602}
- Class: 114
Script: {instanceID: 2806}
Script: {instanceID: 2808}
- Class: 114
Script: {instanceID: 2968}
Script: {instanceID: 2970}
- Class: 114
Script: {instanceID: 3238}
Script: {instanceID: 3240}
- Class: 114
Script: {instanceID: 3484}
Script: {instanceID: 3486}
- Class: 114
Script: {instanceID: 3606}
Script: {instanceID: 3608}
- Class: 114
Script: {instanceID: 4052}
Script: {instanceID: 4054}
- Class: 114
Script: {instanceID: 5162}
Script: {instanceID: 5164}
- Class: 114
Script: {instanceID: 5972}
Script: {instanceID: 5974}
- Class: 115
Script: {instanceID: 0}
- Class: 122
Expand Down Expand Up @@ -248,7 +248,7 @@ ScriptsOnlyBuild:
className: RawImage
- hash:
serializedVersion: 2
Hash: 37c9b6a362d507f4aa5a7d787744de4b
Hash: 4654e4ea40b057b20dcafc3f5bb82420
assemblyName: Assembly-CSharp-firstpass.dll
namespaceName: Valve.VR
className: VXMusicInterface
Expand Down
Binary file modified VXMusicOverlay/Library/SceneVisibilityState.asset
Binary file not shown.
Binary file not shown.
Binary file modified VXMusicOverlay/Library/SourceAssetDB
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"m_ScrollY":0.0,"m_ExpandedSceneGameObjectInstanceIDs":[-1178],"m_LastClickedInstanceID":17278,"m_OpenSceneGUIDs":["2c4e792b9b0e75049ad02099913f62ef"]}
{"m_ScrollY":0.0,"m_ExpandedSceneGameObjectInstanceIDs":[-1190],"m_LastClickedInstanceID":0,"m_OpenSceneGUIDs":["2c4e792b9b0e75049ad02099913f62ef"]}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"cameraMode":{"drawMode":0,"name":"Shaded","section":"Shading Mode"},"sceneLighting":true,"audioPlay":false,"sceneViewState":{"m_AlwaysRefresh":false,"showFog":true,"showSkybox":true,"showFlares":true,"showImageEffects":true,"showParticleSystems":true,"showVisualEffectGraphs":true,"m_FxEnabled":true},"in2DMode":false,"pivot":{"x":10.426570892333985,"y":-6.731657981872559,"z":-4.486052513122559},"rotation":{"x":0.15881375968456269,"y":0.708757221698761,"z":-0.1689440757036209,"w":0.6662585735321045},"size":16.0491886138916,"orthographic":false}
{"cameraMode":{"drawMode":0,"name":"Shaded","section":"Shading Mode"},"sceneLighting":true,"audioPlay":false,"sceneViewState":{"m_AlwaysRefresh":false,"showFog":true,"showSkybox":true,"showFlares":true,"showImageEffects":true,"showParticleSystems":true,"showVisualEffectGraphs":true,"m_FxEnabled":true},"in2DMode":false,"pivot":{"x":10.426570892333985,"y":-6.731657981872559,"z":-4.486052513122559},"rotation":{"x":0.15881375968456269,"y":0.708757221698761,"z":-0.1689440757036209,"w":0.6662585735321045},"size":21.350433349609376,"orthographic":false}

0 comments on commit 170d5b6

Please sign in to comment.