-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInput.cs
More file actions
100 lines (81 loc) · 3.53 KB
/
Input.cs
File metadata and controls
100 lines (81 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// OculusReportMenu/Input.cs - Handles controller input
// (C) Copyright 2024 - 2026 SirKingBinx - MIT License
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.XR;
using Valve.VR;
namespace OculusReportMenu;
/*
* OculusReportMenu allows you to rebind what controller inputs are required to open the menu.
* This is where that data is stored.
*/
internal class Input
{
internal static float Sensitivity = 0.5f;
// -- All of these are set by Main.Start; see that for how this info is gathered -- //
internal static ORM_Button OpenButton1 = ORM_Button.LeftPrimary;
internal static ORM_Button OpenButton2 = ORM_Button.LeftSecondary;
internal static bool EnableTabOpening;
// -- END "all of these" -- //
// Note: this stuff is pending a rewrite to save a bunch of CPU cycles and do some optimization tricks:
// Resolve what method is needed to get controller input on startup, saving a whole lot of code
internal static bool Activated
{
get
{
bool custom = CheckButtonPressedStatus(OpenButton1)
&& CheckButtonPressedStatus(OpenButton2)
;
bool tab = EnableTabOpening
&& Keyboard.current.tabKey.isPressed;
return custom || tab;
}
}
private static bool CheckButtonPressedStatus(ORM_Button thisEntry)
{
bool temporarySClick;
switch (thisEntry)
{
case ORM_Button.LeftPrimary: return ControllerInputPoller.instance.leftControllerPrimaryButton;
case ORM_Button.LeftSecondary: return ControllerInputPoller.instance.leftControllerSecondaryButton;
case ORM_Button.LeftTrigger: return ControllerInputPoller.instance.leftControllerIndexFloat > Sensitivity;
case ORM_Button.LeftGrip: return ControllerInputPoller.instance.leftControllerGripFloat > Sensitivity;
case ORM_Button.LeftJoystickClick:
if (Main.Instance._platformSteam)
temporarySClick = SteamVR_Actions.gorillaTag_LeftJoystickClick.state;
else
InputDevices.GetDeviceAtXRNode(XRNode.LeftHand).TryGetFeatureValue(UnityEngine.XR.CommonUsages.primary2DAxisClick, out temporarySClick);
return temporarySClick;
// right hand
case ORM_Button.RightPrimary: return ControllerInputPoller.instance.rightControllerPrimaryButton;
case ORM_Button.RightSecondary: return ControllerInputPoller.instance.rightControllerSecondaryButton;
case ORM_Button.RightTrigger: return ControllerInputPoller.instance.rightControllerIndexFloat > Sensitivity;
case ORM_Button.RightGrip: return ControllerInputPoller.instance.rightControllerGripFloat > Sensitivity;
case ORM_Button.RightJoystickClick:
if (Main.Instance._platformSteam)
temporarySClick = SteamVR_Actions.gorillaTag_RightJoystickClick.state;
else
InputDevices.GetDeviceAtXRNode(XRNode.RightHand).TryGetFeatureValue(UnityEngine.XR.CommonUsages.primary2DAxisClick, out temporarySClick);
return temporarySClick;
// NAN
case ORM_Button.None:
return true;
}
return false;
}
}
// Here's where our button names are stored.
public enum ORM_Button
{
None = -1,
LeftPrimary = 0,
LeftSecondary,
LeftGrip,
LeftTrigger,
LeftJoystickClick,
RightPrimary = 10,
RightSecondary,
RightGrip,
RightTrigger,
RightJoystickClick
}