private bool GetButtonPressedFromInputDevice(InputHelpers.Button button) { bool pressed = false; m_xrController.inputDevice.IsPressed(button, out pressed); return(pressed); }
public void UpdateTrigger(InputHelpers.Button button, AsimState state, TriggerAction action) { var(controller, ray) = GetCurrent(); switch (state) { case AsimState.Down: if (GetTriggerDown(button)) { action?.Invoke(controller, ray); } break; case AsimState.Hold: if (GetTrigger(button)) { action?.Invoke(controller, ray); } break; case AsimState.Up: if (GetTriggerUp(button)) { action?.Invoke(controller, ray); } break; } }
/// <summary> /// Check if the given trigger is in a given state. /// </summary> /// <param name="button">Target button.</param> /// <param name="state">Target state.</param> /// <returns>Is the trigger in the given state.</returns> public bool IsActive(InputHelpers.Button button, AsimState state) { if (!m_triggerStates.ContainsKey(button)) { m_triggerStates.Add(button, new FakeState()); } return(m_triggerStates[button].GetState(state, IsPressed(button))); }
public void UpdateTrigger(InputHelpers.Button button, AsimState state, TriggerAction action) { foreach (var controller in m_controllers) { if (controller.IsActive(button, state)) { action.Invoke(controller.Controller, controller.Ray); } } }
private void Start() { teleportActivationButton = rightTeleportRay.selectUsage; if (rightTeleportRay) { rightRayInteractor = rightTeleportRay.gameObject.GetComponent <XRRayInteractor>(); } if (leftTeleportRay) { leftRayInteractor = leftTeleportRay.gameObject.GetComponent <XRRayInteractor>(); } }
public bool GetButtonUp(InputHelpers.Button button) { switch (button) { case InputHelpers.Button.Trigger: return(m_trigger.deactivatedThisFrame); case InputHelpers.Button.Grip: return(m_grip.deactivatedThisFrame); default: return(false); } }
public bool GetButton(InputHelpers.Button button) { switch (button) { case InputHelpers.Button.Trigger: return(m_trigger.active); case InputHelpers.Button.Grip: return(m_grip.active); default: return(false); } }
void HandleInteractionAction(InputHelpers.Button button, ref InteractionState interactionState) { if (inputDevice.TryGetFeatureValue(new InputFeatureUsage <Vector2>("Primary2DAxis"), out Vector2 value)) { if (value.magnitude > _triggerTeleportThreshold) { m_SelectInteractionState.active = true; } else if (m_SelectInteractionState.active) { m_SelectInteractionState.active = false; m_SelectInteractionState.deActivatedThisFrame = true; } } }
private KeyCode TriggerToKeyCode(InputHelpers.Button trigger) { switch (trigger) { case InputHelpers.Button.Trigger: return(m_primary); case InputHelpers.Button.Grip: return(m_secondary); case InputHelpers.Button.PrimaryButton: return(m_button1); case InputHelpers.Button.SecondaryButton: return(m_button2); case InputHelpers.Button.Primary2DAxisClick: return(m_axisClick); } return(KeyCode.None); }
void HandleInteractionAction(XRNode node, InputHelpers.Button button, ref InteractionState interactionState) { bool pressed = false; inputDevice.IsPressed(button, out pressed, m_AxisToPressThreshold); if (pressed) { if (!interactionState.active) { interactionState.activatedThisFrame = true; interactionState.active = true; } } else { if (interactionState.active) { interactionState.deActivatedThisFrame = true; interactionState.active = false; } } }
void HandleInteractionAction(XRNode node, InputHelpers.Button button, ref InteractionState interactionState) { bool pressed = false; //inputDevice.IsPressed(button, out pressed, m_AxisToPressThreshold); float indexPinch = ovrHand.GetFingerPinchStrength(OVRHand.HandFinger.Index); pressed = indexPinch > 0.9f; if (pressed) { if (!interactionState.active) { interactionState.activatedThisFrame = true; interactionState.active = true; } } else { if (interactionState.active) { interactionState.deActivatedThisFrame = true; interactionState.active = false; } } }
private bool GetTriggerUp(InputHelpers.Button trigger) { return(Input.GetKeyUp(TriggerToKeyCode(trigger))); }
public bool CheckIfActivated(XRController controller, InputHelpers.Button activationButton) { InputHelpers.IsPressed(controller.inputDevice, activationButton, out bool isActivated, activationThreshold); return(isActivated); }
/// <summary> /// Is the current button currently active. /// </summary> /// <param name="button">Target button.</param> /// <returns>Is button active.</returns> private bool IsPressed(InputHelpers.Button button) { return(Controller.inputDevice.IsPressed(button, out var down) && down); }