Button State

The input button state is reported based on the HID interrupts arriving to the computer and can be polled by calling ovr_GetInputState.

The following example shows how input can be used in addition to hand poses:

double displayMidpointSeconds = ovr_GetPredictedDisplayTime(session, frameIndex);
ovrTrackingState trackState = ovr_GetTrackingState(session, displayMidpointSeconds, ovrTrue);
ovrPosef         handPoses[2];
ovrInputState    inputState;

// Grab hand poses useful for rendering hand or controller representation
handPoses[ovrHand_Left]  = trackState.HandPoses[ovrHand_Left].ThePose;
handPoses[ovrHand_Right] = trackState.HandPoses[ovrHand_Right].ThePose;

if (OVR_SUCCESS(ovr_GetInputState(session, ovrControllerType_Touch, &inputState)))
{
    if (inputState.Buttons & ovrButton_A)
    {
        // Handle A button being pressed
    }
    if (inputState.HandTrigger[ovrHand_Left] > 0.5f)
    {
        // Handle hand grip...
    }
}

  

The ovrInputState struct includes the following fields:

FieldTypeDescription
TimeInSecondsdoubleSystem time when the controller state was last updated.
ControllerTypeunsigned int

Described by ovrControllerType. Indicates which controller types are present; you can check the ovrControllerType_LTouch bit, for example, to verify that the left touch controller is connected. Options include:

  • ovrControllerType_None (0x0000)
  • ovrControllerType_LTouch (0x0001)
  • ovrControllerType_RTouch (0x0002)
  • ovrControllerType_Touch (0x0003)
  • ovrControllerType_Remote (0x0004)
  • ovrControllerType_XBox (0x0010)
Buttonsunsigned intButton state described by ovrButtons. A corresponding bit is set if the button is pressed.
Touchesunsigned intTouch values for buttons and sensors as indexed by ovrTouch. A corresponding bit is set if users finger is touching the button or is in a gesture state detectable by the controller.
IndexTrigger[2]floatLeft and right finger trigger values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f. A value of 1.0 means that the trigger is fully pressed.
HandTrigger[2]floatLeft and right grip button values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f. Hand trigger is often used to grab items. A value of 1.0 means that the trigger is fully pressed.
Thumbstick[2]ovrVector2fHorizontal and vertical thumbstick axis values (ovrHand_Left and ovrHand_Right), in the range -1.0f to 1.0f. The API automatically applies the dead zone, so developers don’t need to handle it explicitly.
IndexTriggerNoDeadzone[2]floatLeft and right finger trigger values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f, without a deadzone. A value of 1.0 means that the trigger is fully pressed.
HandTriggerNoDeadzone[2]floatLeft and right grip button values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f, without a deadzone. The grip button, formerly known as the hand trigger, is often used to grab items. A value of 1.0 means that the button is fully pressed.
ThumbstickNoDeadzone[2]ovrVector2fHorizontal and vertical thumbstick axis values (ovrHand_Left and ovrHand_Right), in the range -1.0f to 1.0f, without a deadzone.
IndexTriggerRaw[2]floatRaw left and right grip button values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f, without a deadzone or filter. A value of 1.0 means that the trigger is fully pressed.
HandTriggerRaw[2]floatLeft and right grip button values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f, without a deadzone or filter. The grip button, formerly known as the hand trigger, is often used to grab items. A value of 1.0 means that the button is fully pressed.
ThumbstickRaw[2]ovrVector2fHorizontal and vertical thumbstick axis values (ovrHand_Left and ovrHand_Right), in the range -1.0f to 1.0f, without a deadzone or filter.

The ovrInputState structure includes the current state of buttons, thumb sticks, triggers and touch sensors on the controller. You can check whether a button is pressed by checking against one of the button constants, as was done for ovrButton_A in the above example. The following is a list of binary buttons available on touch controllers:

Button ConstantDescription
ovrButton_AA button on the right Touch controller.
ovrButton_BB button on the right Touch controller.
ovrButton_RThumbThumb stick button on the right Touch controller.
ovrButton_XX button on the left Touch controller.
ovrButton_YY button on the left Touch controller.
ovrButton_LThumbThumb stick button on the left Touch controller.
ovrButton_EnterEnter button on the left Touch controller. This is equivalent to the Start button on the Xbox controller.