static ovrEyeRenderDesc eyeRenderDesc[2];
static ovrPosef hmdToEyeViewPose[2];
static ovrPosef headPose;
-static ovrPosef handPoses[2];
+static ovrPosef handPose;
static ovrInputState inputState;
static ovrLayerEyeFov layer;
static int multisampling;
return -EINVAL;
}
-void get_poses_ovr(int *button_a, int *button_b, int *button_x, int *button_y, int *button_menu, int *button_trigger, int *button_left_thumb, int *button_right_thumb, double *hand_right_x, double *hand_right_y, double *hand_right_z, double *hand_right_yaw, double *hand_right_pitch, double *hand_right_roll, double *stick_left_x, double *stick_left_y, double *stick_right_x, double *stick_right_y, double *head_yaw, double *head_pitch, double *head_roll)
+void get_poses_ovr(int *button_a, int *button_b, int *button_x, int *button_y, int *button_menu, int *button_left_trigger, int *button_right_trigger, int *button_left_thumb, int *button_right_thumb, double *hand_right_x, double *hand_right_y, double *hand_right_z, double *hand_right_yaw, double *hand_right_pitch, double *hand_right_roll, double *stick_left_x, double *stick_left_y, double *stick_right_x, double *stick_right_y, double *head_yaw, double *head_pitch, double *head_roll)
{
ovrResult result;
float yaw, pitch, roll;
double x, y, z;
+ unsigned int hand_mask = (ovrStatus_OrientationTracked | ovrStatus_PositionTracked);
+ unsigned int hand_flags = (ovrStatus_OrientationTracked | ovrStatus_PositionTracked);
/* Get both eye poses simultaneously, with IPD offset already included. */
double displayMidpointSeconds = ovr_GetPredictedDisplayTime(session, frameIndex);
ovr_CalcEyePoses(hmdState.HeadPose.ThePose, hmdToEyeViewPose, layer.RenderPose);
/* Grab hand poses useful for rendering head/hand or controller representation */
headPose = hmdState.HeadPose.ThePose;
- handPoses[ovrHand_Left] = hmdState.HandPoses[ovrHand_Left].ThePose;
- handPoses[ovrHand_Right] = hmdState.HandPoses[ovrHand_Right].ThePose;
- x = handPoses[ovrHand_Right].Position.x;
- y = handPoses[ovrHand_Right].Position.y;
- z = handPoses[ovrHand_Right].Position.z;
+ handPose = headPose;
+// if ((hmdState.HandStatusFlags[ovrHand_Left] & hand_mask) == hand_flags)
+// handPose = hmdState.HandPoses[ovrHand_Left].ThePose;
+ if ((hmdState.HandStatusFlags[ovrHand_Right] & hand_mask) == hand_flags)
+ handPose = hmdState.HandPoses[ovrHand_Right].ThePose;
+ x = handPose.Position.x;
+ y = handPose.Position.y;
+ z = handPose.Position.z;
x += hand_x_reset;
y += hand_y_reset;
z += hand_z_reset;
*head_yaw = yaw;
*head_pitch = pitch;
*head_roll = roll;
- ovrOrientation2yawpitchroll(handPoses[ovrHand_Right].Orientation, &yaw, &pitch, &roll);
+ ovrOrientation2yawpitchroll(handPose.Orientation, &yaw, &pitch, &roll);
*hand_right_yaw = yaw;
*hand_right_pitch = pitch;
*hand_right_roll = roll;
- result = ovr_GetInputState(session, ovrControllerType_Touch, &inputState);
+ result = ovr_GetInputState(session, ovrControllerType_Active, &inputState);
if (OVR_SUCCESS(result)) {
if (inputState.Buttons & ovrButton_A)
*button_a = 1;
*button_right_thumb = 1;
else
*button_right_thumb = 0;
+ if (inputState.IndexTrigger[ovrHand_Left] >= 0.8)
+ *button_left_trigger = 1;
+ else
+ *button_left_trigger = 0;
if (inputState.IndexTrigger[ovrHand_Right] >= 0.8)
- *button_trigger = 1;
+ *button_right_trigger = 1;
else
- *button_trigger = 0;
- *stick_left_x = inputState.Thumbstick[ovrHand_Left].x;
- *stick_left_y = inputState.Thumbstick[ovrHand_Left].y;
- *stick_right_x = inputState.Thumbstick[ovrHand_Right].x;
- *stick_right_y = inputState.Thumbstick[ovrHand_Right].y;
+ *button_right_trigger = 0;
+ *stick_left_x = inputState.ThumbstickNoDeadzone[ovrHand_Left].x;
+ *stick_left_y = inputState.ThumbstickNoDeadzone[ovrHand_Left].y;
+ *stick_right_x = inputState.ThumbstickNoDeadzone[ovrHand_Right].x;
+ *stick_right_y = inputState.ThumbstickNoDeadzone[ovrHand_Right].y;
}
}
print_info("Failed to begin frame (error %d)\n", result);
}
+static int initial_observer_reset = 1;
+
void begin_render_ovr_eye(int eye, double *camera_x, double *camera_y, double *camera_z)
{
int curIndex;
/* reset to game's observer, if requrested by user */
observer_x = x;
- x += observer_x_reset;
observer_y = y;
- y += observer_y_reset;
observer_z = z;
+ if (initial_observer_reset) {
+ initial_observer_reset = 0;
+ reset_observer_ovr();
+ }
+ x += observer_x_reset;
+ y += observer_y_reset;
z += observer_z_reset;
glRotatef(-roll / M_PI * 180.0,0,0,1);