按钮状态

按钮状态输入被通告基于HID中断到达计算机和能被监听通过调用ovr_GetInputState.

下面例子展示了输入怎样被使用除了手姿势:

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...
    }
}
ovrInputState结构包含下面标识符:
Field Type Description
TimeInSeconds double System time when the controller state was last updated.
ConnectionState unsigned 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_LTouch (0x01)
  • ovrControllerType_RTouch (0x02)
  • ovrControllerType_Touch (0x03)
Buttons unsigned int Button state described by ovrButtons. A corresponding bit is set if the button is pressed.
Touches unsigned int Touch 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] float Left 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 depressed.
HandTrigger[2] float Left and right hand trigger 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 depressed.
Thumbstick[2] ovrVector2f Horizontal 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.
ovrInputState结构包括当前按钮状态,拇指,触发器和触摸控制传感器。你能检查一个按钮是否按下同过检查一次一个按钮常量,就像ovrButton_A在上面的例子中一样。下面是一个按钮触摸控制器变量列表:
Button Constant Description
ovrButton_A A button on the right Touch controller.
ovrButton_B B button on the right Touch controller.
ovrButton_RThumb Thumb stick button on the right Touch controller.
ovrButton_X X button on the left Touch controller.
ovrButton_Y Y button on the left Touch controller.
ovrButton_LThumb Thumb stick button on the left Touch controller.


你可能感兴趣的:(按钮状态)