using System.Runtime.InteropServices; using UnityEngine; using UnityEngine.InputSystem.Layouts; using UnityEngine.InputSystem.LowLevel; using UnityEngine.InputSystem.Utilities; namespace SC.XR.Unity.Simulation { /// /// State for input device representing a simulated XR HMD. /// [StructLayout(LayoutKind.Explicit, Size = 117)] public struct XRSimulatedHMDState : IInputStateTypeInfo { /// /// Memory format identifier for . /// /// public static FourCC formatId => new FourCC('X', 'R', 'S', 'H'); /// /// See IInputStateTypeInfo.format. /// public FourCC format => formatId; /// /// The position of the left eye on this device. /// [InputControl(usage = "LeftEyePosition")] [FieldOffset(0)] public Vector3 leftEyePosition; /// /// The rotation of the left eye on this device. /// [InputControl(usage = "LeftEyeRotation")] [FieldOffset(12)] public Quaternion leftEyeRotation; /// /// The position of the right eye on this device. /// [InputControl(usage = "RightEyePosition")] [FieldOffset(28)] public Vector3 rightEyePosition; /// /// The rotation of the right eye on this device. /// [InputControl(usage = "RightEyeRotation")] [FieldOffset(40)] public Quaternion rightEyeRotation; /// /// The position of the center eye on this device. /// [InputControl(usage = "CenterEyePosition")] [FieldOffset(56)] public Vector3 centerEyePosition; /// /// The rotation of the center eye on this device. /// [InputControl(usage = "CenterEyeRotation")] [FieldOffset(68)] public Quaternion centerEyeRotation; /// /// Represents the values being tracked for this device. /// [InputControl(usage = "TrackingState", layout = "Integer")] [FieldOffset(84)] public int trackingState; /// /// Informs to the developer whether the device is currently being tracked. /// [InputControl(usage = "IsTracked", layout = "Button")] [FieldOffset(88)] public bool isTracked; /// /// The position of the device. /// [InputControl(usage = "DevicePosition")] [FieldOffset(89)] public Vector3 devicePosition; /// /// The rotation of this device. /// [InputControl(usage = "DeviceRotation")] [FieldOffset(101)] public Quaternion deviceRotation; /// /// See . /// public void Reset() { leftEyePosition = default; leftEyeRotation = Quaternion.identity; rightEyePosition = default; rightEyeRotation = Quaternion.identity; centerEyePosition = default; centerEyeRotation = Quaternion.identity; trackingState = default; isTracked = default; devicePosition = default; deviceRotation = Quaternion.identity; } } }