Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions DFUVR/SPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using UnityEngine;
using UnityEngine.SpatialTracking;
using UnityEngine.UI;
using UnityEngine.XR;
using uWindowCapture;

namespace DFUVR
Expand Down Expand Up @@ -30,6 +31,7 @@ public class SPC : MonoBehaviour

private const uint MOUSEEVENTF_LEFTDOWN = 0x02;
private const uint MOUSEEVENTF_LEFTUP = 0x04;
private const uint MOUSEEVENTF_WHEEL = 0x0800;

[DllImport("user32.dll")]
private static extern bool SetCursorPos(int X, int Y);
Expand Down Expand Up @@ -156,6 +158,15 @@ void Update()
if (Input.GetKeyDown(Var.acceptButton) || Var.rTriggerDone || Var.lTriggerDone)
hit.collider.gameObject.GetComponent<Button>()?.onClick.Invoke();
}

// scroll
InputDevice hand = Var.leftHanded ? InputDevices.GetDeviceAtXRNode(XRNode.LeftHand) : InputDevices.GetDeviceAtXRNode(XRNode.RightHand);

Vector2 rThumbStick;
hand.TryGetFeatureValue(UnityEngine.XR.CommonUsages.primary2DAxis, out rThumbStick);

float inputY = rThumbStick.y;
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, (uint)(inputY * Var.scrollSpeed), 0);
}
}
else if (clicked)
Expand Down
1 change: 1 addition & 0 deletions DFUVR/Var.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public class Var : MonoBehaviour


public static GameObject keyboard;
public static float scrollSpeed = 2;

public static float active;

Expand Down