diff --git a/DFUVR/DFUVR.csproj b/DFUVR/DFUVR.csproj
index d84be7d..4e8d560 100644
--- a/DFUVR/DFUVR.csproj
+++ b/DFUVR/DFUVR.csproj
@@ -96,9 +96,7 @@
False
..\dependencies\Windows\x64\DaggerfallUnity_Data\Managed\UnityEngine.XRModule.dll
-
- ..\dependencies\Windows\x64\DaggerfallUnity_Data\Managed\uWindowCapture.Runtime.dll
-
+
diff --git a/DFUVR/SPC.cs b/DFUVR/SPC.cs
index a6cf3e9..a4eecf9 100644
--- a/DFUVR/SPC.cs
+++ b/DFUVR/SPC.cs
@@ -1,9 +1,9 @@
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
+using DaggerfallWorkshop.Game;
using UnityEngine;
using UnityEngine.SpatialTracking;
using UnityEngine.UI;
using UnityEngine.XR;
-using uWindowCapture;
namespace DFUVR
{
@@ -24,8 +24,6 @@ public class SPC : MonoBehaviour
private bool isClicking = false;
- private UwcWindowTexture wTexture;
-
[DllImport("user32.dll")]
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
@@ -42,13 +40,12 @@ public void Initialize(LineRenderer line, GraphicRaycaster graphicRaycaster, Tra
{
if (Var.isFirst)
{
- wTexture = GameObject.Find("VRUI").GetComponent();
- wTexture.type = WindowTextureType.Window;
- wTexture.partialWindowTitle = "Daggerfall";
+ // Use physics raycast for main menu UI (no uWindowCapture)
+ windowHeight = Var.windowHeight;
+ windowWidth = Var.windowWidth;
}
else
{
- //wTexture = GameObject.Find("VRUI").GetComponent();
windowHeight = Var.windowHeight;
windowWidth = Var.windowWidth;
}
@@ -61,36 +58,6 @@ public void Initialize(LineRenderer line, GraphicRaycaster graphicRaycaster, Tra
void Update()
{
- //foreach (KeyCode kcode in Enum.GetValues(typeof(KeyCode)))
- //{
- // if (Input.GetKey(kcode))
- // Plugin.LoggerInstance.LogInfo("KeyCode down: " + kcode);
- //}
- //float input = Input.GetAxis("Axis" + Var.debugInt2);
-
- //Plugin.LoggerInstance.LogInfo("Input:" + input);
- //Plugin.LoggerInstance.LogInfo("Axis:" + Var.debugInt2);
- //Debug.Log(Var.heightOffset);
-
- //if (Input.GetKeyDown(Var.acceptButton)) { Var.debugInt2 += 1; }
- //Plugin.LoggerInstance.LogInfo(wTexture);
- //DaggerfallUI daggerfallUI = GameObject.Find("DaggerfallUI").GetComponent();
- //FieldInfo directionField = AccessTools.Field(typeof(DaggerfallUI), "customRenderTarget");
- //Plugin.LoggerInstance.LogInfo(directionField.GetValue(daggerfallUI));
- //if (Input.GetKeyDown(KeyCode.K))
- //{
- // Plugin.LoggerInstance.LogInfo("Pressed");
- // StartCoroutine(SpawnUI.Calibrate());
- //}
- //wTexture = GameObject.Find("VRUI").GetComponent();
- //if (wTexture != null)
- //{
- // windowPosX = wTexture.window.x;
- // windowPosY = wTexture.window.y;
- // windowWidth = wTexture.window.width;
- // windowHeight = wTexture.window.height;
- // Plugin.LoggerInstance.LogInfo(windowWidth+", "+windowHeight);
- //}
TriggerProvider.CheckPressedRight();
bool clicked = Input.GetKeyDown(Var.acceptButton) || TriggerProvider.pressedDone;
@@ -107,67 +74,38 @@ void Update()
if (!Var.fStartMenu)
{
- if (!Var.isCalibrated)
- {
- if (clicked)
- {
- var result = UwcWindowTexture.RayCast(lineStart, trackedPoseDriver.transform.forward, raycastDistance, -1);
- if (result.hit)
- {
- //uWindowCapture really needs a proper documentation. I wish I knew sooner that it had a precise raycast function built in before making one myself...
- //windowCoord = result.windowCoord;
- Vector2 desktopCoord = result.desktopCoord;
- SetCursorPos((int)desktopCoord.x, (int)desktopCoord.y);
- mouse_event(MOUSEEVENTF_LEFTDOWN, (uint)desktopCoord.x, (uint)desktopCoord.y, 0, 0);
- mouse_event(MOUSEEVENTF_LEFTUP, (uint)desktopCoord.x, (uint)desktopCoord.y, 0, 0);
- }
- }
- }
- else
+ // Continuously update DaggerfallUI mouse position from laser pointer
+ RaycastHit vruiHit;
+ bool hitVRUI = false;
+ RaycastHit[] hits = Physics.RaycastAll(lineStart, trackedPoseDriver.transform.forward, raycastDistance);
+
+ foreach (var hit in hits)
{
- //RaycastHit hit;
-
- //if (Physics.Raycast(lineStart, trackedPoseDriver.transform.forward, out hit, raycastDistance))
- //{
- // if (hit.collider.gameObject.name == "VRUI")
- // {
- // if (Input.GetKeyDown(Var.acceptButton))
- // {
- // Plugin.LoggerInstance.LogInfo("Raycast Hit: " + hit.point);
- // SimulateMouseClick(hit.point);
- // }
- // }
- // if (Input.GetKeyDown(Var.acceptButton))
- // {
- // if (hit.collider.gameObject.name != "VRUI")
- // { Plugin.LoggerInstance.LogInfo("Hit " + hit.collider.gameObject.name); }
- // }
- //}
- RaycastHit[] hits = Physics.RaycastAll(lineStart, trackedPoseDriver.transform.forward, raycastDistance);
-
- foreach (var hit in hits)
+ if (hit.collider.gameObject.name == "VRUI")
{
- Plugin.LoggerInstance.LogInfo("clicked");
- if (hit.collider.gameObject.name == "VRUI")
+ vruiHit = hit;
+ hitVRUI = true;
+ UpdateVRMousePosition(hit.point);
+
+ if (clicked)
{
- Plugin.LoggerInstance.LogInfo("Raycast Hit: " + hit.point);
SimulateMouseClick(hit.point);
- break;
}
-
- if (Input.GetKeyDown(Var.acceptButton) || Var.rTriggerDone || Var.lTriggerDone)
- hit.collider.gameObject.GetComponent