From 3314986e7e905561a30cd4825e21e09b5a1aaba0 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Fri, 23 Jan 2026 18:25:34 -0300 Subject: [PATCH 1/2] Holding trigger holds the mouse click on the game UI. Mouse is tracked the entire time on the game UI. --- DFUVR/SPC.cs | 157 ++++++++++++++++++++++++--------------------------- 1 file changed, 75 insertions(+), 82 deletions(-) diff --git a/DFUVR/SPC.cs b/DFUVR/SPC.cs index d308a42..4278fd0 100644 --- a/DFUVR/SPC.cs +++ b/DFUVR/SPC.cs @@ -1,12 +1,5 @@ - -using DaggerfallWorkshop.Game; -using DaggerfallWorkshop.Game.Utility; -using HarmonyLib; -using System; -using System.Reflection; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; using UnityEngine; -using UnityEngine.EventSystems; using UnityEngine.SpatialTracking; using UnityEngine.UI; using uWindowCapture; @@ -28,6 +21,8 @@ public class SPC : MonoBehaviour public int windowWidth; public int windowHeight; + private bool isClicking = false; + private UwcWindowTexture wTexture; [DllImport("user32.dll")] @@ -39,10 +34,6 @@ public class SPC : MonoBehaviour [DllImport("user32.dll")] private static extern bool SetCursorPos(int X, int Y); - void Start() - { - - } public void Initialize(LineRenderer line, GraphicRaycaster graphicRaycaster, TrackedPoseDriver tracked) { if (!Var.fStartMenu) @@ -58,9 +49,9 @@ public void Initialize(LineRenderer line, GraphicRaycaster graphicRaycaster, Tra //wTexture = GameObject.Find("VRUI").GetComponent(); windowHeight = Var.windowHeight; windowWidth = Var.windowWidth; - } } + lineRenderer = line; trackedPoseDriver = tracked; this.graphicRaycaster = graphicRaycaster; @@ -68,7 +59,6 @@ public void Initialize(LineRenderer line, GraphicRaycaster graphicRaycaster, Tra void Update() { - //foreach (KeyCode kcode in Enum.GetValues(typeof(KeyCode))) //{ // if (Input.GetKey(kcode)) @@ -99,8 +89,9 @@ void Update() // windowHeight = wTexture.window.height; // Plugin.LoggerInstance.LogInfo(windowWidth+", "+windowHeight); //} - TriggerProvider.CheckPressedRight(); + bool clicked = Input.GetKeyDown(Var.acceptButton) || TriggerProvider.pressedDone; + if (trackedPoseDriver != null && lineRenderer != null) { Vector3 controllerPosition = trackedPoseDriver.transform.localPosition; @@ -111,11 +102,12 @@ void Update() lineRenderer.SetPosition(0, lineStart); lineRenderer.SetPosition(1, lineEnd); - if (Input.GetKeyDown(Var.acceptButton) || Var.rTriggerDone || Var.lTriggerDone) + + if (!Var.fStartMenu) { - if (!Var.fStartMenu) + if (!Var.isCalibrated) { - if (!Var.isCalibrated) + if (clicked) { var result = UwcWindowTexture.RayCast(lineStart, trackedPoseDriver.transform.forward, raycastDistance, -1); if (result.hit) @@ -128,88 +120,77 @@ void Update() mouse_event(MOUSEEVENTF_LEFTUP, (uint)desktopCoord.x, (uint)desktopCoord.y, 0, 0); } } - else - { - //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) - { - Plugin.LoggerInstance.LogInfo("clicked"); - if (hit.collider.gameObject.name == "VRUI") - { - Plugin.LoggerInstance.LogInfo("Raycast Hit: " + hit.point); - SimulateMouseClick(hit.point); - break; - } - - if (hit.collider.gameObject.GetComponent