Пример #1
0
        public float GetAxis(Axis1D axis)
        {
            var id = (int)axis;

            if (id < _axis.Length)
            {
                return(_axis[(int)axis]);
            }

            return(0.0f);
        }
Пример #2
0
		public RawAxis1D ResolveToRawMask(Axis1D virtualMask)
		{
			return axis1DMap.ToRawMask(virtualMask);
		}
Пример #3
0
			public RawAxis1D ToRawMask(Axis1D virtualMask)
			{
				RawAxis1D rawMask = 0;

				if (virtualMask == Axis1D.None)
					return RawAxis1D.None;

				if ((virtualMask & Axis1D.PrimaryIndexTrigger) != 0)
					rawMask |= PrimaryIndexTrigger;
				if ((virtualMask & Axis1D.PrimaryHandTrigger) != 0)
					rawMask |= PrimaryHandTrigger;
				if ((virtualMask & Axis1D.SecondaryIndexTrigger) != 0)
					rawMask |= SecondaryIndexTrigger;
				if ((virtualMask & Axis1D.SecondaryHandTrigger) != 0)
					rawMask |= SecondaryHandTrigger;

				return rawMask;
			}
Пример #4
0
    private float GetResolvedAxis1D(Axis1D virtualMask, RawAxis1D rawMask, ControllerType controllerMask)
    {
        if (!OVRManager.instance.isVRPresent)
            return 0.0f;

        float maxAxis = 0.0f;

        if ((controllerMask & ControllerType.Active) != 0)
            controllerMask |= activeControllerType;

        for (int i = 0; i < controllers.Count; i++)
        {
            OVRControllerBase controller = controllers[i];

            RawAxis1D resolvedMask = rawMask | controller.ResolveToRawMask(virtualMask);

            if (ShouldResolveController(controller.controllerType, controllerMask))
            {
                if ((RawAxis1D.LIndexTrigger & resolvedMask) != 0)
                {
                    maxAxis = CalculateMax(maxAxis, controller.currentInputState.LIndexTrigger);
                }
                if ((RawAxis1D.RIndexTrigger & resolvedMask) != 0)
                {
                    maxAxis = CalculateMax(maxAxis, controller.currentInputState.RIndexTrigger);
                }
                if ((RawAxis1D.LHandTrigger & resolvedMask) != 0)
                {
                    maxAxis = CalculateMax(maxAxis, controller.currentInputState.LHandTrigger);
                }
                if ((RawAxis1D.RHandTrigger & resolvedMask) != 0)
                {
                    maxAxis = CalculateMax(maxAxis, controller.currentInputState.RHandTrigger);
                }
            }
        }

        return maxAxis;
    }
Пример #5
0
 /// <summary>
 /// Gets the current state of the given virtual 1-dimensional axis mask on the given controller mask.
 /// Returns the value of the largest masked axis across all masked controllers. Values range from 0 to 1.
 /// </summary>
 public static float Get(Axis1D virtualMask, ControllerType controllerMask)
 {
     return OVRManager.input.GetResolvedAxis1D(virtualMask, RawAxis1D.None, controllerMask);
 }
Пример #6
0
	private float GetResolvedAxis1D(Axis1D virtualMask, RawAxis1D rawMask, Controller controllerMask)
	{
#if OVR_LEGACY
		if (!OVRManager.instance.isVRPresent)
			return 0.0f;
#else
		if (!OVRManager.isHmdPresent)
			return 0.0f;
#endif

		float maxAxis = 0.0f;

		if ((controllerMask & Controller.Active) != 0)
			controllerMask |= activeControllerType;

		for (int i = 0; i < controllers.Count; i++)
		{
			OVRControllerBase controller = controllers[i];

			if (ShouldResolveController(controller.controllerType, controllerMask))
			{
				RawAxis1D resolvedMask = rawMask | controller.ResolveToRawMask(virtualMask);

				if ((RawAxis1D.LIndexTrigger & resolvedMask) != 0)
				{
					maxAxis = CalculateAbsMax(maxAxis, controller.currentInputState.LIndexTrigger);
				}
				if ((RawAxis1D.RIndexTrigger & resolvedMask) != 0)
				{
					maxAxis = CalculateAbsMax(maxAxis, controller.currentInputState.RIndexTrigger);
				}
				if ((RawAxis1D.LHandTrigger & resolvedMask) != 0)
				{
					maxAxis = CalculateAbsMax(maxAxis, controller.currentInputState.LHandTrigger);
				}
				if ((RawAxis1D.RHandTrigger & resolvedMask) != 0)
				{
					maxAxis = CalculateAbsMax(maxAxis, controller.currentInputState.RHandTrigger);
				}
			}
		}

		maxAxis = CalculateDeadzone(maxAxis, AXIS_DEADZONE_THRESHOLD);

		return maxAxis;
	}
Пример #7
0
 public static bool Get(Axis1D button)
 {
     return(GetAxis(button) > TriggerThreshold);
 }
    /// <summary>
    /// Gets the current index of the first valid slot of the specified dimension within the specified bounds.
    /// </summary>
    /// <param name="bounds">The bounds to check against.</param>
    /// <param name="axis">The axis of the dimension whose starting index needs to be determined.</param>
    /// <returns>
    /// The current index of the first slot of the specified dimension.
    /// </returns>
    public static int GetCurrentLowerBound(this IDynamicIndexingBounds <Index1D> bounds, Axis1D axis)
    {
        Contracts.Requires.That(bounds != null);

        return(bounds.GetCurrentLowerBound((int)axis));
    }
Пример #9
0
    /// <summary>
    /// Gets the index of the last element of the specified dimension in the array.
    /// </summary>
    /// <typeparam name="T">The type of values stored in the array.</typeparam>
    /// <param name="array">The array.</param>
    /// <param name="dimension">The dimension whose upper bound needs to be determined.</param>
    /// <returns>
    /// The index of the last element of the specified dimension in the array, or -1 if the specified dimension is empty.
    /// </returns>
    public static int GetUpperBound <T>(this T[] array, Axis1D dimension)
    {
        Contracts.Requires.That(array != null);

        return(array.GetUpperBound((int)dimension));
    }
Пример #10
0
    /// <summary>
    /// Gets the index of the last slot of the specified dimension within the specified bounds.
    /// </summary>
    /// <param name="bounds">The bounds to check against.</param>
    /// <param name="axis">The axis of the dimension whose ending index needs to be determined.</param>
    /// <returns>
    /// The index of the last slot of the specified dimension.
    /// </returns>
    public static int GetUpperBound(this IIndexingBounds <Index1D> bounds, Axis1D axis)
    {
        Contracts.Requires.That(bounds != null);

        return(bounds.GetUpperBound((int)axis));
    }
Пример #11
0
    /// <summary>
    /// Gets a 64-bit integer that represents the number of elements in the specified dimension of the array.
    /// </summary>
    /// <typeparam name="T">The type of values stored in the array.</typeparam>
    /// <param name="array">The array.</param>
    /// <param name="dimension">The dimension whose length needs to be determined.</param>
    /// <returns>A 64-bit integer that represents the number of elements in the specified dimension.</returns>
    public static long GetLongLength <T>(this T[] array, Axis1D dimension)
    {
        Contracts.Requires.That(array != null);

        return(array.GetLongLength((int)dimension));
    }
Пример #12
0
 /// <summary>
 /// Gets the coordinate value or index of a particular dimension.
 /// </summary>
 /// <param name="axis">The axis of the dimension whose coordinate needs to be determined.</param>
 /// <returns>The value of the dimensional coordinate.</returns>
 public int this[Axis1D axis] => this[(int)axis];
Пример #13
0
	/// <summary>
	/// Gets the current state of the given virtual 1-dimensional axis mask on the given controller mask.
	/// Returns the value of the largest masked axis across all masked controllers. Values range from 0 to 1.
	/// </summary>
	public static float Get(Axis1D virtualMask, Controller controllerMask = Controller.Active)
	{
        if (OVRManager.isHmdPresent)
        {
            return OVRManager.input.GetResolvedAxis1D(virtualMask, RawAxis1D.None, controllerMask);
        } else
        {
            return 0;
        }
	}
Пример #14
0
	/// <summary>
	/// Gets the current state of the given virtual 1-dimensional axis mask on the given controller mask.
	/// Returns the value of the largest masked axis across all masked controllers. Values range from 0 to 1.
	/// </summary>
	public static float Get(Axis1D virtualMask, Controller controllerMask = Controller.Active)
	{
		return GetResolvedAxis1D(virtualMask, RawAxis1D.None, controllerMask);
	}
Пример #15
0
 public static float GetAxis(Axis1D button)
 {
     return(Input.GetAxis(((InputMapping)button).ToString()));
 }
Пример #16
0
	private static float GetResolvedAxis1D(Axis1D virtualMask, RawAxis1D rawMask, Controller controllerMask)
	{
		float maxAxis = 0.0f;

		if ((controllerMask & Controller.Active) != 0)
			controllerMask |= activeControllerType;

		for (int i = 0; i < controllers.Count; i++)
		{
			OVRControllerBase controller = controllers[i];

			if (ShouldResolveController(controller.controllerType, controllerMask))
			{
				RawAxis1D resolvedMask = rawMask | controller.ResolveToRawMask(virtualMask);

				if ((RawAxis1D.LIndexTrigger & resolvedMask) != 0)
				{
					maxAxis = CalculateAbsMax(maxAxis, controller.currentState.LIndexTrigger);
				}
				if ((RawAxis1D.RIndexTrigger & resolvedMask) != 0)
				{
					maxAxis = CalculateAbsMax(maxAxis, controller.currentState.RIndexTrigger);
				}
				if ((RawAxis1D.LHandTrigger & resolvedMask) != 0)
				{
					maxAxis = CalculateAbsMax(maxAxis, controller.currentState.LHandTrigger);
				}
				if ((RawAxis1D.RHandTrigger & resolvedMask) != 0)
				{
					maxAxis = CalculateAbsMax(maxAxis, controller.currentState.RHandTrigger);
				}
			}
		}

		maxAxis = CalculateDeadzone(maxAxis, AXIS_DEADZONE_THRESHOLD);

		return maxAxis;
	}
Пример #17
0
        public override void Update()
        {
            if (MicroLightManager.Instance)
            {
                if (MicroLightManager.Instance.OpenTracker)
                {
                    //Do to transform Update
                    base.Update();

                    if (MicroLightManager.Instance.mTracker != IntPtr.Zero)
                    {
                        if (MicroLightManager.Instance.deviceType == TrackingDeviceType.MicroLightIR)
                        {
                            if (EnButton)
                            {
                                //Back Button
                                bool Result = MicroLightPlugin.Tracker.GetButtonPressed(MicroLightManager.Instance.mTracker, serialnumber, (int)Button.Back);



                                if (Result)
                                {
                                    if (!BackIsDown)
                                    {
                                        BackIsDown = Result;

                                        if (BackDown != null)
                                        {
                                            BackDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":BackDown");
                                        }
#endif
                                    }
                                    if (BackPressed != null)
                                    {
                                        BackPressed.Invoke();
                                    }

#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":BackPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (BackIsDown)
                                    {
                                        BackIsDown = false;
                                        if (BackUp != null)
                                        {
                                            BackUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":BackUp");
                                        }
#endif
                                    }
                                }

                                //Menu Button
                                Result = MicroLightPlugin.Tracker.GetButtonPressed(MicroLightManager.Instance.mTracker, serialnumber, (int)Button.Menu);
                                if (Result)
                                {
                                    if (!MenuIsDown)
                                    {
                                        MenuIsDown = Result;

                                        if (MenuDown != null)
                                        {
                                            MenuDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":MenuDown");
                                        }
#endif
                                    }


                                    if (MenuPressed != null)
                                    {
                                        MenuPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":MenuPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (MenuIsDown)
                                    {
                                        MenuIsDown = false;
                                        if (MenuUp != null)
                                        {
                                            MenuUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":MenuUp");
                                        }
#endif
                                    }
                                }

                                //IndexTriggerUp Button
                                Result = MicroLightPlugin.Tracker.GetButtonPressed(MicroLightManager.Instance.mTracker, serialnumber, (int)Button.IndexTriggerUp);
                                if (Result)
                                {
                                    if (!IndexTriggerUpIsDown)
                                    {
                                        IndexTriggerUpIsDown = Result;

                                        if (IndexTriggerUpDown != null)
                                        {
                                            IndexTriggerUpDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":IndexTriggerUpDown");
                                        }
#endif
                                    }


                                    if (IndexTriggerUpPressed != null)
                                    {
                                        IndexTriggerUpPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":IndexTriggerUpPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (IndexTriggerUpIsDown)
                                    {
                                        IndexTriggerUpIsDown = false;
                                        if (IndexTriggerUpUp != null)
                                        {
                                            IndexTriggerUpUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":IndexTriggerUpUp");
                                        }
#endif
                                    }
                                }

                                //IndexTriggerDown Button
                                Result = MicroLightPlugin.Tracker.GetButtonPressed(MicroLightManager.Instance.mTracker, serialnumber, (int)Button.IndexTriggerDown);
                                if (Result)
                                {
                                    if (!IndexTriggerDownIsDown)
                                    {
                                        IndexTriggerDownIsDown = Result;

                                        if (IndexTriggerDownDown != null)
                                        {
                                            IndexTriggerDownDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":IndexTriggerDownDown");
                                        }
#endif
                                    }

                                    if (IndexTriggerDownPressed != null)
                                    {
                                        IndexTriggerDownPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":IndexTriggerDownPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (IndexTriggerDownIsDown)
                                    {
                                        IndexTriggerDownIsDown = false;
                                        if (IndexTriggerDownUp != null)
                                        {
                                            IndexTriggerDownUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":IndexTriggerDownUp");
                                        }
#endif
                                    }
                                }

                                //ThumbstickUp Button
                                Result = MicroLightPlugin.Tracker.GetButtonPressed(MicroLightManager.Instance.mTracker, serialnumber, (int)Button.ThumbstickUp);
                                if (Result)
                                {
                                    if (!ThumbstickUpIsDown)
                                    {
                                        ThumbstickUpIsDown = Result;

                                        if (ThumbstickUpDown != null)
                                        {
                                            ThumbstickUpDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickUpDown");
                                        }
#endif
                                    }

                                    if (ThumbstickUpPressed != null)
                                    {
                                        ThumbstickUpPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":ThumbstickUpPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (ThumbstickUpIsDown)
                                    {
                                        ThumbstickUpIsDown = false;
                                        if (ThumbstickUpUp != null)
                                        {
                                            ThumbstickUpUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickUpUp");
                                        }
#endif
                                    }
                                }

                                //ThumbstickDown Button
                                Result = MicroLightPlugin.Tracker.GetButtonPressed(MicroLightManager.Instance.mTracker, serialnumber, (int)Button.ThumbstickDown);
                                if (Result)
                                {
                                    if (!ThumbstickDownIsDown)
                                    {
                                        ThumbstickDownIsDown = Result;

                                        if (ThumbstickDownDown != null)
                                        {
                                            ThumbstickDownDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickDownDown");
                                        }
#endif
                                    }

                                    if (ThumbstickDownPressed != null)
                                    {
                                        ThumbstickDownPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":ThumbstickDownPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (ThumbstickDownIsDown)
                                    {
                                        ThumbstickDownIsDown = false;
                                        if (ThumbstickDownUp != null)
                                        {
                                            ThumbstickDownUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickDownUp");
                                        }
#endif
                                    }
                                }

                                //ThumbstickLeft Button
                                Result = MicroLightPlugin.Tracker.GetButtonPressed(MicroLightManager.Instance.mTracker, serialnumber, (int)Button.ThumbstickLeft);
                                if (Result)
                                {
                                    if (!ThumbstickLeftIsDown)
                                    {
                                        ThumbstickLeftIsDown = Result;

                                        if (ThumbstickLeftDown != null)
                                        {
                                            ThumbstickLeftDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickLeftDown");
                                        }
#endif
                                    }

                                    if (ThumbstickLeftPressed != null)
                                    {
                                        ThumbstickLeftPressed.Invoke();
                                    }
#if DEBUGE
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(controller + ":ThumbstickLeftPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (ThumbstickLeftIsDown)
                                    {
                                        ThumbstickLeftIsDown = false;
                                        if (ThumbstickLeftUp != null)
                                        {
                                            ThumbstickLeftUp.Invoke();
                                        }
#if DEBUGE
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(controller + ":ThumbstickLeftUp");
                                        }
#endif
                                    }
                                }

                                //ThumbstickRight Button
                                Result = MicroLightPlugin.Tracker.GetButtonPressed(MicroLightManager.Instance.mTracker, serialnumber, (int)Button.ThumbstickRight);
                                if (Result)
                                {
                                    if (!ThumbstickRightIsDown)
                                    {
                                        ThumbstickRightIsDown = Result;

                                        if (ThumbstickRightDown != null)
                                        {
                                            ThumbstickRightDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickRightDown");
                                        }
#endif
                                    }

                                    if (ThumbstickRightPressed != null)
                                    {
                                        ThumbstickRightPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":ThumbstickRightPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (ThumbstickRightIsDown)
                                    {
                                        ThumbstickRightIsDown = false;
                                        if (ThumbstickRightUp != null)
                                        {
                                            ThumbstickRightUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickRightUp");
                                        }
#endif
                                    }
                                }
                            }
                            if (EnAxis)
                            {
                                Axis1D IndexTriggerAxisType = Axis1D.RIndexTrigger;

                                if (id == Controller.Touchpad1)

                                {
                                    IndexTriggerAxisType = Axis1D.RIndexTrigger;
                                }
                                if (id == Controller.Touchpad2)

                                {
                                    IndexTriggerAxisType = Axis1D.LIndexTrigger;
                                }
                                float Axis1DValue = MicroLightPlugin.Tracker.GetButtonAxis1D(MicroLightManager.Instance.mTracker, serialnumber, (int)IndexTriggerAxisType);
                                if (IndexTriggerAxis != Axis1DValue)
                                {
                                    IndexTriggerAxis = Axis1DValue;

                                    if (IndexTriggerAxisChanged != null)
                                    {
                                        IndexTriggerAxisChanged.Invoke(IndexTriggerAxis);
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":IndexTriggerAxisChanged");
                                    }
#endif
                                }
                                Axis2D ThumbstickAxisType = Axis2D.RThumbstick;
                                if (id == Controller.Touchpad1)

                                {
                                    ThumbstickAxisType = Axis2D.RThumbstick;

                                    Vector2 Axis2DValue = MicroLightPlugin.Tracker.GetButtonAxis2D(MicroLightManager.Instance.mTracker, serialnumber, (int)ThumbstickAxisType);
                                    if (ThumbstickAxis != Axis2DValue)
                                    {
                                        ThumbstickAxis = Axis2DValue;

                                        if (ThumbstickAxisChanged != null)
                                        {
                                            ThumbstickAxisChanged.Invoke(ThumbstickAxis);
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickAxis");
                                        }
#endif
                                    }
                                }
                                if (id == Controller.Touchpad2)

                                {
                                    ThumbstickAxisType = Axis2D.LThumbstick;

                                    Vector2 Axis2DValue = MicroLightPlugin.Tracker.GetButtonAxis2D(MicroLightManager.Instance.mTracker, serialnumber, (int)ThumbstickAxisType);
                                    if (ThumbstickAxis != Axis2DValue)
                                    {
                                        ThumbstickAxis = Axis2DValue;

                                        if (ThumbstickAxisChanged != null)
                                        {
                                            ThumbstickAxisChanged.Invoke(ThumbstickAxis);
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickAxis");
                                        }
#endif
                                    }
                                }
                            }
                        }
                        else if (MicroLightManager.Instance.deviceType == TrackingDeviceType.LightHouse)
                        {
                            VRControllerState vRControllerState = MicroLightPlugin.Tracker.GetControllerState(MicroLightManager.Instance.mTracker, serialnumber);


                            if (EnButton)
                            {
                                //Back Button
                                bool Result = (vRControllerState.ulButtonPressed & (1UL << ((int)VRButtonId.k_EButton_System))) > 0;
                                if (Result)
                                {
                                    if (!BackIsDown)
                                    {
                                        BackIsDown = Result;

                                        if (BackDown != null)
                                        {
                                            BackDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":BackDown");
                                        }
#endif
                                    }
                                    if (BackPressed != null)
                                    {
                                        BackPressed.Invoke();
                                    }

#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":BackPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (BackIsDown)
                                    {
                                        BackIsDown = false;
                                        if (BackUp != null)
                                        {
                                            BackUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":BackUp");
                                        }
#endif
                                    }
                                }


                                //Menu Button
                                Result = (vRControllerState.ulButtonPressed & (1UL << ((int)VRButtonId.k_EButton_ApplicationMenu))) > 0;
                                if (Result)
                                {
                                    if (!MenuIsDown)
                                    {
                                        MenuIsDown = Result;

                                        if (MenuDown != null)
                                        {
                                            MenuDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":MenuDown");
                                        }
#endif
                                    }


                                    if (MenuPressed != null)
                                    {
                                        MenuPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":MenuPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (MenuIsDown)
                                    {
                                        MenuIsDown = false;
                                        if (MenuUp != null)
                                        {
                                            MenuUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":MenuUp");
                                        }
#endif
                                    }
                                }

                                //IndexTriggerUp Button
                                Result = (vRControllerState.ulButtonPressed & (1UL << ((int)VRButtonId.k_EButton_Grip))) > 0;
                                if (Result)
                                {
                                    if (!IndexTriggerUpIsDown)
                                    {
                                        IndexTriggerUpIsDown = Result;

                                        if (IndexTriggerUpDown != null)
                                        {
                                            IndexTriggerUpDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":IndexTriggerUpDown");
                                        }
#endif
                                    }


                                    if (IndexTriggerUpPressed != null)
                                    {
                                        IndexTriggerUpPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":IndexTriggerUpPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (IndexTriggerUpIsDown)
                                    {
                                        IndexTriggerUpIsDown = false;
                                        if (IndexTriggerUpUp != null)
                                        {
                                            IndexTriggerUpUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":IndexTriggerUpUp");
                                        }
#endif
                                    }
                                }

                                //IndexTriggerDown Button
                                Result = (vRControllerState.ulButtonPressed & (1UL << ((int)VRButtonId.k_EButton_SteamVR_Trigger))) > 0;
                                if (Result)
                                {
                                    if (!IndexTriggerDownIsDown)
                                    {
                                        IndexTriggerDownIsDown = Result;

                                        if (IndexTriggerDownDown != null)
                                        {
                                            IndexTriggerDownDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":IndexTriggerDownDown");
                                        }
#endif
                                    }

                                    if (IndexTriggerDownPressed != null)
                                    {
                                        IndexTriggerDownPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":IndexTriggerDownPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (IndexTriggerDownIsDown)
                                    {
                                        IndexTriggerDownIsDown = false;
                                        if (IndexTriggerDownUp != null)
                                        {
                                            IndexTriggerDownUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":IndexTriggerDownUp");
                                        }
#endif
                                    }
                                }



                                //ThumbstickUp Button
                                Result = (vRControllerState.ulButtonPressed & (1UL << ((int)VRButtonId.k_EButton_SteamVR_Touchpad))) > 0 && Mathf.Abs(ThumbstickAxis.x) < 0.35f && ThumbstickAxis.y > 0.8f;
                                if (Result)
                                {
                                    if (!ThumbstickUpIsDown)
                                    {
                                        ThumbstickUpIsDown = Result;

                                        if (ThumbstickUpDown != null)
                                        {
                                            ThumbstickUpDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickUpDown");
                                        }
#endif
                                    }

                                    if (ThumbstickUpPressed != null)
                                    {
                                        ThumbstickUpPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":ThumbstickUpPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (ThumbstickUpIsDown)
                                    {
                                        ThumbstickUpIsDown = false;
                                        if (ThumbstickUpUp != null)
                                        {
                                            ThumbstickUpUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickUpUp");
                                        }
#endif
                                    }
                                }

                                //ThumbstickDown Button
                                Result = (vRControllerState.ulButtonPressed & (1UL << ((int)VRButtonId.k_EButton_SteamVR_Touchpad))) > 0 && Mathf.Abs(ThumbstickAxis.x) < 0.35f && ThumbstickAxis.y < -0.8f;
                                if (Result)
                                {
                                    if (!ThumbstickDownIsDown)
                                    {
                                        ThumbstickDownIsDown = Result;

                                        if (ThumbstickDownDown != null)
                                        {
                                            ThumbstickDownDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickDownDown");
                                        }
#endif
                                    }

                                    if (ThumbstickDownPressed != null)
                                    {
                                        ThumbstickDownPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":ThumbstickDownPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (ThumbstickDownIsDown)
                                    {
                                        ThumbstickDownIsDown = false;
                                        if (ThumbstickDownUp != null)
                                        {
                                            ThumbstickDownUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickDownUp");
                                        }
#endif
                                    }
                                }

                                //ThumbstickLeft Button
                                Result = (vRControllerState.ulButtonPressed & (1UL << ((int)VRButtonId.k_EButton_SteamVR_Touchpad))) > 0 && Mathf.Abs(ThumbstickAxis.y) < 0.35f && ThumbstickAxis.x < -0.8f;
                                if (Result)
                                {
                                    if (!ThumbstickLeftIsDown)
                                    {
                                        ThumbstickLeftIsDown = Result;

                                        if (ThumbstickLeftDown != null)
                                        {
                                            ThumbstickLeftDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickLeftDown");
                                        }
#endif
                                    }

                                    if (ThumbstickLeftPressed != null)
                                    {
                                        ThumbstickLeftPressed.Invoke();
                                    }
#if DEBUGE
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(controller + ":ThumbstickLeftPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (ThumbstickLeftIsDown)
                                    {
                                        ThumbstickLeftIsDown = false;
                                        if (ThumbstickLeftUp != null)
                                        {
                                            ThumbstickLeftUp.Invoke();
                                        }
#if DEBUGE
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(controller + ":ThumbstickLeftUp");
                                        }
#endif
                                    }
                                }

                                //ThumbstickRight Button
                                Result = (vRControllerState.ulButtonPressed & (1UL << ((int)VRButtonId.k_EButton_SteamVR_Touchpad))) > 0 && Mathf.Abs(ThumbstickAxis.y) < 0.35f && ThumbstickAxis.x > 0.8f;
                                if (Result)
                                {
                                    if (!ThumbstickRightIsDown)
                                    {
                                        ThumbstickRightIsDown = Result;

                                        if (ThumbstickRightDown != null)
                                        {
                                            ThumbstickRightDown.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickRightDown");
                                        }
#endif
                                    }

                                    if (ThumbstickRightPressed != null)
                                    {
                                        ThumbstickRightPressed.Invoke();
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":ThumbstickRightPressed");
                                    }
#endif
                                }
                                else
                                {
                                    if (ThumbstickRightIsDown)
                                    {
                                        ThumbstickRightIsDown = false;
                                        if (ThumbstickRightUp != null)
                                        {
                                            ThumbstickRightUp.Invoke();
                                        }
#if UNITY_EDITOR
                                        if (EditorShowDebug)
                                        {
                                            Debug.Log(id + ":ThumbstickRightUp");
                                        }
#endif
                                    }
                                }
                            }
                            if (EnAxis)
                            {
                                Vector2 Axis2DValue = new Vector2(vRControllerState.rAxis0.x, vRControllerState.rAxis0.y);
                                if (ThumbstickAxis != Axis2DValue)
                                {
                                    ThumbstickAxis = Axis2DValue;

                                    if (ThumbstickAxisChanged != null)
                                    {
                                        ThumbstickAxisChanged.Invoke(ThumbstickAxis);
                                    }
#if UNITY_EDITOR
                                    if (EditorShowDebug)
                                    {
                                        Debug.Log(id + ":ThumbstickAxis");
                                    }
#endif
                                }
                            }
                        }
                    }
                }
            }
        }