SteamVR Developer Hardware

SteamVR Developer Hardware

Eiseno Dec 13, 2015 @ 4:58am
How Get Pad button press and Swipe in Unity
:steamfacepalm:Hi
I want understand input on pad down-top-left-right press. how can i take this input in unity ?
2. I want understand swipe on pad left to right in unity ?

How can i get this inputs ? Can anyone share code ?

Edit:
I make swipe code and share on github
https://github.com/omerfaruk/htc-vive-swipe
Last edited by Eiseno; Dec 14, 2015 @ 6:35am
< >
Showing 1-3 of 3 comments
SnugglePilot Dec 13, 2015 @ 9:46am 
There's a few other threads very recently here that will help you get on the right track, some code samples in there too:

http://steamcommunity.com/app/358720/discussions/0/487876568222540886/
and
http://steamcommunity.com/app/358720/discussions/0/487876568226759993/

I want understand input on pad down-top-left-right press.

Because the pad is touch-sensitive, it is constantly reporting it's touch location (without clicking it down) via:

[SteamVR_Controller Device].GetAxis(EVRAxisId.k_Axis1);

I believe the touchpad's current touch coordinates are stored in Axis1 (experiment if it doesn't seem right), so the very top left corner of Axis1 would be x: -1, y: -1. This isn't particularly useful as nobody will ever hit the exact top left of the pad; you'll have to write some code to determine what is "close enough". (if I press down just a smidge to the top left of exact center, does that count?)

The intended use cases for controller joysticks and touch quadrants are typically very different from use case to use case, so the engines leave it up to you to code it in a way that makes sense. There are some libraries in the Unity Asset Store that sorta deal with this, such as InControl, but you still have to configure it yourself (and map all the InControl wires to SteamVR which might be too much effort for you).

I recommend writing your own system for practice though.

To detect pushing down on the button, similarly just poll for:

[SteamVR_Controller Device].GetButtonDown(EVRButtonId.k_Touchpad);

I want understand swipe on pad left to right in unity?

Perhaps you can store the X,Y coordinates of the touchpads' current position into an array w/timestamps, and you can compare the last second to see if the touch is trending in a particular direction? There is no built-in "swipe" detection.

The above is largely pseudocode, so I hope it sets you on the right path. Your questions are bordering on the 'how do I code' sorta thing that is a lot more difficult to help with, and might be better/more quickly answered in the Unity forums. Or use your google-fu; here's a quicks earch for swipe detection:

http://answers.unity3d.com/questions/600148/detect-swipe-in-four-directions-android.html
or:
https://pfonseca.com/swipe-detection-on-unity
Eiseno Dec 14, 2015 @ 6:34am 
Thanx i make swipe code and share on github
https://github.com/omerfaruk/htc-vive-swipe
BL1TZ Jun 6, 2016 @ 7:00am 
Thanks for sharing your code on this! Once I saw how to "swipe" the way you swipe (by releasing the touch and calculating the delta's of position and time), I came up with some code to swipe realtime, yet it needs polishing! Anyway, the way it works: whenever you press the touchpad, let a timer record for 0.1 seconds and after that 0.1 second, let it store the endPosition there. Now you calculate the delta position and time (0.1 second). You cant swipe more than once, but it gets close to swiping realtime :)
< >
Showing 1-3 of 3 comments
Per page: 1530 50

Date Posted: Dec 13, 2015 @ 4:58am
Posts: 3