Skip to end of metadata
Go to start of metadata



HTC Vive support is now included in CRYENGINE. This article covers the programming side of interacting with a Vive headset. For information on the basics of HTC Vive use, see HTC Vive.



This section describes how to access VR in general, but specifically the HTC Vive from Game Code.

Check VR Setup

In order to check if the current VR setup is valid, you can check if the VR related pointers are set and valid:

C++  Expand source
C#  Expand source

Get HMD Device Tracking State

You can retrieve the position and rotation of the HMD device. While the camera will usually be controlled by the ViewSystem directly, it might be useful to setup additional checks and game-play logic that takes the user's head position into consideration. In the following code samples we will assume pDevice to be set according to 'Check VR Support':

C++  Expand source
C#  Expand source

Get Controller Tracking State

You can get the controller's tracking states similar to the HMD's tracking state.

C++  Expand source
C#  Expand source

React to Controller Input

The controller of the HTC Vive provides more than just tracking information. It has some buttons, a trigger and a touchpad, and you have several options should you want to react to inputs other than just tracking information:


openvr_systemButtonRESERVED! This button opens the SteamVR Dashboard.
openvr_appmenuButtonApplication menu button
openvr_gripButtonGrip button
openvr_touch_xAxisHorizontal axis of the touchpad
openvr_touch_yAxisVertical axis of the touchpad
openvr_triggerTriggerAnalog trigger value
openvr_trigger_btnButtonBinary trigger value (true, if more than half pressed)
openvr_touch_btnButtonPressed if the user is not just touching, but pressing the touchpad


  • InputListener: Please read CryInput. Check for DeviceType eIDT_MotionController and KeyIds:
    • eKI_Motion_OpenVR_System
    •  eKI_Motion_OpenVR_ApplicationMenu
    • eKI_Motion_OpenVR_Grip
    • eKI_Motion_OpenVR_TouchPad_X
    • eKI_Motion_OpenVR_TouchPad_Y
    • eKI_Motion_OpenVR_Trigger
    • eKI_Motion_OpenVR_TriggerBtn
    • eKI_Motion_OpenVR_TouchPadBtn

  • Polling: Additionally, you can poll the current controller state. A nice bonus of this approach, is that you will not only get the information if a button is pressed, but also (in most cases) if the button is just touched:
C++  Expand source
C#  Expand source