예제 #1
0
        private void UpdateGrip()
        {
            var gripPressed    = Math.Abs(Input.GetAxis(Side + StaticAliases.alias_GripSqueeze) - 1) < TOLERANCE;
            var isPressChanged = GetButtonState(gripArgs.GripPress, gripPressed, out var newGripPressState);

            if (!isPressChanged)
            {
                return;
            }
            gripArgs.GripPress = newGripPressState;

            switch (gripArgs.GripPress)
            {
            case InputDataButtonState.Released:
                OnGripReleased?.Invoke(this, gripArgs);
                break;

            case InputDataButtonState.Pressed:
                OnGripPressed?.Invoke(this, gripArgs);
                break;

            case InputDataButtonState.StayReleased:
            case InputDataButtonState.StayPressed:
                break;

            default:
                break;
            }
        }
예제 #2
0
    private void Update()
    {
        if (xrController == null)
        {
            Debug.LogWarning("You did't add XR Controller to the script.");
            return;
        }
        ;

        // Trigger
        if (xrController.inputDevice.TryGetFeatureValue(CommonUsages.trigger, out float intensity))
        {
            OnTriggerIntensity?.Invoke(intensity);
        }
        if (xrController.inputDevice.TryGetFeatureValue(CommonUsages.triggerButton, out bool triggerPressed))
        {
            OnTriggerButtonPressed?.Invoke(triggerPressed);
        }

        // Joystick
        if (xrController.inputDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 primary2Daxis))
        {
            OnPrimary2DAxis?.Invoke(primary2Daxis);
        }
        if (xrController.inputDevice.TryGetFeatureValue(CommonUsages.primary2DAxisClick, out bool primary2Dpressed))
        {
            OnPrimary2DAxisPressed?.Invoke(primary2Dpressed);
        }
        if (xrController.inputDevice.TryGetFeatureValue(CommonUsages.primary2DAxisTouch, out bool primary2DTouched))
        {
            OnPrimary2DAxisTouched?.Invoke(primary2DTouched);
        }

        // Primary button
        if (xrController.inputDevice.TryGetFeatureValue(CommonUsages.primaryButton, out bool primaryButtonPressed))
        {
            OnPrimaryButtonPressed?.Invoke(primaryButtonPressed);
        }
        if (xrController.inputDevice.TryGetFeatureValue(CommonUsages.primaryTouch, out bool primaryTouched))
        {
            OnPrimaryButtonTouched?.Invoke(primaryTouched);
        }

        // Secondary button
        if (xrController.inputDevice.TryGetFeatureValue(CommonUsages.secondaryButton, out bool secondaryButtonPressed))
        {
            OnSecondaryButtonPressed?.Invoke(secondaryButtonPressed);
        }
        if (xrController.inputDevice.TryGetFeatureValue(CommonUsages.secondaryTouch, out bool secondaryTouched))
        {
            OnSecondaryButtonTouched?.Invoke(secondaryTouched);
        }

        // Grip
        if (xrController.inputDevice.TryGetFeatureValue(CommonUsages.grip, out float gripIntensity))
        {
            OnGripIntensity?.Invoke(gripIntensity);
        }
        if (xrController.inputDevice.TryGetFeatureValue(CommonUsages.gripButton, out bool gripPressed))
        {
            OnGripPressed?.Invoke(gripPressed);
        }
    }