mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 1383110 - Force to fetch Oculus Touch tracking data when it is added; r=kip
MozReview-Commit-ID: 4e8qoV6cDzy --HG-- extra : rebase_source : fd5f41fe3d67583af98e50a0bee363989ea00c40
This commit is contained in:
parent
c673ebcff6
commit
6afecdd28e
@ -1552,50 +1552,57 @@ VRSystemManagerOculus::HandleInput()
|
|||||||
axis = static_cast<uint32_t>(OculusControllerAxisType::ThumbstickYAxis);
|
axis = static_cast<uint32_t>(OculusControllerAxisType::ThumbstickYAxis);
|
||||||
HandleAxisMove(i, axis, -inputState.Thumbstick[i].y);
|
HandleAxisMove(i, axis, -inputState.Thumbstick[i].y);
|
||||||
|
|
||||||
// Start to process pose
|
// Process pose state.
|
||||||
|
GamepadPoseState poseState;
|
||||||
|
GetControllerPoseState(handIdx, poseState);
|
||||||
|
HandlePoseTracking(i, poseState, controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
VRSystemManagerOculus::GetControllerPoseState(uint32_t aHandIdx, GamepadPoseState& aPoseState,
|
||||||
|
bool aForceUpdate)
|
||||||
|
{
|
||||||
ovrTrackingState state = ovr_GetTrackingState(mSession->Get(), 0.0, false);
|
ovrTrackingState state = ovr_GetTrackingState(mSession->Get(), 0.0, false);
|
||||||
|
|
||||||
// HandPoses is ordered by ovrControllerType_LTouch and ovrControllerType_RTouch,
|
// HandPoses is ordered by ovrControllerType_LTouch and ovrControllerType_RTouch,
|
||||||
// therefore, we can't get its state by the index of mOculusController.
|
// therefore, we can't get its state by the index of mOculusController.
|
||||||
ovrPoseStatef& pose(state.HandPoses[handIdx]);
|
ovrPoseStatef& pose(state.HandPoses[aHandIdx]);
|
||||||
GamepadPoseState poseState;
|
|
||||||
|
|
||||||
if (state.HandStatusFlags[handIdx] & ovrStatus_OrientationTracked) {
|
if (aForceUpdate || state.HandStatusFlags[aHandIdx] & ovrStatus_OrientationTracked) {
|
||||||
poseState.flags |= GamepadCapabilityFlags::Cap_Orientation;
|
aPoseState.flags |= GamepadCapabilityFlags::Cap_Orientation;
|
||||||
poseState.orientation[0] = pose.ThePose.Orientation.x;
|
aPoseState.orientation[0] = pose.ThePose.Orientation.x;
|
||||||
poseState.orientation[1] = pose.ThePose.Orientation.y;
|
aPoseState.orientation[1] = pose.ThePose.Orientation.y;
|
||||||
poseState.orientation[2] = pose.ThePose.Orientation.z;
|
aPoseState.orientation[2] = pose.ThePose.Orientation.z;
|
||||||
poseState.orientation[3] = pose.ThePose.Orientation.w;
|
aPoseState.orientation[3] = pose.ThePose.Orientation.w;
|
||||||
poseState.angularVelocity[0] = pose.AngularVelocity.x;
|
aPoseState.angularVelocity[0] = pose.AngularVelocity.x;
|
||||||
poseState.angularVelocity[1] = pose.AngularVelocity.y;
|
aPoseState.angularVelocity[1] = pose.AngularVelocity.y;
|
||||||
poseState.angularVelocity[2] = pose.AngularVelocity.z;
|
aPoseState.angularVelocity[2] = pose.AngularVelocity.z;
|
||||||
|
|
||||||
poseState.flags |= GamepadCapabilityFlags::Cap_AngularAcceleration;
|
aPoseState.flags |= GamepadCapabilityFlags::Cap_AngularAcceleration;
|
||||||
poseState.angularAcceleration[0] = pose.AngularAcceleration.x;
|
aPoseState.angularAcceleration[0] = pose.AngularAcceleration.x;
|
||||||
poseState.angularAcceleration[1] = pose.AngularAcceleration.y;
|
aPoseState.angularAcceleration[1] = pose.AngularAcceleration.y;
|
||||||
poseState.angularAcceleration[2] = pose.AngularAcceleration.z;
|
aPoseState.angularAcceleration[2] = pose.AngularAcceleration.z;
|
||||||
poseState.isOrientationValid = true;
|
aPoseState.isOrientationValid = true;
|
||||||
}
|
}
|
||||||
if (state.HandStatusFlags[handIdx] & ovrStatus_PositionTracked) {
|
if (aForceUpdate || state.HandStatusFlags[aHandIdx] & ovrStatus_PositionTracked) {
|
||||||
poseState.flags |= GamepadCapabilityFlags::Cap_Position;
|
aPoseState.flags |= GamepadCapabilityFlags::Cap_Position;
|
||||||
poseState.position[0] = pose.ThePose.Position.x;
|
aPoseState.position[0] = pose.ThePose.Position.x;
|
||||||
poseState.position[1] = pose.ThePose.Position.y;
|
aPoseState.position[1] = pose.ThePose.Position.y;
|
||||||
poseState.position[2] = pose.ThePose.Position.z;
|
aPoseState.position[2] = pose.ThePose.Position.z;
|
||||||
poseState.linearVelocity[0] = pose.LinearVelocity.x;
|
aPoseState.linearVelocity[0] = pose.LinearVelocity.x;
|
||||||
poseState.linearVelocity[1] = pose.LinearVelocity.y;
|
aPoseState.linearVelocity[1] = pose.LinearVelocity.y;
|
||||||
poseState.linearVelocity[2] = pose.LinearVelocity.z;
|
aPoseState.linearVelocity[2] = pose.LinearVelocity.z;
|
||||||
|
|
||||||
poseState.flags |= GamepadCapabilityFlags::Cap_LinearAcceleration;
|
aPoseState.flags |= GamepadCapabilityFlags::Cap_LinearAcceleration;
|
||||||
poseState.linearAcceleration[0] = pose.LinearAcceleration.x;
|
aPoseState.linearAcceleration[0] = pose.LinearAcceleration.x;
|
||||||
poseState.linearAcceleration[1] = pose.LinearAcceleration.y;
|
aPoseState.linearAcceleration[1] = pose.LinearAcceleration.y;
|
||||||
poseState.linearAcceleration[2] = pose.LinearAcceleration.z;
|
aPoseState.linearAcceleration[2] = pose.LinearAcceleration.z;
|
||||||
|
|
||||||
float eyeHeight = ovr_GetFloat(mSession->Get(), OVR_KEY_EYE_HEIGHT, OVR_DEFAULT_EYE_HEIGHT);
|
float eyeHeight = ovr_GetFloat(mSession->Get(), OVR_KEY_EYE_HEIGHT, OVR_DEFAULT_EYE_HEIGHT);
|
||||||
poseState.position[1] -= eyeHeight;
|
aPoseState.position[1] -= eyeHeight;
|
||||||
poseState.isPositionValid = true;
|
aPoseState.isPositionValid = true;
|
||||||
}
|
}
|
||||||
HandlePoseTracking(i, poseState, controller);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1766,6 +1773,11 @@ VRSystemManagerOculus::ScanForControllers()
|
|||||||
ovrInputState inputState;
|
ovrInputState inputState;
|
||||||
bool hasInputState = ovr_GetInputState(mSession->Get(), ovrControllerType_Touch,
|
bool hasInputState = ovr_GetInputState(mSession->Get(), ovrControllerType_Touch,
|
||||||
&inputState) == ovrSuccess;
|
&inputState) == ovrSuccess;
|
||||||
|
|
||||||
|
if (!hasInputState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ovrControllerType activeControllerArray[2];
|
ovrControllerType activeControllerArray[2];
|
||||||
uint32_t newControllerCount = 0;
|
uint32_t newControllerCount = 0;
|
||||||
|
|
||||||
@ -1800,6 +1812,16 @@ VRSystemManagerOculus::ScanForControllers()
|
|||||||
|
|
||||||
// Not already present, add it.
|
// Not already present, add it.
|
||||||
AddGamepad(oculusController->GetControllerInfo());
|
AddGamepad(oculusController->GetControllerInfo());
|
||||||
|
|
||||||
|
// Process pose state.
|
||||||
|
// We wanna Oculus Touch has the right position when it shows up,
|
||||||
|
// so we force to update the pose no matter if it has OrientationTracked
|
||||||
|
// or PositionTracked.
|
||||||
|
const uint32_t handIdx = static_cast<uint32_t>(hand) - 1;
|
||||||
|
GamepadPoseState poseState;
|
||||||
|
GetControllerPoseState(handIdx, poseState, true);
|
||||||
|
HandlePoseTracking(i, poseState, oculusController);
|
||||||
|
|
||||||
++mControllerCount;
|
++mControllerCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,6 +202,9 @@ private:
|
|||||||
void HandleHandTriggerPress(uint32_t aControllerIdx, uint32_t aButton, float aValue);
|
void HandleHandTriggerPress(uint32_t aControllerIdx, uint32_t aButton, float aValue);
|
||||||
void HandleTouchEvent(uint32_t aControllerIdx, uint32_t aButton,
|
void HandleTouchEvent(uint32_t aControllerIdx, uint32_t aButton,
|
||||||
uint64_t aTouchMask, uint64_t aTouched);
|
uint64_t aTouchMask, uint64_t aTouched);
|
||||||
|
void GetControllerPoseState(uint32_t aHandIdx, dom::GamepadPoseState& aPoseState,
|
||||||
|
bool aForceUpdate = false);
|
||||||
|
|
||||||
RefPtr<impl::VRDisplayOculus> mDisplay;
|
RefPtr<impl::VRDisplayOculus> mDisplay;
|
||||||
nsTArray<RefPtr<impl::VRControllerOculus>> mOculusController;
|
nsTArray<RefPtr<impl::VRControllerOculus>> mOculusController;
|
||||||
RefPtr<impl::VROculusSession> mSession;
|
RefPtr<impl::VROculusSession> mSession;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user