static void UpdateControllerValue(InputDevice controller, InputFeatureUsage <bool> usage, bool value) { if (!currentControllerValues.ContainsKey(controller)) { return; } ControllerValues controllerValue = currentControllerValues[controller]; if (usage == CommonUsages.primary2DAxisClick) { controllerValue.primary2DAxisClickState = value; } else if (usage == CommonUsages.triggerButton) { controllerValue.triggerButtonPressed = value; } else if (usage == CommonUsages.primaryButton) { controllerValue.primaryButtonState = value; } else if (usage == CommonUsages.secondaryButton) { controllerValue.secondaryButtonState = value; } else if (usage == CommonUsages.gripButton) { controllerValue.gripButtonPressed = value; } }
string TextAccumFloat(InputDevice device, InputFeatureUsage feature) { float value; device.TryGetFeatureValue(feature.As <float>(), out value); return(value.ToString()); }
public ControlTest2DRange_neg1_1(InputDevice device, InputFeatureUsage usage) : base(device, usage) { Description = "This control's range must be -1.0 to 1.0. Check that it hits all extremes and is never outside that range."; CertReqID = "1.2.3.x"; Checks = new Check[11]; Checks[0] = new Check2DHits0_0(DeviceUnderTest, FeatureUsageUnderTest, this); Checks[1] = new Check2DHits1_0(DeviceUnderTest, FeatureUsageUnderTest, this); Checks[2] = new Check2DHits0_1(DeviceUnderTest, FeatureUsageUnderTest, this); Checks[3] = new Check2DHits0_neg1(DeviceUnderTest, FeatureUsageUnderTest, this); Checks[4] = new Check2DHitsneg1_0(DeviceUnderTest, FeatureUsageUnderTest, this); Checks[5] = new Check2DHitsPosXPosY(DeviceUnderTest, FeatureUsageUnderTest, this); Checks[6] = new Check2DHitsNegXNegY(DeviceUnderTest, FeatureUsageUnderTest, this); Checks[7] = new Check2DHitsPosXNegY(DeviceUnderTest, FeatureUsageUnderTest, this); Checks[8] = new Check2DHitsNegXPosY(DeviceUnderTest, FeatureUsageUnderTest, this); Checks[9] = new Check2D_AlwaysNeg1To1(DeviceUnderTest, FeatureUsageUnderTest, this); Checks[10] = new CheckRequireManualPass(DeviceUnderTest, FeatureUsageUnderTest, this); for (int i = 0; i < Checks.Length; i++) { Checks[i].ForcedFailure += HandleForcedFail; } }
public bool TryGetFeatureValue( InputFeatureUsage <Vector3> usage, DateTime time, out Vector3 value) { return(m_inputDevice.TryGetFeatureValue(usage, time, out value)); }
static void UpdateControllerDelta(InputDevice controller, InputFeatureUsage <bool> usage) { bool bPrevValue; bool bCurrValue; remapLeftRightHandedDevices = false; bPrevValue = GetPrevValue(controller, usage); bCurrValue = GetValue(controller, usage); remapLeftRightHandedDevices = true; InputPair pair = new InputPair(controller, usage); if (bPrevValue == bCurrValue) { justPressed.Remove(pair); justReleased.Remove(pair); } else { if (bCurrValue) { justPressed.Add(pair); justReleased.Remove(pair); } else { justReleased.Add(pair); justPressed.Remove(pair); } } }
string TextAccumUint(InputDevice device, InputFeatureUsage feature) { uint value; device.TryGetFeatureValue(feature.As <uint>(), out value); return(value.ToString()); }
// Tries to get a float feature value. public bool TryGetFeatureValue(InputFeatureUsage <float> usage, out float value) { // Set a default value. bool valueGet = false; value = 0.0f; // Determine which usage is being queried. switch (usage.name) { // Get the trigger. case "Trigger": valueGet = true; value = trigger; break; // Get the grip. case "Grip": valueGet = true; value = grip; break; } // Return whether a value was gotten. return(valueGet); }
string TextAccumBool(InputDevice device, InputFeatureUsage feature) { bool value; device.TryGetFeatureValue(feature.As <bool>(), out value); return(value.ToString()); }
public bool TryGetFeatureValue( InputFeatureUsage <Quaternion> usage, DateTime time, out Quaternion value) { return(m_inputDevice.TryGetFeatureValue(usage, time, out value)); }
string TextAccumVector3(InputDevice device, InputFeatureUsage feature) { Vector3 value; device.TryGetFeatureValue(feature.As <Vector3>(), out value); return(value.ToString()); }
public bool TryGetFeatureValue( InputFeatureUsage <InputTrackingState> usage, DateTime time, out InputTrackingState value) { return(m_inputDevice.TryGetFeatureValue(usage, time, out value)); }
private void UpdateButtonState(InputDevice device, InputFeatureUsage <bool> button, ButtonEvent buttonPressEvent) { bool tempState; bool invalidDeviceFound = false; bool buttonState = false; tempState = device.isValid && // the device is still valid device.TryGetFeatureValue(button, out buttonState) && // did get a value buttonState; // the value we got if (!device.isValid) { invalidDeviceFound = true; } if (tempState != buttonPressEvent.Value) // Button state changed since last frame { buttonPressEvent.Invoke(tempState); buttonPressEvent.Value = tempState; } if (invalidDeviceFound) // refresh device lists { SetDevices(); } }
// Update is called once per frame void Update() { if (controller == null) { GetDevice(); } /* * JOYSTICK MOVEMENT */ Vector2 primary2dValue; InputFeatureUsage <Vector2> primary2DVector = CommonUsages.primary2DAxis; if (controller.TryGetFeatureValue(primary2DVector, out primary2dValue) && primary2dValue != Vector2.zero) { Debug.Log("primary2DAxisClick is pressed " + primary2dValue); } bool buttonValue; /* * CLICK X */ if (controller.TryGetFeatureValue(CommonUsages.primaryButton, out buttonValue) && buttonValue) { if (!buttonPressed) { Debug.Log("primaryButton is pressed " + buttonValue); } } }
public void SetDrivingUsage(InputDevice device, InputFeatureUsage <uint> featureUsage) { Device = device; FeatureUsage = featureUsage; gameObject.SetActive(true); }
bool GetButtonDown(InputFeatureUsage <bool> input) { bool tmp = false; for (int i = 0; i < hands.Count; i++) { var hand = hands[i]; if (hand == null) { continue; } if (!hand.isValid) { to_refresh = true; continue; } hand.TryGetFeatureValue(input, out tmp); if (tmp) { handInUse = i; break; } } return(tmp); }
public Check(InputDevice device, InputFeatureUsage featureUsage, ControlTest parentTest) { CanForceFailure = false; RequiresManualPass = false; FeatureUsageUnderTest = featureUsage; DeviceUnderTest = device; ParentControlTest = parentTest; }
float getFeatureUsage(InputDevice device, InputFeatureUsage <float> usage, bool clamp = true) { float val; device.TryGetFeatureValue(usage, out val); return(Mathf.Clamp01(val)); }
public static void GetInstantButtonEvent(InputDevice controller, InputFeatureUsage <bool> usage, ref bool outJustPressed, ref bool outJustReleased) { InputDevice c = GetLeftOrRightHandedController(controller); InputPair pair = new InputPair(c, usage); outJustPressed = justPressed.Contains(pair); outJustReleased = justReleased.Contains(pair); }
private static void AddEyesTests(InputDevice device, InputFeatureUsage usage, List <ControlTest> tests) { tests.Add(new ControlTestEyesDefault(device, usage)); tests.Add(new ControlTestEyesOpenAmount(device, usage)); tests.Add(new ControlTestEyesFixationPoint(device, usage)); tests.Add(new ControlTestEyesPosition(device, usage)); tests.Add(new ControlTestEyesRotation(device, usage)); }
public Vector2 GetVec2(InputFeatureUsage <Vector2> feature) { if (device.TryGetFeatureValue(feature, out v2)) { return(v2); } return(Vector2.zero); }
public Vector3 GetVec3(InputFeatureUsage <Vector3> feature) { if (device.TryGetFeatureValue(feature, out v3)) { return(v3); } return(Vector3.zero); }
public Quaternion GetQuaternion(InputFeatureUsage <Quaternion> feature) { if (device.TryGetFeatureValue(feature, out q)) { return(q); } return(Quaternion.identity); }
public bool GetBool(InputFeatureUsage <bool> feature) { if (device.TryGetFeatureValue(feature, out b)) { return(b); } return(false); }
private void UpdateButton(InputFeatureUsage <bool> feature, ControllerButton button) { bool pressed = false; if (InputDevice.TryGetFeatureValue(feature, out pressed)) { button.SetDown(pressed); } }
private void RightJoystickMove() { InputFeatureUsage <Vector2> primary2DAxis = CommonUsages.primary2DAxis; if (rightHand.TryGetFeatureValue(primary2DAxis, out Vector2 primary2DValue) && primary2DValue != Vector2.zero) { Debug.Log("primary2daxisclick is pressed " + primary2DValue); } }
private void Update() { // wait for a certain amount of time before allowing another turn. if (m_TimeStarted > 0.0f && (m_TimeStarted + m_DebounceTime < Time.time)) { m_TimeStarted = 0.0f; return; } if (m_Controllers.Count > 0) { EnsureControllerDataListSize(); InputFeatureUsage <Vector2> feature = m_Vec2UsageList[(int)m_TurnUsage]; for (int i = 0; i < m_Controllers.Count; i++) { XRController controller = m_Controllers[i]; if (controller != null) { if (controller.enableInputActions && m_ControllersWereActive[i]) { ////MODIFIED BY TONY! var device = controller.inputDevice; Vector2 currentState; if (device.TryGetFeatureValue(feature, out currentState)) { if (currentState.x > deadZone) { StartTurn(m_TurnAmount); } else if (currentState.x < -deadZone) { StartTurn(-m_TurnAmount); } } } else //This adds a 1 frame delay when enabling input actions, so that the frame it's enabled doesn't trigger a snap turn. { m_ControllersWereActive[i] = controller.enableInputActions; } } } } if (Math.Abs(m_CurrentTurnAmount) > 0.0f && BeginLocomotion()) { var xrRig = system.xrRig; if (xrRig != null) { xrRig.RotateAroundCameraUsingRigUp(m_CurrentTurnAmount); } m_CurrentTurnAmount = 0.0f; EndLocomotion(); } }
public static Hand GetDeviceFeatureValueOrDefault(InputDevice device, InputFeatureUsage <Hand> feature, Hand defaultValue = default(Hand)) { Hand value; if (device.TryGetFeatureValue(feature, out value)) { return(value); } return(defaultValue); }
public static Bone GetDeviceFeatureValueOrDefault(InputDevice device, InputFeatureUsage <Bone> feature, Bone defaultValue = default(Bone)) { Bone value; if (device.TryGetFeatureValue(feature, out value)) { return(value); } return(defaultValue); }
public static Quaternion GetDeviceFeatureValueOrDefault(InputDevice device, InputFeatureUsage <Quaternion> feature, Quaternion defaultValue) { Quaternion value; if (device.TryGetFeatureValue(feature, out value)) { return(value); } return(defaultValue); }
public static Eyes GetDeviceFeatureValueOrDefault(InputDevice device, InputFeatureUsage <Eyes> feature, Eyes defaultValue = default(Eyes)) { Eyes value; if (device.TryGetFeatureValue(feature, out value)) { return(value); } return(defaultValue); }