SteamVR 触摸板定向输入

SteamVR Touch Pad Directional Input

我目前能够统一调用我的 Vive 控制器上的所有输入,但来自触摸板的定向输入除外。

如何获取用户按下的方向?

这是我一直在尝试使用的 "EVRButtonId.k_EButton_DPad_Up" 但没有成功。

我在 .NET/C# 的 HTC VIVE API 上做了一些工作。我在垫子上遇到了一些问题,因为无论如何我都找不到在不按下垫子按钮的情况下知道玩家是否正在触摸垫子的问题,并且您会看到当玩家没有触摸垫子时, API 给出了一个稍微随机的 x,y 位置,因为它是一个触觉板。

不过试试这个,如果玩家按下它,它会给出正确的垫子 x,y 位置:

//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;

我遇到了同样的问题。我为避免这个问题所做的是:

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

这似乎有效。基本上,我只是利用了这样一个事实,即我们知道何时按下垫子并且我们知道用户触摸垫子的位置。

此特定示例是针对使用 x 轴的触摸板右侧 (GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0)[0] 。我不确定这是否是最佳方式,我可能对此表示怀疑,但它确实有效,而且目前在帮助方面没有太多帮助。