using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Layouts; using UnityEngine.Scripting; namespace SC.XR.Unity.Simulation { /// /// An input device representing a simulated XR handed controller. /// [InputControlLayout(stateType = typeof(XRSimulatedControllerState), commonUsages = new[] { "LeftHand", "RightHand" }, isGenericTypeOfDevice = false, displayName = "XR Simulated Controller"), Preserve] public class XRSimulatedController : UnityEngine.InputSystem.XR.XRController { /// /// The primary touchpad or joystick on a device. /// public Vector2Control primary2DAxis { get; private set; } /// /// A trigger-like control, pressed with the index finger. /// public AxisControl trigger { get; private set; } /// /// Represents the users grip on the controller. /// public AxisControl grip { get; private set; } /// /// A secondary touchpad or joystick on a device. /// public Vector2Control secondary2DAxis { get; private set; } /// /// The primary face button being pressed on a device, or sole button if only one is available. /// public ButtonControl primaryButton { get; private set; } /// /// The primary face button being touched on a device. /// public ButtonControl primaryTouch { get; private set; } /// /// The secondary face button being pressed on a device. /// public ButtonControl secondaryButton { get; private set; } /// /// The secondary face button being touched on a device. /// public ButtonControl secondaryTouch { get; private set; } /// /// A binary measure of whether the device is being gripped. /// public ButtonControl gripButton { get; private set; } /// /// A binary measure of whether the index finger is activating the trigger. /// public ButtonControl triggerButton { get; private set; } /// /// Represents a menu button, used to pause, go back, or otherwise exit gameplay. /// public ButtonControl menuButton { get; private set; } /// /// Represents the primary 2D axis being clicked or otherwise depressed. /// public ButtonControl primary2DAxisClick { get; private set; } /// /// Represents the primary 2D axis being touched. /// public ButtonControl primary2DAxisTouch { get; private set; } /// /// Represents the secondary 2D axis being clicked or otherwise depressed. /// public ButtonControl secondary2DAxisClick { get; private set; } /// /// Represents the secondary 2D axis being touched. /// public ButtonControl secondary2DAxisTouch { get; private set; } /// /// Value representing the current battery life of this device. /// public AxisControl batteryLevel { get; private set; } /// /// Indicates whether the user is present and interacting with the device. /// public ButtonControl userPresence { get; private set; } /// /// Finishes setting up all the input values for the controller. /// protected override void FinishSetup() { base.FinishSetup(); primary2DAxis = GetChildControl(nameof(primary2DAxis)); trigger = GetChildControl(nameof(trigger)); grip = GetChildControl(nameof(grip)); secondary2DAxis = GetChildControl(nameof(secondary2DAxis)); primaryButton = GetChildControl(nameof(primaryButton)); primaryTouch = GetChildControl(nameof(primaryTouch)); secondaryButton = GetChildControl(nameof(secondaryButton)); secondaryTouch = GetChildControl(nameof(secondaryTouch)); gripButton = GetChildControl(nameof(gripButton)); triggerButton = GetChildControl(nameof(triggerButton)); menuButton = GetChildControl(nameof(menuButton)); primary2DAxisClick = GetChildControl(nameof(primary2DAxisClick)); primary2DAxisTouch = GetChildControl(nameof(primary2DAxisTouch)); secondary2DAxisClick = GetChildControl(nameof(secondary2DAxisClick)); secondary2DAxisTouch = GetChildControl(nameof(secondary2DAxisTouch)); batteryLevel = GetChildControl(nameof(batteryLevel)); userPresence = GetChildControl(nameof(userPresence)); } } }