mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 14:46:04 +02:00
Respect if overlay is toggled
This commit is contained in:
@@ -356,18 +356,18 @@ namespace VRCX
|
|||||||
|
|
||||||
public void ExecuteVrFeedFunction(string function, string json)
|
public void ExecuteVrFeedFunction(string function, string json)
|
||||||
{
|
{
|
||||||
if (VRCXVR._browser1 == null) return;
|
if (VRCXVR._wristOverlay == null) return;
|
||||||
if (VRCXVR._browser1.IsLoading)
|
if (VRCXVR._wristOverlay.IsLoading)
|
||||||
VRCXVR.Instance.Restart();
|
VRCXVR.Instance.Restart();
|
||||||
VRCXVR._browser1.ExecuteScriptAsync($"$app.{function}", json);
|
VRCXVR._wristOverlay.ExecuteScriptAsync($"$app.{function}", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExecuteVrOverlayFunction(string function, string json)
|
public void ExecuteVrOverlayFunction(string function, string json)
|
||||||
{
|
{
|
||||||
if (VRCXVR._browser2 == null) return;
|
if (VRCXVR._hmdOverlay == null) return;
|
||||||
if (VRCXVR._browser2.IsLoading)
|
if (VRCXVR._hmdOverlay.IsLoading)
|
||||||
VRCXVR.Instance.Restart();
|
VRCXVR.Instance.Restart();
|
||||||
VRCXVR._browser2.ExecuteScriptAsync($"$app.{function}", json);
|
VRCXVR._hmdOverlay.ExecuteScriptAsync($"$app.{function}", json);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
+66
-34
@@ -33,20 +33,28 @@ namespace VRCX
|
|||||||
private static readonly float[] _translationRight = { 7f / 100f, -5f / 100f, 6f / 100f };
|
private static readonly float[] _translationRight = { 7f / 100f, -5f / 100f, 6f / 100f };
|
||||||
private static readonly float[] _rotationLeft = { 90f * (float)(Math.PI / 180f), 90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f) };
|
private static readonly float[] _rotationLeft = { 90f * (float)(Math.PI / 180f), 90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f) };
|
||||||
private static readonly float[] _rotationRight = { -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f) };
|
private static readonly float[] _rotationRight = { -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f), -90f * (float)(Math.PI / 180f) };
|
||||||
public static OffScreenBrowser _browser1;
|
public static OffScreenBrowser _wristOverlay;
|
||||||
public static OffScreenBrowser _browser2;
|
public static OffScreenBrowser _hmdOverlay;
|
||||||
private readonly List<string[]> _deviceList;
|
private readonly List<string[]> _deviceList;
|
||||||
private readonly ReaderWriterLockSlim _deviceListLock;
|
private readonly ReaderWriterLockSlim _deviceListLock;
|
||||||
private bool _active;
|
private bool _active;
|
||||||
private Device _device;
|
private Device _device;
|
||||||
private bool _hmdOverlayActive;
|
|
||||||
private bool _menuButton;
|
private bool _menuButton;
|
||||||
private int _overlayHand;
|
private int _overlayHand;
|
||||||
|
private Factory _factory;
|
||||||
private Texture2D _texture1;
|
private Texture2D _texture1;
|
||||||
private Texture2D _texture2;
|
private Texture2D _texture2;
|
||||||
private Thread _thread;
|
private Thread _thread;
|
||||||
private bool _wristOverlayActive;
|
|
||||||
private DateTime _nextOverlayUpdate;
|
private DateTime _nextOverlayUpdate;
|
||||||
|
|
||||||
|
private ulong _hmdOverlayHandle;
|
||||||
|
private bool _hmdOverlayActive;
|
||||||
|
private bool _hmdOverlayWasActive;
|
||||||
|
|
||||||
|
private ulong _wristOverlayHandle;
|
||||||
|
private bool _wristOverlayActive;
|
||||||
|
private bool _wristOverlayWasActive;
|
||||||
|
|
||||||
public bool IsHmdAfk { get; private set; }
|
public bool IsHmdAfk { get; private set; }
|
||||||
|
|
||||||
static VRCXVR()
|
static VRCXVR()
|
||||||
@@ -89,8 +97,10 @@ namespace VRCX
|
|||||||
|
|
||||||
private void SetupTextures()
|
private void SetupTextures()
|
||||||
{
|
{
|
||||||
Factory f = new Factory1();
|
_factory ??= new Factory1();
|
||||||
_device = new Device(f.GetAdapter(OpenVR.System.GetD3D9AdapterIndex()),
|
|
||||||
|
_device?.Dispose();
|
||||||
|
_device = new Device(_factory.GetAdapter(OpenVR.System.GetD3D9AdapterIndex()),
|
||||||
DeviceCreationFlags.BgraSupport);
|
DeviceCreationFlags.BgraSupport);
|
||||||
UpgradeDevice();
|
UpgradeDevice();
|
||||||
|
|
||||||
@@ -108,7 +118,7 @@ namespace VRCX
|
|||||||
BindFlags = BindFlags.ShaderResource
|
BindFlags = BindFlags.ShaderResource
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
_browser1?.UpdateRender(_device, _texture1);
|
_wristOverlay?.UpdateRender(_device, _texture1);
|
||||||
|
|
||||||
_texture2?.Dispose();
|
_texture2?.Dispose();
|
||||||
_texture2 = new Texture2D(
|
_texture2 = new Texture2D(
|
||||||
@@ -124,7 +134,7 @@ namespace VRCX
|
|||||||
BindFlags = BindFlags.ShaderResource
|
BindFlags = BindFlags.ShaderResource
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
_browser2?.UpdateRender(_device, _texture2);
|
_hmdOverlay?.UpdateRender(_device, _texture2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpgradeDevice()
|
private void UpgradeDevice()
|
||||||
@@ -176,16 +186,14 @@ namespace VRCX
|
|||||||
var overlayVisible1 = false;
|
var overlayVisible1 = false;
|
||||||
var overlayVisible2 = false;
|
var overlayVisible2 = false;
|
||||||
var dashboardHandle = 0UL;
|
var dashboardHandle = 0UL;
|
||||||
var overlayHandle1 = 0UL;
|
|
||||||
var overlayHandle2 = 0UL;
|
|
||||||
|
|
||||||
_browser1 = new OffScreenBrowser(
|
_wristOverlay = new OffScreenBrowser(
|
||||||
"file://vrcx/vr.html?1",
|
"file://vrcx/vr.html?1",
|
||||||
512,
|
512,
|
||||||
512
|
512
|
||||||
);
|
);
|
||||||
|
|
||||||
_browser2 = new OffScreenBrowser(
|
_hmdOverlay = new OffScreenBrowser(
|
||||||
"file://vrcx/vr.html?2",
|
"file://vrcx/vr.html?2",
|
||||||
1024,
|
1024,
|
||||||
1024
|
1024
|
||||||
@@ -264,22 +272,30 @@ namespace VRCX
|
|||||||
logger.Error(err);
|
logger.Error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ProcessOverlay1(overlay, ref overlayHandle1, ref overlayVisible1, dashboardVisible, overlayIndex);
|
if (_wristOverlayActive)
|
||||||
if (err != EVROverlayError.None &&
|
|
||||||
overlayHandle1 != 0)
|
|
||||||
{
|
{
|
||||||
overlay.DestroyOverlay(overlayHandle1);
|
err = ProcessOverlay1(overlay, ref _wristOverlayHandle, ref overlayVisible1,
|
||||||
overlayHandle1 = 0;
|
dashboardVisible, overlayIndex);
|
||||||
logger.Error(err);
|
if (err != EVROverlayError.None &&
|
||||||
|
_wristOverlayHandle != 0)
|
||||||
|
{
|
||||||
|
overlay.DestroyOverlay(_wristOverlayHandle);
|
||||||
|
_wristOverlayHandle = 0;
|
||||||
|
logger.Error(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ProcessOverlay2(overlay, ref overlayHandle2, ref overlayVisible2, dashboardVisible);
|
if (_hmdOverlayActive)
|
||||||
if (err != EVROverlayError.None &&
|
|
||||||
overlayHandle2 != 0)
|
|
||||||
{
|
{
|
||||||
overlay.DestroyOverlay(overlayHandle2);
|
err = ProcessOverlay2(overlay, ref _hmdOverlayHandle, ref overlayVisible2,
|
||||||
overlayHandle2 = 0;
|
dashboardVisible);
|
||||||
logger.Error(err);
|
if (err != EVROverlayError.None &&
|
||||||
|
_hmdOverlayHandle != 0)
|
||||||
|
{
|
||||||
|
overlay.DestroyOverlay(_hmdOverlayHandle);
|
||||||
|
_hmdOverlayHandle = 0;
|
||||||
|
logger.Error(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -301,8 +317,8 @@ namespace VRCX
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_browser2?.Dispose();
|
_hmdOverlay?.Dispose();
|
||||||
_browser1?.Dispose();
|
_wristOverlay?.Dispose();
|
||||||
_texture2?.Dispose();
|
_texture2?.Dispose();
|
||||||
_texture1?.Dispose();
|
_texture1?.Dispose();
|
||||||
_device?.Dispose();
|
_device?.Dispose();
|
||||||
@@ -315,12 +331,28 @@ namespace VRCX
|
|||||||
_wristOverlayActive = wristOverlay;
|
_wristOverlayActive = wristOverlay;
|
||||||
_menuButton = menuButton;
|
_menuButton = menuButton;
|
||||||
_overlayHand = overlayHand;
|
_overlayHand = overlayHand;
|
||||||
|
|
||||||
|
if (_hmdOverlayActive != _hmdOverlayWasActive && _hmdOverlayHandle != 0)
|
||||||
|
{
|
||||||
|
OpenVR.Overlay.DestroyOverlay(_hmdOverlayHandle);
|
||||||
|
_hmdOverlayHandle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_hmdOverlayWasActive = _hmdOverlayActive;
|
||||||
|
|
||||||
|
if (_wristOverlayActive != _wristOverlayWasActive && _wristOverlayHandle != 0)
|
||||||
|
{
|
||||||
|
OpenVR.Overlay.DestroyOverlay(_wristOverlayHandle);
|
||||||
|
_wristOverlayHandle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_wristOverlayWasActive = _wristOverlayActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Refresh()
|
public void Refresh()
|
||||||
{
|
{
|
||||||
_browser1.Reload();
|
_wristOverlay.Reload();
|
||||||
_browser2.Reload();
|
_hmdOverlay.Reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[][] GetDevices()
|
public string[][] GetDevices()
|
||||||
@@ -555,20 +587,20 @@ namespace VRCX
|
|||||||
if (type == EVREventType.VREvent_MouseMove)
|
if (type == EVREventType.VREvent_MouseMove)
|
||||||
{
|
{
|
||||||
var m = e.data.mouse;
|
var m = e.data.mouse;
|
||||||
var s = _browser1.Size;
|
var s = _wristOverlay.Size;
|
||||||
_browser1.GetBrowserHost().SendMouseMoveEvent((int)(m.x * s.Width), s.Height - (int)(m.y * s.Height), false, CefEventFlags.None);
|
_wristOverlay.GetBrowserHost().SendMouseMoveEvent((int)(m.x * s.Width), s.Height - (int)(m.y * s.Height), false, CefEventFlags.None);
|
||||||
}
|
}
|
||||||
else if (type == EVREventType.VREvent_MouseButtonDown)
|
else if (type == EVREventType.VREvent_MouseButtonDown)
|
||||||
{
|
{
|
||||||
var m = e.data.mouse;
|
var m = e.data.mouse;
|
||||||
var s = _browser1.Size;
|
var s = _wristOverlay.Size;
|
||||||
_browser1.GetBrowserHost().SendMouseClickEvent((int)(m.x * s.Width), s.Height - (int)(m.y * s.Height), MouseButtonType.Left, false, 1, CefEventFlags.LeftMouseButton);
|
_wristOverlay.GetBrowserHost().SendMouseClickEvent((int)(m.x * s.Width), s.Height - (int)(m.y * s.Height), MouseButtonType.Left, false, 1, CefEventFlags.LeftMouseButton);
|
||||||
}
|
}
|
||||||
else if (type == EVREventType.VREvent_MouseButtonUp)
|
else if (type == EVREventType.VREvent_MouseButtonUp)
|
||||||
{
|
{
|
||||||
var m = e.data.mouse;
|
var m = e.data.mouse;
|
||||||
var s = _browser1.Size;
|
var s = _wristOverlay.Size;
|
||||||
_browser1.GetBrowserHost().SendMouseClickEvent((int)(m.x * s.Width), s.Height - (int)(m.y * s.Height), MouseButtonType.Left, true, 1, CefEventFlags.None);
|
_wristOverlay.GetBrowserHost().SendMouseClickEvent((int)(m.x * s.Width), s.Height - (int)(m.y * s.Height), MouseButtonType.Left, true, 1, CefEventFlags.None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user