OT2O
OT2O

Reputation: 61

SteamVR Touch Pad Directional Input

I am currently able to invoke all inputs on my Vive controller in unity except for directional input from the touch pad.

How can I access the direction the user is pressing?

Here is what I have been trying to use "EVRButtonId.k_EButton_DPad_Up" but have had no success.

Upvotes: 1

Views: 8107

Answers (2)

Tyler Heers
Tyler Heers

Reputation: 132

I had the same issue. What I did to circumvent this issue was:

    if(Controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0)[0] > 0.8f
        && Controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad))
    {
        // code continues...
    }

This seemed to work. Basically, i just used the fact that we know when the pad is pressed down and we know where on the pad user is touching.

This particular example was for the Right side of the touchpad using the x-axis (GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0)[0] . I am unsure if this is the best way, and i probably doubt it, but it works and there is not a lot out there currently in terms of help.

Upvotes: 3

elpha01
elpha01

Reputation: 306

I worked a little on the HTC VIVE API in .NET/C#. I had some problems with the pad because I didn't find anyway to know if the player is touching the pad or not without pressing the pad button, and you'll see that when the player doesn't touch the pad, the API gives a slightly random x,y position because it's a tactile pad.

However try this which gives the right pad x,y position of the pad if the player press on it:

//Get the right device
    rightDevice = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestRight);

//Check if the device is valid
    if(rightDevice == -1){return Vector2.zero;}

//Get the x,y position on the pad
    Vector2 touch = SteamVR_Controller.Input(rightDevice).GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);

    //Check if the player press on the pad button
if(!SteamVR_Controller.Input(deviceDroite).GetPress(SteamVR_Controller.ButtonMask.Touchpad)){return Vector2.zero}

    return touch;

Upvotes: 0

Related Questions