Last active
January 29, 2020 22:23
-
-
Save chris-hatton/c1f7b3a344f89a3e78c9346b345ef25e to your computer and use it in GitHub Desktop.
Fragment to get pressed D-Pad button from SteamVR controller in Unity
Oh, also, if you wanted to make it so it captures the press once the user releases the button, instead of currently where it sends a constant stream if the button is held down, you can update your if() statement for device.GetPress()
instad to be device.GetPressUp()
Sorry, I'll stop spamming your wall now, thanks again! (I made sure to credit your gist in my source)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Chris, thank you for your work on this, I don't understand why Valve hasn't enabled the Dpad support yet. While I was using your gist, I found that some of the code didn't work (at least on the current Vive firmware), so I slightly adjusted your code and it seems to be working as itended now.
Thanks again, there's barely any documentation right now!
The parts I slightly adjusted were your left and right if() statements:
if (touchpadAxis.y > (1.0f - threshold)) { return dPadButtonId == EVRButtonId.k_EButton_DPad_Up; } else if (touchpadAxis.y < (-1f + threshold)) { return dPadButtonId == EVRButtonId.k_EButton_DPad_Down; } else if (touchpadAxis.x > (1.0f - threshold)) { return dPadButtonId == EVRButtonId.k_EButton_DPad_Right; } else if (touchpadAxis.x < (-1f + threshold)) { return dPadButtonId == EVRButtonId.k_EButton_DPad_Left; }