only fire the entitlement check if OCULUS_APP_ID is set

This commit is contained in:
Stephen Birarda 2016-12-16 14:53:48 -08:00
parent ea3e5f702a
commit b87a1b2b2b
2 changed files with 34 additions and 7 deletions

View file

@ -11,6 +11,11 @@ if (WIN32)
# we're using static GLEW, so define GLEW_STATIC # we're using static GLEW, so define GLEW_STATIC
add_definitions(-DGLEW_STATIC) add_definitions(-DGLEW_STATIC)
# if we were passed an Oculus App ID for entitlement checks, send that along
if (DEFINED ENV{OCULUS_APP_ID})
add_definitions(-DOCULUS_APP_ID="\\"$ENV{OCULUS_APP_ID}\\"")
endif ()
set(TARGET_NAME oculus) set(TARGET_NAME oculus)
setup_hifi_plugin(Multimedia) setup_hifi_plugin(Multimedia)
link_hifi_libraries( link_hifi_libraries(
@ -18,7 +23,6 @@ if (WIN32)
plugins ui-plugins display-plugins input-plugins plugins ui-plugins display-plugins input-plugins
audio-client networking render-utils audio-client networking render-utils
) )
include_hifi_library_headers(octree) include_hifi_library_headers(octree)
add_dependency_external_projects(LibOVR) add_dependency_external_projects(LibOVR)

View file

@ -30,7 +30,6 @@ static ovrSession session { nullptr };
static bool _quitRequested { false }; static bool _quitRequested { false };
static bool _reorientRequested { false }; static bool _reorientRequested { false };
static bool _entitlementCheckFailed { false };
inline ovrErrorInfo getError() { inline ovrErrorInfo getError() {
ovrErrorInfo error; ovrErrorInfo error;
@ -93,6 +92,18 @@ ovrSession acquireOculusSession() {
return session; return session;
} }
#ifdef OCULUS_APP_ID
if (true) {
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(oculus) << "Performing Oculus Platform entitlement check";
ovr_Entitlement_GetIsViewerEntitled();
}
}
#endif
Q_ASSERT(0 == refCount); Q_ASSERT(0 == refCount);
ovrGraphicsLuid luid; ovrGraphicsLuid luid;
if (!OVR_SUCCESS(ovr_Create(&session, &luid))) { if (!OVR_SUCCESS(ovr_Create(&session, &luid))) {
@ -129,22 +140,34 @@ void handleOVREvents() {
return; return;
} }
_quitRequested = status.ShouldQuit;
_reorientRequested = status.ShouldRecenter;
#ifdef OCULUS_APP_ID
// pop messages to see if we got a return for an entitlement check // pop messages to see if we got a return for an entitlement check
while ((message = ovr_PopMessage()) != nullptr) { ovrMessageHandle message = ovr_PopMessage();
while (message) {
switch (ovr_Message_GetType(message)) { switch (ovr_Message_GetType(message)) {
case ovrMessage_Entitlement_GetIsViewerEntitled: { case ovrMessage_Entitlement_GetIsViewerEntitled: {
if (!ovr_Message_IsError(message)) { if (!ovr_Message_IsError(message)) {
// this viewer is entitled, no need to flag anything // this viewer is entitled, no need to flag anything
qCDebug(oculus) << "Oculus Platform entitlement check succeeded, proceeding normally";
} else { } else {
// we failed the entitlement check, set our flag so the app can stop // we failed the entitlement check, set our flag so the app can stop
_entitlementCheckFailed = true; qCDebug(oculus) << "Oculus Platform entitlement check failed, app will now quit" << OCULUS_APP_ID;
} _quitRequested = true;
} }
} }
} }
_quitRequested = status.ShouldQuit; // free the message handle to cleanup and not leak
_reorientRequested = status.ShouldRecenter; ovr_FreeMessage(message);
// pop the next message to check, if there is one
message = ovr_PopMessage();
}
#endif
} }
bool quitRequested() { bool quitRequested() {