Esempio n. 1
0
    public override NVRButtonInputs GetButtonState(NVRHand hand, NVRButtonID button)
    {
        SteamVR_Controller.Device controller;
        if (hand == LeftHand)
        {
            controller = SteamVR_Controller.Input((int)LeftHandTracker.index);
        }
        else
        {
            controller = SteamVR_Controller.Input((int)RightHandTracker.index);
        }

        NVRButtonInputs buttonState = new NVRButtonInputs();

        buttonState.Axis       = controller.GetAxis(InputMap[button]);
        buttonState.SingleAxis = buttonState.Axis.x;
        buttonState.PressDown  = controller.GetPressDown(InputMap[button]);
        buttonState.PressUp    = controller.GetPressUp(InputMap[button]);
        buttonState.IsPressed  = controller.GetPress(InputMap[button]);
        buttonState.TouchDown  = controller.GetTouchDown(InputMap[button]);
        buttonState.TouchUp    = controller.GetTouchUp(InputMap[button]);
        buttonState.IsTouched  = controller.GetTouch(InputMap[button]);

        return(buttonState);
    }
    public override NVRButtonInputs GetButtonState(NVRHand hand, NVRButtonID button)
    {
        NVRButtonInputs buttonState = new NVRButtonInputs();

        switch (button)
        {
        case NVRButtonID.HoldButton:
            if (grasping && !hand.Inputs[button].IsPressed)     // first frame of grasp
            {
                buttonState.Axis       = Vector2.one;
                buttonState.SingleAxis = 1;
                buttonState.PressDown  = true;
                buttonState.PressUp    = false;
                buttonState.IsPressed  = true;
                buttonState.TouchDown  = true;
                buttonState.TouchUp    = false;
                buttonState.IsTouched  = true;
            }
            else if (grasping && hand.Inputs[button].IsPressed)     // we're continuing to grasp
            {
                buttonState.Axis       = Vector2.one;
                buttonState.SingleAxis = 1;
                buttonState.PressDown  = false;
                buttonState.PressUp    = false;
                buttonState.IsPressed  = true;
                buttonState.TouchDown  = false;
                buttonState.TouchUp    = false;
                buttonState.IsTouched  = true;
            }
            else if (!grasping && !hand.Inputs[button].IsPressed)     // not grasping at all
            {
                buttonState.Axis       = Vector2.zero;
                buttonState.SingleAxis = 0;
                buttonState.PressDown  = false;
                buttonState.PressUp    = false;
                buttonState.IsPressed  = false;
                buttonState.TouchDown  = false;
                buttonState.TouchUp    = false;
                buttonState.IsTouched  = false;
            }
            else if (!grasping && hand.Inputs[button].IsPressed)     // first frame of not grasping after a grasp
            {
                buttonState.Axis       = Vector2.zero;
                buttonState.SingleAxis = 0;
                buttonState.PressDown  = false;
                buttonState.PressUp    = true;
                buttonState.IsPressed  = false;
                buttonState.TouchDown  = false;
                buttonState.TouchUp    = true;
                buttonState.IsTouched  = false;
            }

            break;

        case NVRButtonID.UseButton:
            buttonState.Axis       = Vector2.zero;
            buttonState.SingleAxis = 0;
            buttonState.PressDown  = false;
            buttonState.PressUp    = false;
            buttonState.IsPressed  = false;
            buttonState.TouchDown  = false;
            buttonState.TouchUp    = false;
            buttonState.IsTouched  = false;
            break;

        default:
            break;
        }

        return(buttonState);
    }
Esempio n. 3
0
 public override NVRButtonInputs GetButtonState(NVRHand hand, NVRButtonID button)
 {
     throw new NotImplementedException();
 }
Esempio n. 4
0
 /// <summary>
 /// Retrieves button state (pressed/up, etc) for whatever device the given hand is using
 /// </summary>
 /// <param name="hand">Which hand to look up button states for</param>
 /// <param name="button">Which button to check (dev is responsible for mapping NVRButtonID to their device's buttons)</param>
 /// <returns>Complete state of given button for the current frame</returns>
 public abstract NVRButtonInputs GetButtonState(NVRHand hand, NVRButtonID button);