// Update is called once per frame void Update() { Eyes EyeData = new Eyes(); float LeftEyeOpenAmount = -1; float RightEyeOpenAmount = -1; Vector3 FixationPointValue; Vector3 PositionLeft; Vector3 PositionRight; Quaternion RotationLeft; Quaternion RotationRight; if (m_Device.isValid) { if (m_Device.TryGetFeatureValue(m_Usage.As <Eyes>(), out EyeData)) { EyeData.TryGetLeftEyeOpenAmount(out LeftEyeOpenAmount); EyeOpenAmountLeft.text = LeftEyeOpenAmount.ToString(); EyeData.TryGetRightEyeOpenAmount(out RightEyeOpenAmount); EyeOpenAmountRight.text = RightEyeOpenAmount.ToString(); EyeData.TryGetFixationPoint(out FixationPointValue); FixationPoint.text = FixationPointValue.ToString(); EyeData.TryGetLeftEyePosition(out PositionLeft); EyePositionLeft.text = PositionLeft.ToString(); EyeData.TryGetRightEyePosition(out PositionRight); EyePositionRight.text = PositionRight.ToString(); EyeData.TryGetLeftEyeRotation(out RotationLeft); EyeRotationLeft.text = RotationLeft.ToString(); EyeData.TryGetRightEyeRotation(out RotationRight); EyeRotationRight.text = RotationRight.ToString(); } } }
string TextAccumFloat(InputDevice device, InputFeatureUsage feature) { float value; device.TryGetFeatureValue(feature.As <float>(), out value); return(value.ToString()); }
string TextAccumBool(InputDevice device, InputFeatureUsage feature) { bool value; device.TryGetFeatureValue(feature.As <bool>(), out value); return(value.ToString()); }
string TextAccumUint(InputDevice device, InputFeatureUsage feature) { uint value; device.TryGetFeatureValue(feature.As <uint>(), out value); return(value.ToString()); }
string TextAccumVector3(InputDevice device, InputFeatureUsage feature) { Vector3 value; device.TryGetFeatureValue(feature.As <Vector3>(), out value); return(value.ToString()); }
// Update is called once per frame void Update() { Eyes eyes; Vector3 FixationPosition; if (device != null) { if (((InputDevice)device).TryGetFeatureValue(eyeFeatureUsage.As <Eyes>(), out eyes) && eyes.TryGetFixationPoint(out FixationPosition)) { myTransform.position = FixationPosition; if (showPosition) { ReportText.text = "FixationPoint\n" + myTransform.localPosition; } } } }
// Update is called once per frame void Update() { Eyes currentEyeState = new Eyes(); Vector3 eyePosition = new Vector3(); Quaternion eyeRotation = new Quaternion(); if (m_Device.isValid && m_Device.TryGetFeatureValue(m_Usage.As <Eyes>(), out currentEyeState)) { if (m_EyeSide == LeftOrRightEye.LeftEye) { currentEyeState.TryGetLeftEyePosition(out eyePosition); currentEyeState.TryGetLeftEyeRotation(out eyeRotation); } else { currentEyeState.TryGetRightEyePosition(out eyePosition); currentEyeState.TryGetRightEyeRotation(out eyeRotation); } myTransform.localPosition = eyePosition + positionOffset; } }
public bool SetDrivingUsage(InputDevice device, InputFeatureUsage usage) { m_HideOnStart = false; HideAllUI(); if (usage.type == typeof(bool)) { BoolFeatureUI.SetDrivingUsage(device, usage.As <bool>()); } else if (usage.type == typeof(float)) { FloatFeatureUI.SetDrivingUsage(device, usage.As <float>()); } else if (usage.type == typeof(uint)) { UintFeatureUI.SetDrivingUsage(device, usage.As <uint>()); } else if (usage.type == typeof(Vector2)) { Vector2FeatureUI.SetDrivingUsage(device, usage.As <Vector2>()); } else if (usage.type == typeof(Vector3)) { Vector3FeatureUI.SetDrivingUsage(device, usage.As <Vector3>()); } else if (usage.type == typeof(Quaternion)) { QuaternionFeatureUI.SetDrivingUsage(device, usage.As <Quaternion>()); } else if (usage.type == typeof(Eyes)) { EyeDataUI.gameObject.SetActive(true); } else { Debug.LogError("ArbiterFeatureUsageDrivesUI could not SetDrivingUsage() for device " + device.name + " and " + usage.type.ToString() + " type usage " + usage.name); return(false); } return(true); }
static public bool DeviceFeatureIsReactive(InputDevice device, InputFeatureUsage feature) { bool value_bool; if (feature.type == typeof(bool)) { return(device.TryGetFeatureValue(feature.As <bool>(), out value_bool)); } float value_float; if (feature.type == typeof(float)) { return(device.TryGetFeatureValue(feature.As <float>(), out value_float)); } Vector2 value_vector2; if (feature.type == typeof(Vector2)) { return(device.TryGetFeatureValue(feature.As <Vector2>(), out value_vector2)); } Vector3 value_vector3; if (feature.type == typeof(Vector3)) { return(device.TryGetFeatureValue(feature.As <Vector3>(), out value_vector3)); } Quaternion value_quaternion; if (feature.type == typeof(Quaternion)) { return(device.TryGetFeatureValue(feature.As <Quaternion>(), out value_quaternion)); } System.UInt32 value_int32; if (feature.type == typeof(System.UInt32)) { return(device.TryGetFeatureValue(feature.As <System.UInt32>(), out value_int32)); } InputTrackingState value_inputTrackingState; if (feature.type == typeof(InputTrackingState)) { return(device.TryGetFeatureValue(feature.As <InputTrackingState>(), out value_inputTrackingState)); } Hand value_hand; if (feature.type == typeof(Hand)) { return(device.TryGetFeatureValue(feature.As <Hand>(), out value_hand)); } Eyes value_eyes; if (feature.type == typeof(Eyes)) { return(device.TryGetFeatureValue(feature.As <Eyes>(), out value_eyes)); } return(false); }
string GetFeatureValue(InputDevice device, InputFeatureUsage featureUsage) { switch (featureUsage.type.ToString()) { case "System.Boolean": bool boolValue; if (device.TryGetFeatureValue(featureUsage.As <bool>(), out boolValue)) { return(boolValue.ToString()); } break; case "System.UInt32": uint uintValue; if (device.TryGetFeatureValue(featureUsage.As <uint>(), out uintValue)) { return(uintValue.ToString()); } break; case "System.Single": float floatValue; if (device.TryGetFeatureValue(featureUsage.As <float>(), out floatValue)) { return(floatValue.ToString()); } break; case "UnityEngine.Vector2": Vector2 Vector2Value; if (device.TryGetFeatureValue(featureUsage.As <Vector2>(), out Vector2Value)) { return(Vector2Value.ToString()); } break; case "UnityEngine.Vector3": Vector3 Vector3Value; if (device.TryGetFeatureValue(featureUsage.As <Vector3>(), out Vector3Value)) { return(Vector3Value.ToString()); } break; case "UnityEngine.Quaternion": Quaternion QuaternionValue; if (device.TryGetFeatureValue(featureUsage.As <Quaternion>(), out QuaternionValue)) { return(QuaternionValue.ToString()); } break; case "UnityEngine.XR.Hand": Hand HandValue; if (device.TryGetFeatureValue(featureUsage.As <Hand>(), out HandValue)) { return(HandValue.ToString()); } break; case "UnityEngine.XR.Bone": Bone BoneValue; if (device.TryGetFeatureValue(featureUsage.As <Bone>(), out BoneValue)) { return(BoneValue.ToString()); } break; case "UnityEngine.XR.Eyes": Eyes EyesValue; if (device.TryGetFeatureValue(featureUsage.As <Eyes>(), out EyesValue)) { return(EyesValue.ToString()); } break; } return(""); }
static string GetFeatureValue(InputDevice device, InputFeatureUsage featureUsage) { switch (featureUsage.type.ToString()) { case "System.Boolean": if (device.TryGetFeatureValue(featureUsage.As <bool>(), out var boolValue)) { return(boolValue.ToString()); } break; case "System.UInt32": if (device.TryGetFeatureValue(featureUsage.As <uint>(), out var uintValue)) { return(uintValue.ToString()); } break; case "System.Single": if (device.TryGetFeatureValue(featureUsage.As <float>(), out var floatValue)) { return(floatValue.ToString()); } break; case "UnityEngine.Vector2": if (device.TryGetFeatureValue(featureUsage.As <Vector2>(), out var vector2Value)) { return(vector2Value.ToString()); } break; case "UnityEngine.Vector3": if (device.TryGetFeatureValue(featureUsage.As <Vector3>(), out var vector3Value)) { return(vector3Value.ToString()); } break; case "UnityEngine.Quaternion": if (device.TryGetFeatureValue(featureUsage.As <Quaternion>(), out var quaternionValue)) { return(quaternionValue.ToString()); } break; case "UnityEngine.XR.Hand": if (device.TryGetFeatureValue(featureUsage.As <Hand>(), out var handValue)) { return(handValue.ToString()); } break; case "UnityEngine.XR.Bone": if (device.TryGetFeatureValue(featureUsage.As <Bone>(), out var boneValue)) { if (boneValue.TryGetPosition(out var bonePosition) && boneValue.TryGetRotation(out var boneRotation)) { return($"{bonePosition}, {boneRotation}"); } } break; case "UnityEngine.XR.Eyes": if (device.TryGetFeatureValue(featureUsage.As <Eyes>(), out var eyesValue)) { if (eyesValue.TryGetFixationPoint(out var fixation) && eyesValue.TryGetLeftEyePosition(out var left) && eyesValue.TryGetRightEyePosition(out var right) && eyesValue.TryGetLeftEyeOpenAmount(out var leftOpen) && eyesValue.TryGetRightEyeOpenAmount(out var rightOpen)) { return($"{fixation}, {left}, {right}, {leftOpen}, {rightOpen}"); } } break; } return(""); }
public override void SetInputFeature(InputFeatureUsage usage) { inputFeature = usage.As <Vector2>(); touch = new InputFeatureUsage <bool>(usage.name + "Touch"); click = new InputFeatureUsage <bool>(usage.name + "Click"); }
public override void SetInputFeature(InputFeatureUsage usage) => inputFeature = usage.As <bool>();
string GetFeatureValue(InputDevice device, InputFeatureUsage featureUsage) { switch (featureUsage.type.ToString()) { case "System.Boolean": bool boolValue; if (device.TryGetFeatureValue(featureUsage.As <bool>(), out boolValue)) { return(boolValue.ToString()); } break; case "System.UInt32": uint uintValue; if (device.TryGetFeatureValue(featureUsage.As <uint>(), out uintValue)) { return(uintValue.ToString()); } break; case "System.Single": float floatValue; if (device.TryGetFeatureValue(featureUsage.As <float>(), out floatValue)) { return(floatValue.ToString()); } break; case "UnityEngine.Vector2": Vector2 Vector2Value; if (device.TryGetFeatureValue(featureUsage.As <Vector2>(), out Vector2Value)) { return(Vector2Value.ToString()); } break; case "UnityEngine.Vector3": Vector3 Vector3Value; if (device.TryGetFeatureValue(featureUsage.As <Vector3>(), out Vector3Value)) { return(Vector3Value.ToString()); } break; case "UnityEngine.Quaternion": Quaternion QuaternionValue; if (device.TryGetFeatureValue(featureUsage.As <Quaternion>(), out QuaternionValue)) { return(QuaternionValue.ToString()); } break; case "UnityEngine.XR.Hand": Hand HandValue; if (device.TryGetFeatureValue(featureUsage.As <Hand>(), out HandValue)) { return(HandValue.ToString()); } break; case "UnityEngine.XR.Bone": Bone BoneValue; if (device.TryGetFeatureValue(featureUsage.As <Bone>(), out BoneValue)) { Vector3 bonePosition; Quaternion boneRotation; if (BoneValue.TryGetPosition(out bonePosition) && BoneValue.TryGetRotation(out boneRotation)) { return(string.Format("{0}, {1}", bonePosition.ToString(), boneRotation.ToString())); } } break; case "UnityEngine.XR.Eyes": Eyes EyesValue; if (device.TryGetFeatureValue(featureUsage.As <Eyes>(), out EyesValue)) { Vector3 fixation, left, right; float leftOpen, rightOpen; if (EyesValue.TryGetFixationPoint(out fixation) && EyesValue.TryGetLeftEyePosition(out left) && EyesValue.TryGetRightEyePosition(out right) && EyesValue.TryGetLeftEyeOpenAmount(out leftOpen) && EyesValue.TryGetRightEyeOpenAmount(out rightOpen)) { return(string.Format("{0}, {1}, {2}, {3}, {4}", fixation.ToString(), left.ToString(), right.ToString(), leftOpen, rightOpen)); } } break; } return(""); }