mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
reenable entitlements check
This commit is contained in:
parent
5729d35c48
commit
799db33b34
3 changed files with 41 additions and 38 deletions
|
@ -23,13 +23,14 @@ void OculusBaseDisplayPlugin::resetSensors() {
|
|||
}
|
||||
|
||||
bool OculusBaseDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
|
||||
ovrSessionStatus status{};
|
||||
if (!OVR_SUCCESS(ovr_GetSessionStatus(_session, &status))) {
|
||||
ovrResult getStatusResult;
|
||||
ovrSessionStatus status = ovr::getStatus(getStatusResult);
|
||||
if (!OVR_SUCCESS(getStatusResult)) {
|
||||
qCWarning(oculusLog) << "Unable to fetch Oculus session status" << ovr::getError();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ovr::quitRequested(status)) {
|
||||
if (ovr::quitRequested(status) || !ovr::handleOVREvents()) {
|
||||
QMetaObject::invokeMethod(qApp, "quit");
|
||||
return false;
|
||||
}
|
||||
|
@ -44,7 +45,7 @@ bool OculusBaseDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
|
|||
_currentRenderFrameInfo = FrameInfo();
|
||||
_currentRenderFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds();
|
||||
_currentRenderFrameInfo.predictedDisplayTime = ovr_GetPredictedDisplayTime(_session, frameIndex);
|
||||
auto trackingState = ovr_GetTrackingState(_session, _currentRenderFrameInfo.predictedDisplayTime, ovrTrue);
|
||||
auto trackingState = ovr::getTrackingState(_currentRenderFrameInfo.predictedDisplayTime, ovrTrue);
|
||||
_currentRenderFrameInfo.renderPose = ovr::toGlm(trackingState.HeadPose.ThePose);
|
||||
_currentRenderFrameInfo.presentPose = _currentRenderFrameInfo.renderPose;
|
||||
|
||||
|
@ -167,7 +168,7 @@ void OculusBaseDisplayPlugin::updatePresentPose() {
|
|||
ovrTrackingState trackingState;
|
||||
_currentPresentFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds();
|
||||
_currentPresentFrameInfo.predictedDisplayTime = ovr_GetPredictedDisplayTime(_session, 0);
|
||||
trackingState = ovr_GetTrackingState(_session, _currentRenderFrameInfo.predictedDisplayTime, ovrFalse);
|
||||
trackingState = ovr::getTrackingState(_currentRenderFrameInfo.predictedDisplayTime);
|
||||
_currentPresentFrameInfo.presentPose = ovr::toGlm(trackingState.HeadPose.ThePose);
|
||||
_currentPresentFrameInfo.renderPose = _currentPresentFrameInfo.presentPose;
|
||||
}
|
||||
|
|
|
@ -81,6 +81,18 @@ private:
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef OCULUS_APP_ID
|
||||
if (qApp->property(hifi::properties::OCULUS_STORE).toBool()) {
|
||||
if (ovr_PlatformInitializeWindows(OCULUS_APP_ID) != ovrPlatformInitialize_Success) {
|
||||
qCWarning(oculusLog) << "Unable to initialize the platform for entitlement check - fail the check" << ovr::getError();
|
||||
return;
|
||||
} else {
|
||||
qCDebug(oculusLog) << "Performing Oculus Platform entitlement check";
|
||||
ovr_Entitlement_GetIsViewerEntitled();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ovrGraphicsLuid luid;
|
||||
if (!OVR_SUCCESS(ovr_Create(&session, &luid))) {
|
||||
qCWarning(oculusLog) << "Failed to acquire Oculus session" << ovr::getError();
|
||||
|
@ -141,18 +153,24 @@ void ovr::withSession(const std::function<void(ovrSession)>& f) {
|
|||
}
|
||||
|
||||
ovrSessionStatus ovr::getStatus() {
|
||||
ovrResult result;
|
||||
return ovr::getStatus(result);
|
||||
}
|
||||
|
||||
ovrSessionStatus ovr::getStatus(ovrResult& result) {
|
||||
ovrSessionStatus status{};
|
||||
withSession([&](ovrSession session) {
|
||||
if (!OVR_SUCCESS(ovr_GetSessionStatus(session, &status))) {
|
||||
result = ovr_GetSessionStatus(session, &status);
|
||||
if (!OVR_SUCCESS(result)) {
|
||||
qCWarning(oculusLog) << "Failed to get session status" << ovr::getError();
|
||||
}
|
||||
});
|
||||
return status;
|
||||
}
|
||||
|
||||
ovrTrackingState ovr::getTrackingState() {
|
||||
ovrTrackingState ovr::getTrackingState(double absTime, ovrBool latencyMarker) {
|
||||
ovrTrackingState result{};
|
||||
withSession([&](ovrSession session) { result = ovr_GetTrackingState(session, 0, ovrFalse); });
|
||||
withSession([&](ovrSession session) { result = ovr_GetTrackingState(session, absTime, latencyMarker); });
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -276,31 +294,25 @@ controller::Pose hifi::ovr::toControllerPose(ovrHandType hand,
|
|||
return pose;
|
||||
}
|
||||
|
||||
// FIXME These should be moved to an oculusPlatform plugin, they don't interact with the controller or session state
|
||||
#if 0
|
||||
void handleOVREvents() {
|
||||
updateSessionStatus(true);
|
||||
|
||||
bool hifi::ovr::handleOVREvents() {
|
||||
#ifdef OCULUS_APP_ID
|
||||
|
||||
if (qApp->property(hifi::properties::OCULUS_STORE).toBool()) {
|
||||
// pop messages to see if we got a return for an entitlement check
|
||||
ovrMessageHandle message = ovr_PopMessage();
|
||||
|
||||
while (message) {
|
||||
switch (ovr_Message_GetType(message)) {
|
||||
case ovrMessage_Entitlement_GetIsViewerEntitled:
|
||||
{
|
||||
if (!ovr_Message_IsError(message)) {
|
||||
// this viewer is entitled, no need to flag anything
|
||||
qCDebug(oculus) << "Oculus Platform entitlement check succeeded, proceeding normally";
|
||||
} else {
|
||||
// we failed the entitlement check, set our flag so the app can stop
|
||||
qCDebug(oculus) << "Oculus Platform entitlement check failed, app will now quit" << OCULUS_APP_ID;
|
||||
_quitRequested = true;
|
||||
case ovrMessage_Entitlement_GetIsViewerEntitled: {
|
||||
if (!ovr_Message_IsError(message)) {
|
||||
// this viewer is entitled, no need to flag anything
|
||||
qCDebug(oculusLog) << "Oculus Platform entitlement check succeeded, proceeding normally";
|
||||
} else {
|
||||
// we failed the entitlement check, quit
|
||||
qCDebug(oculusLog) << "Oculus Platform entitlement check failed, app will now quit" << OCULUS_APP_ID;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// free the message handle to cleanup and not leak
|
||||
ovr_FreeMessage(message);
|
||||
|
@ -310,17 +322,5 @@ void handleOVREvents() {
|
|||
}
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef OCULUS_APP_ID
|
||||
if (qApp->property(hifi::properties::OCULUS_STORE).toBool()) {
|
||||
if (ovr_PlatformInitializeWindows(OCULUS_APP_ID) != ovrPlatformInitialize_Success) {
|
||||
// we were unable to initialize the platform for entitlement check - fail the check
|
||||
_quitRequested = true;
|
||||
} else {
|
||||
qCDebug(oculusLog) << "Performing Oculus Platform entitlement check";
|
||||
ovr_Entitlement_GetIsViewerEntitled();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -27,8 +27,10 @@ struct ovr {
|
|||
static void releaseRenderSession(ovrSession session);
|
||||
static void withSession(const std::function<void(ovrSession)>& f);
|
||||
static ovrSessionStatus getStatus();
|
||||
static ovrTrackingState getTrackingState();
|
||||
static ovrSessionStatus getStatus(ovrResult& result);
|
||||
static ovrTrackingState getTrackingState(double absTime = 0.0, ovrBool latencyMarker = ovrFalse);
|
||||
static QString getError();
|
||||
static bool handleOVREvents();
|
||||
|
||||
static inline bool quitRequested() { return quitRequested(getStatus()); }
|
||||
static inline bool reorientRequested() { return reorientRequested(getStatus()); }
|
||||
|
|
Loading…
Reference in a new issue