In this post I demonstrate how to use the Vive trackpad in your VR applications using the new SteamVR 2.0 input system. This method is used in my current Early Access project Puzzle Out VR.
Although I will cover the most important aspects of the solution, I highly recommend reading the official documentation to get familiar with the nomenclature. You can find it in the SteamVR plugin root folder named "SteamVR Unity Plugin - Input System". Also some experience in Unity is required such as knowing how to import Assets.
Requirements for the UI
In Puzzle Out VR I use a helmet UI that the player can navigate with the trackpad controls. I wanted the player to be able to navigate the menu by pressing the trackpad up and down while making a selection by pressing the trackpad . I wasn't able to retrieve positional trackpad presses directly from SteamVR, only either the position where a touch was registered OR whether the trackpad was pressed somewhere.
Here is what the UI panel looks like in the game:
The concept is very simple: First, I retrieve the position where the player's thumb has touched the pad and then - within the same method - I listen for trackpad presses and combine this data.
Creating an Action Set
After you have imported the SteamVR plugin from the Asset Store, navigate to Window - SteamVR Input:
In the following dialog, press on the small plus icon next to the premade "buggy" button to create a new action set. Give it an arbitrary name:
In the Actions area to the left, beneath the "In" list, we will add three actions: Navigate, NavigateClick and Confirm.
In the above screenshot you can see that I defined action "Navigate" as a Vector2 type. This represents the positional trackpad tracking. When you look at the trackpad you can imagine a two-dimensional coordinate system with the origin being in the center of the trackpad: the x axis that runs from the center to left and right and the y axis that runs from the center to top and bottom. Or, as Valve's docs are describing it, a "combination of two analog values". Inputs are clamped to values between -1 to 1 for both axes where the lower half of the trackpad have negative values and the upper half has a positive value. We are only interested in the upper and lower halves (y axis).
The next action is NavigateClick which is a boolean type and represents the trackpad press on either the lower or upper half of the trackpad . There's either a trackpad press or not so a boolean type is the correct one.
The last action is "Confirm" and is also of type Boolean. This represents the trigger button on the bottom of the controller. This button can be pressed partially but I wanted to register only full presses so again the value is either true or false.
Now hit "Save and generate". After this process is finished, press "Open binding UI". Note that SteamVR must be running and at least one controller must be turned on. A browser window will open where a button "Create Binding" should be visible. After hitting that button a new page opens. Press the tab with the name you gave the newly created action set:
Now scroll down to see the trackpad section. Here we can bind the physical input controls to the actions we just defined. Click on the pen icon and you will be able to edit the bindings for the trackpad. For "Click" we want the action navigateclick to fire so we select that. "Position" tracks the physical touch on the pad and we want the action "navigate" to fire for that.
Now expand the Trigger section for the same controller. Edit the "Click" event to point to the "confirm" action:
Save the binding and it should be active by default. You are done for now!
Continue to the part 2 of How to use Vive's trackpad for menus using SteamVR. We will look at how these actions are actually used in the game.