17 #if UNITY_2019_1_OR_NEWER && INPUTSYSTEM_AVAILABLE
20 using UnityEngine.InputSystem;
21 using UnityEngine.InputSystem.Controls;
22 using UnityEngine.InputSystem.Layouts;
23 using UnityEngine.InputSystem.LowLevel;
24 using UnityEngine.InputSystem.Utilities;
30 public struct GlassesState : IInputStateTypeInfo
32 public FourCC format =>
new FourCC(
'T',
'5');
34 [InputControl(name =
"devicePosition", alias =
"Position", noisy =
true, layout =
"Vector3")]
35 [InputControl(name =
"centerEyePosition", synthetic =
true, useStateFrom =
"devicePosition")]
36 public Vector3 devicePosition;
38 [InputControl(name =
"LeftEyePosition", noisy =
true, layout =
"Vector3")]
39 public Vector3 LeftEyePosition;
41 [InputControl(name =
"RightEyePosition", noisy =
true, layout =
"Vector3")]
42 public Vector3 RightEyePosition;
44 [InputControl(name =
"Position/Raw", noisy =
true, layout =
"Vector3")]
45 public Vector3 RawDevicePosition;
47 [InputControl(name =
"LeftEyePosition/Raw", noisy =
true, layout =
"Vector3")]
48 public Vector3 RawLeftEyePosition;
50 [InputControl(name =
"RightEyePosition/Raw", noisy =
true, layout =
"Vector3")]
51 public Vector3 RawRightEyePosition;
55 [InputControl(name =
"deviceRotation", alias =
"Rotation", noisy =
true, layout =
"Quaternion")]
56 [InputControl(name =
"centerEyeRotation", synthetic =
true, useStateFrom =
"deviceRotation", noisy =
true)]
57 [InputControl(name =
"leftEyeRotation", synthetic =
true, useStateFrom =
"deviceRotation", noisy =
true)]
58 [InputControl(name =
"rightEyeRotation", synthetic =
true, useStateFrom =
"deviceRotation", noisy =
true)]
59 public Quaternion deviceRotation;
61 [InputControl(name =
"Rotation/Raw", noisy =
true, layout =
"Quaternion")]
62 public Quaternion RawRotation;
65 [InputControlLayout(stateType = typeof(GlassesState), displayName =
"Tilt Five Glasses", updateBeforeRender =
true)]
69 public class GlassesDevice : UnityEngine.InputSystem.XR.XRHMD
74 public WandDevice LeftWand =
null;
75 public WandDevice RightWand =
null;
82 public new Vector3Control devicePosition {
get;
private set; }
83 public new Vector3Control leftEyePosition {
get;
private set; }
84 public new Vector3Control rightEyePosition {
get;
private set; }
85 public new Vector3Control centerEyePosition {
get;
private set; }
87 public Vector3Control RawPosition {
get;
private set; }
88 public Vector3Control RawLeftEyePosition {
get;
private set; }
89 public Vector3Control RawRightEyePosition {
get;
private set; }
91 public new QuaternionControl deviceRotation {
get;
private set; }
92 public new QuaternionControl leftEyeRotation {
get;
private set; }
93 public new QuaternionControl rightEyeRotation {
get;
private set; }
94 public new QuaternionControl centerEyeRotation {
get;
private set; }
95 public QuaternionControl RawRotation {
get;
private set; }
97 public new ButtonControl isTracked {
get;
private set; }
99 public new IntegerControl trackingState {
get;
private set; }
106 protected override void FinishSetup()
110 devicePosition = GetChildControl<Vector3Control>(
"Position");
111 centerEyePosition = GetChildControl<Vector3Control>(
"centerEyePosition");
112 leftEyePosition = GetChildControl<Vector3Control>(
"LeftEyePosition");
113 rightEyePosition = GetChildControl<Vector3Control>(
"RightEyePosition");
115 RawPosition = GetChildControl<Vector3Control>(
"Position/Raw");
116 RawLeftEyePosition = GetChildControl<Vector3Control>(
"LeftEyePosition/Raw");
117 RawRightEyePosition = GetChildControl<Vector3Control>(
"RightEyePosition/Raw");
119 deviceRotation = GetChildControl<QuaternionControl>(
"Rotation");
120 leftEyeRotation = GetChildControl<QuaternionControl>(
"leftEyeRotation");
121 rightEyeRotation = GetChildControl<QuaternionControl>(
"rightEyeRotation");
122 centerEyeRotation = GetChildControl<QuaternionControl>(
"centerEyeRotation");
123 RawRotation = GetChildControl<QuaternionControl>(
"Rotation/Raw");
125 isTracked = GetChildControl<ButtonControl>(
"isTracked");
126 trackingState = GetChildControl<IntegerControl>(
"trackingState");
131 static GlassesDevice()
133 InputSystem.RegisterLayout<GlassesDevice>(matches:
new InputDeviceMatcher()
134 .WithInterface(
"GlassesDevice"));
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)