// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled. // Docs generation is skipped because these are intended to be replaced with the com.unity.xr.openvr package. #if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) && !DISABLE_BUILTIN_INPUT_SYSTEM_OPENVR && !UNITY_FORCE_INPUTSYSTEM_XR_OFF && !PACKAGE_DOCS_GENERATION using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Layouts; using UnityEngine.InputSystem.XR; namespace Unity.XR.OpenVR { [InputControlLayout(displayName = "OpenVR Headset", hideInUI = true)] public class OpenVRHMD : XRHMD { [InputControl(noisy = true)] public Vector3Control deviceVelocity { get; private set; } [InputControl(noisy = true)] public Vector3Control deviceAngularVelocity { get; private set; } [InputControl(noisy = true)] public Vector3Control leftEyeVelocity { get; private set; } [InputControl(noisy = true)] public Vector3Control leftEyeAngularVelocity { get; private set; } [InputControl(noisy = true)] public Vector3Control rightEyeVelocity { get; private set; } [InputControl(noisy = true)] public Vector3Control rightEyeAngularVelocity { get; private set; } [InputControl(noisy = true)] public Vector3Control centerEyeVelocity { get; private set; } [InputControl(noisy = true)] public Vector3Control centerEyeAngularVelocity { get; private set; } protected override void FinishSetup() { base.FinishSetup(); deviceVelocity = GetChildControl("deviceVelocity"); deviceAngularVelocity = GetChildControl("deviceAngularVelocity"); leftEyeVelocity = GetChildControl("leftEyeVelocity"); leftEyeAngularVelocity = GetChildControl("leftEyeAngularVelocity"); rightEyeVelocity = GetChildControl("rightEyeVelocity"); rightEyeAngularVelocity = GetChildControl("rightEyeAngularVelocity"); centerEyeVelocity = GetChildControl("centerEyeVelocity"); centerEyeAngularVelocity = GetChildControl("centerEyeAngularVelocity"); } } [InputControlLayout(displayName = "Windows MR Controller (OpenVR)", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class OpenVRControllerWMR : XRController { [InputControl(noisy = true)] public Vector3Control deviceVelocity { get; private set; } [InputControl(noisy = true)] public Vector3Control deviceAngularVelocity { get; private set; } [InputControl(aliases = new[] { "primary2DAxisClick", "joystickOrPadPressed" })] public ButtonControl touchpadClick { get; private set; } [InputControl(aliases = new[] { "primary2DAxisTouch", "joystickOrPadTouched" })] public ButtonControl touchpadTouch { get; private set; } [InputControl] public ButtonControl gripPressed { get; private set; } [InputControl] public ButtonControl triggerPressed { get; private set; } [InputControl(aliases = new[] { "primary" })] public ButtonControl menu { get; private set; } [InputControl] public AxisControl trigger { get; private set; } [InputControl] public AxisControl grip { get; private set; } [InputControl(aliases = new[] { "secondary2DAxis" })] public Vector2Control touchpad { get; private set; } [InputControl(aliases = new[] { "primary2DAxis" })] public Vector2Control joystick { get; private set; } protected override void FinishSetup() { base.FinishSetup(); deviceVelocity = GetChildControl("deviceVelocity"); deviceAngularVelocity = GetChildControl("deviceAngularVelocity"); touchpadClick = GetChildControl("touchpadClick"); touchpadTouch = GetChildControl("touchpadTouch"); gripPressed = GetChildControl("gripPressed"); triggerPressed = GetChildControl("triggerPressed"); menu = GetChildControl("menu"); trigger = GetChildControl("trigger"); grip = GetChildControl("grip"); touchpad = GetChildControl("touchpad"); joystick = GetChildControl("joystick"); } } /// /// An HTC Vive Wand controller. /// [InputControlLayout(displayName = "Vive Wand", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class ViveWand : XRControllerWithRumble { [InputControl] public AxisControl grip { get; private set; } [InputControl] public ButtonControl gripPressed { get; private set; } [InputControl] public ButtonControl primary { get; private set; } [InputControl(aliases = new[] { "primary2DAxisClick", "joystickOrPadPressed" })] public ButtonControl trackpadPressed { get; private set; } [InputControl(aliases = new[] { "primary2DAxisTouch", "joystickOrPadTouched" })] public ButtonControl trackpadTouched { get; private set; } [InputControl(aliases = new[] { "Primary2DAxis" })] public Vector2Control trackpad { get; private set; } [InputControl] public AxisControl trigger { get; private set; } [InputControl] public ButtonControl triggerPressed { get; private set; } [InputControl(noisy = true)] public Vector3Control deviceVelocity { get; private set; } [InputControl(noisy = true)] public Vector3Control deviceAngularVelocity { get; private set; } protected override void FinishSetup() { base.FinishSetup(); grip = GetChildControl("grip"); primary = GetChildControl("primary"); gripPressed = GetChildControl("gripPressed"); trackpadPressed = GetChildControl("trackpadPressed"); trackpadTouched = GetChildControl("trackpadTouched"); trackpad = GetChildControl("trackpad"); trigger = GetChildControl("trigger"); triggerPressed = GetChildControl("triggerPressed"); deviceVelocity = GetChildControl("deviceVelocity"); deviceAngularVelocity = GetChildControl("deviceAngularVelocity"); } } /// /// An HTC Vive lighthouse. /// [InputControlLayout(displayName = "Vive Lighthouse", hideInUI = true)] public class ViveLighthouse : TrackedDevice { } /// /// An HTC Vive tracker. /// [InputControlLayout(displayName = "Vive Tracker")] public class ViveTracker : TrackedDevice { [InputControl(noisy = true)] public Vector3Control deviceVelocity { get; private set; } [InputControl(noisy = true)] public Vector3Control deviceAngularVelocity { get; private set; } protected override void FinishSetup() { base.FinishSetup(); deviceVelocity = GetChildControl("deviceVelocity"); deviceAngularVelocity = GetChildControl("deviceAngularVelocity"); } } [InputControlLayout(displayName = "Handed Vive Tracker", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class HandedViveTracker : ViveTracker { [InputControl] public AxisControl grip { get; private set; } [InputControl] public ButtonControl gripPressed { get; private set; } [InputControl] public ButtonControl primary { get; private set; } [InputControl(aliases = new[] { "JoystickOrPadPressed" })] public ButtonControl trackpadPressed { get; private set; } [InputControl] public ButtonControl triggerPressed { get; private set; } protected override void FinishSetup() { grip = GetChildControl("grip"); primary = GetChildControl("primary"); gripPressed = GetChildControl("gripPressed"); trackpadPressed = GetChildControl("trackpadPressed"); triggerPressed = GetChildControl("triggerPressed"); base.FinishSetup(); } } /// /// An Oculus Touch controller. /// [InputControlLayout(displayName = "Oculus Touch Controller (OpenVR)", commonUsages = new[] { "LeftHand", "RightHand" }, hideInUI = true)] public class OpenVROculusTouchController : XRControllerWithRumble { [InputControl] public Vector2Control thumbstick { get; private set; } [InputControl] public AxisControl trigger { get; private set; } [InputControl] public AxisControl grip { get; private set; } // Primary & Secondary are switched in order to retain consistency with the Oculus SDK [InputControl(aliases = new[] { "Alternate" })] public ButtonControl primaryButton { get; private set; } [InputControl(aliases = new[] { "Primary" })] public ButtonControl secondaryButton { get; private set; } [InputControl] public ButtonControl gripPressed { get; private set; } [InputControl] public ButtonControl triggerPressed { get; private set; } [InputControl(aliases = new[] { "primary2DAxisClicked" })] public ButtonControl thumbstickClicked { get; private set; } [InputControl(aliases = new[] { "primary2DAxisTouch" })] public ButtonControl thumbstickTouched { get; private set; } [InputControl(noisy = true)] public Vector3Control deviceVelocity { get; private set; } [InputControl(noisy = true)] public Vector3Control deviceAngularVelocity { get; private set; } protected override void FinishSetup() { base.FinishSetup(); thumbstick = GetChildControl("thumbstick"); trigger = GetChildControl("trigger"); grip = GetChildControl("grip"); primaryButton = GetChildControl("primaryButton"); secondaryButton = GetChildControl("secondaryButton"); gripPressed = GetChildControl("gripPressed"); thumbstickClicked = GetChildControl("thumbstickClicked"); thumbstickTouched = GetChildControl("thumbstickTouched"); triggerPressed = GetChildControl("triggerPressed"); deviceVelocity = GetChildControl("deviceVelocity"); deviceAngularVelocity = GetChildControl("deviceAngularVelocity"); } } } #endif