Input System
The heart of the SteamVR Unity Plugin is actions. Virtual Reality is evolving at a rapid rate and we need our software to be able to evolve with the hardware. SteamVR Input abstracts away the device specific parts of your code so you can focus on the intent of the user - their actions. Instead of writing the code to recognize "pulling the trigger button down 75% of the way to grab the block" you can now just focus on the last bit of that, "grab the block". You still configure the default for what "grab" means but the user can rebind it to their preference in a standard interface. And when a new input device comes out your users can publish bindings to share for that device with no code changes on your end.
This style of abstracting input is similar to how many other companies are thinking about it. Members from most of the major Virtual Reality hardware companies have joined Khronos to create the OpenXR standard which is still under development. For more information in participating in this organization and contributing to industry standards like this see: https://www.khronos.org/openxr
SteamVR has separated actions out into 6 different types of input and one output type.
- Boolean - true or false
- Single - an analog value
- Vector2 - two analog values
- Vector3 - three analog values
- Pose - position, rotation, velocity, and angular velocity
- Skeleton - Orientations for each bone in a hand
- Vibration - Actuating haptic motors
Boolean
Boolean actions are values that are either true or false. For example, Grab is a common action that is either true or false. You’re either intending to hold something or you aren’t, there is no in between. With a Vive Wand this may mean pulling the trigger 75%, with an Oculus Touch this may mean pulling the grip trigger 25%, with Knuckles this may be some combination of capacitive sensing and force sensing. But in the end it breaks down to a true or false value.
Single
Single actions are analog values from 0 to 1. These are scenarios where you need more data than just a true or false. There are fewer of these than you’d expect. If previously you were reading a 0 to 1 value and then waiting for it to get to a certain point, a threshold, then you can accomplish the same thing with a boolean action, making it easier for your end user to customize. A good example of a Single action is the Throttle for the RC car in the SteamVR Interaction System. The action your taking as a user can vary depending on how fast you want the car to travel.
Vector2
Vector2 actions are a combination of two analog values. An X and a Y. Generally in VR so far these sort of actions are best represented by the radial menus or 2D positioning. In the SteamVR Interaction System we have an example of steering an RC car as well as a platformer type character. On the Vive Wand this is mapped to the touchpad but on Oculus Touch and Knuckles this is mapped to the joystick. With the RC car we’re using the y axis to determine forward or backward direction and the x axis to determine turning. With the platformer we’re mapping the x/y input onto the direction and magnitude of the character's movement.
Vector3
Vector3 actions are pretty uncommon. In SteamVR Home this is used for scrolling, x, y, and z is the number of pages to scroll.
Pose
Pose actions are a representation of a position and rotation in 3d space. This is used to track your VR controllers. The user can customize these bindings by setting the point on the controller that the pose represents. Some users may find a slightly different tracked position or rotation feels better for them.
Skeleton
Skeleton actions use SteamVR Skeleton Input to get our best estimation of the orientation of your fingers while holding your VR controllers. This provides one standard to get joint positions and rotations for every controller regardless of tracking fidelity. Controllers with the capacity for higher fidelity finger tracking will be more accurate than those without.
Vibration
Vibration actions are used to trigger haptic feedback on VR devices. This could be a controller, a vest, or even a chair.
Using actions
Once you've created your actions you can use them in your own scripts or you can use the unity components we've created that handle some common tasks. These are named SteamVR_Behaviour_Boolean, SteamVR_Behaviour_Single, SteamVR_Behaviour_Vector2, SteamVR_Behaviour_Vector3, SteamVR_Behaviour_Pose, and SteamVR_Behaviour_Skeleton. Drag those onto a GameObject to see what they can do.