private void UpdateSingleAxisData(MixedRealityInteractionMapping interactionMapping)
        {
            Debug.Assert(interactionMapping.AxisType == AxisType.SingleAxis);

            OculusApi.RawAxis1D interactionAxis1D = OculusApi.RawAxis1D.None;
            OculusInteractionMapping.TryParseRawAxis1D(interactionMapping, out interactionAxis1D);
            //Enum.TryParse<OculusApi.RawAxis1D>(interactionMapping.InputName, out interactionAxis1D);

            if (interactionAxis1D != OculusApi.RawAxis1D.None)
            {
                switch (interactionAxis1D)
                {
                case OculusApi.RawAxis1D.LIndexTrigger:
                    singleAxisValue = currentState.LIndexTrigger;

                    //if (shouldApplyDeadzone)
                    //    singleAxisValue = OculusApi.CalculateDeadzone(singleAxisValue, OculusApi.AXIS_DEADZONE_THRESHOLD);

                    singleAxisValue = OculusApi.CalculateAbsMax(0, singleAxisValue);
                    break;

                case OculusApi.RawAxis1D.LHandTrigger:
                    singleAxisValue = currentState.LHandTrigger;

                    //if (shouldApplyDeadzone)
                    //    singleAxisValue = OculusApi.CalculateDeadzone(singleAxisValue, OculusApi.AXIS_DEADZONE_THRESHOLD);

                    singleAxisValue = OculusApi.CalculateAbsMax(0, singleAxisValue);
                    break;

                case OculusApi.RawAxis1D.RIndexTrigger:
                    singleAxisValue = currentState.RIndexTrigger;

                    //if (shouldApplyDeadzone)
                    //    singleAxisValue = OculusApi.CalculateDeadzone(singleAxisValue, OculusApi.AXIS_DEADZONE_THRESHOLD);

                    singleAxisValue = OculusApi.CalculateAbsMax(0, singleAxisValue);
                    break;

                case OculusApi.RawAxis1D.RHandTrigger:
                    singleAxisValue = currentState.RHandTrigger;

                    //if (shouldApplyDeadzone)
                    //    singleAxisValue = OculusApi.CalculateDeadzone(singleAxisValue, OculusApi.AXIS_DEADZONE_THRESHOLD);

                    singleAxisValue = OculusApi.CalculateAbsMax(0, singleAxisValue);
                    break;
                }
            }

            // Update the interaction data source
            interactionMapping.FloatData = singleAxisValue;

            //interactionMapping.UpdateInteractionMappingFloat(InputSource, ControllerHandedness);
            if (interactionMapping.Changed)
            {
                InputSystem?.RaiseFloatInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.FloatData);
            }
        }
Esempio n. 2
0
        private void UpdateDualAxisData(MixedRealityInteractionMapping interactionMapping)
        {
            Debug.Assert(interactionMapping.AxisType == AxisType.DualAxis);

            OculusApi.RawAxis2D interactionAxis2D = OculusApi.RawAxis2D.None;
            Enum.TryParse <OculusApi.RawAxis2D>(interactionMapping.InputName, out interactionAxis2D);

            if (interactionAxis2D != OculusApi.RawAxis2D.None)
            {
                switch (interactionAxis2D)
                {
                case OculusApi.RawAxis2D.LThumbstick:
                    dualAxisPosition.x = currentState.LThumbstick.x;
                    dualAxisPosition.y = currentState.LThumbstick.y;

                    dualAxisPosition = OculusApi.CalculateAbsMax(Vector2.zero, dualAxisPosition);
                    break;

                case OculusApi.RawAxis2D.LTouchpad:
                    dualAxisPosition.x = currentState.LTouchpad.x;
                    dualAxisPosition.y = currentState.LTouchpad.y;

                    dualAxisPosition = OculusApi.CalculateAbsMax(Vector2.zero, dualAxisPosition);
                    break;

                case OculusApi.RawAxis2D.RThumbstick:
                    dualAxisPosition.x = currentState.RThumbstick.x;
                    dualAxisPosition.y = currentState.RThumbstick.y;

                    dualAxisPosition = OculusApi.CalculateAbsMax(Vector2.zero, dualAxisPosition);
                    break;

                case OculusApi.RawAxis2D.RTouchpad:
                    dualAxisPosition.x = currentState.RTouchpad.x;
                    dualAxisPosition.y = currentState.RTouchpad.y;

                    dualAxisPosition = OculusApi.CalculateAbsMax(Vector2.zero, dualAxisPosition);
                    break;
                }
            }

            // Update the interaction data source
            interactionMapping.Vector2Data = dualAxisPosition;

            interactionMapping.UpdateInteractionMappingVector2(InputSource, ControllerHandedness);
        }
Esempio n. 3
0
        private void UpdateSingleAxisData(MixedRealityInteractionMapping interactionMapping)
        {
            Debug.Assert(interactionMapping.AxisType == AxisType.SingleAxis);

            OculusApi.RawAxis1D interactionAxis1D = OculusApi.RawAxis1D.None;
            Enum.TryParse <OculusApi.RawAxis1D>(interactionMapping.InputName, out interactionAxis1D);

            if (interactionAxis1D != OculusApi.RawAxis1D.None)
            {
                switch (interactionAxis1D)
                {
                case OculusApi.RawAxis1D.LIndexTrigger:
                    singleAxisValue = currentState.LIndexTrigger;

                    singleAxisValue = OculusApi.CalculateAbsMax(0, singleAxisValue);
                    break;

                case OculusApi.RawAxis1D.LHandTrigger:
                    singleAxisValue = currentState.LHandTrigger;

                    singleAxisValue = OculusApi.CalculateAbsMax(0, singleAxisValue);
                    break;

                case OculusApi.RawAxis1D.RIndexTrigger:
                    singleAxisValue = currentState.RIndexTrigger;

                    singleAxisValue = OculusApi.CalculateAbsMax(0, singleAxisValue);
                    break;

                case OculusApi.RawAxis1D.RHandTrigger:

                    singleAxisValue = currentState.RHandTrigger;

                    singleAxisValue = OculusApi.CalculateAbsMax(0, singleAxisValue);
                    break;
                }
            }

            // Update the interaction data source
            interactionMapping.FloatData = singleAxisValue;

            interactionMapping.UpdateInteractionMappingFloat(InputSource, ControllerHandedness);
        }
        private void UpdateDualAxisData(MixedRealityInteractionMapping interactionMapping)
        {
            Debug.Assert(interactionMapping.AxisType == AxisType.DualAxis);

            OculusApi.RawAxis2D interactionAxis2D = OculusApi.RawAxis2D.None;
            OculusInteractionMapping.TryParseRawAxis2D(interactionMapping, out interactionAxis2D);
            //Enum.TryParse<OculusApi.RawAxis2D>(interactionMapping.InputName, out interactionAxis2D);

            if (interactionAxis2D != OculusApi.RawAxis2D.None)
            {
                switch (interactionAxis2D)
                {
                case OculusApi.RawAxis2D.LThumbstick:
                    dualAxisPosition.x = currentState.LThumbstick.x;
                    dualAxisPosition.y = currentState.LThumbstick.y;

                    //if (shouldApplyDeadzone)
                    //    dualAxisPosition = OculusApi.CalculateDeadzone(dualAxisPosition, OculusApi.AXIS_DEADZONE_THRESHOLD);

                    dualAxisPosition = OculusApi.CalculateAbsMax(Vector2.zero, dualAxisPosition);
                    break;

                case OculusApi.RawAxis2D.LTouchpad:
                    dualAxisPosition.x = currentState.LTouchpad.x;
                    dualAxisPosition.y = currentState.LTouchpad.y;

                    //if (shouldApplyDeadzone)
                    //    dualAxisPosition = OculusApi.CalculateDeadzone(dualAxisPosition, OculusApi.AXIS_DEADZONE_THRESHOLD);

                    dualAxisPosition = OculusApi.CalculateAbsMax(Vector2.zero, dualAxisPosition);
                    break;

                case OculusApi.RawAxis2D.RThumbstick:

                    dualAxisPosition.x = currentState.RThumbstick.x;
                    dualAxisPosition.y = currentState.RThumbstick.y;

                    //if (shouldApplyDeadzone)
                    //    dualAxisPosition = OculusApi.CalculateDeadzone(dualAxisPosition, OculusApi.AXIS_DEADZONE_THRESHOLD);

                    dualAxisPosition = OculusApi.CalculateAbsMax(Vector2.zero, dualAxisPosition);
                    break;

                case OculusApi.RawAxis2D.RTouchpad:

                    dualAxisPosition.x = currentState.RTouchpad.x;
                    dualAxisPosition.y = currentState.RTouchpad.y;

                    //if (shouldApplyDeadzone)
                    //    dualAxisPosition = OculusApi.CalculateDeadzone(dualAxisPosition, OculusApi.AXIS_DEADZONE_THRESHOLD);

                    dualAxisPosition = OculusApi.CalculateAbsMax(Vector2.zero, dualAxisPosition);
                    break;
                }
            }

            // Update the interaction data source
            interactionMapping.Vector2Data = dualAxisPosition;
            //interactionMapping.UpdateInteractionMappingVector2(InputSource, ControllerHandedness);
            if (interactionMapping.Changed)
            {
                InputSystem?.RaisePositionInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, interactionMapping.Vector2Data);
            }
        }