adding code for if oculus is running

This commit is contained in:
Wayne Chen 2019-01-28 14:20:03 -08:00
parent 09770920a8
commit c06f2f337e

View file

@ -17,23 +17,27 @@
QString OculusAPIPlugin::NAME { "Oculus Rift" };
OculusAPIPlugin::OculusAPIPlugin() {
if (isRunning()) {
if (hifi::ovr::available()) {
_session = hifi::ovr::acquireRenderSession();
}
}
OculusAPIPlugin::~OculusAPIPlugin() {
if (isRunning()) {
if (hifi::ovr::available() && isRunning()) {
hifi::ovr::releaseRenderSession(_session);
}
}
bool OculusAPIPlugin::isRunning() const {
return (qApp->property(hifi::properties::OCULUS_STORE).toBool());
return _session;
}
void OculusAPIPlugin::requestNonceAndUserID(NonceUserIDCallback callback) {
#ifdef OCULUS_APP_ID
if (!isRunning()) {
return;
}
_nonceUserIDCallback = callback;
ovr_User_GetUserProof();
ovr_User_GetLoggedInUser();
@ -42,7 +46,10 @@ void OculusAPIPlugin::requestNonceAndUserID(NonceUserIDCallback callback) {
void OculusAPIPlugin::handleOVREvents() {
#ifdef OCULUS_APP_ID
if (qApp->property(hifi::properties::OCULUS_STORE).toBool()) {
if (!isRunning()) {
return;
}
// pop messages to see if we got a return for an entitlement check
ovrMessageHandle message { nullptr };
@ -108,6 +115,5 @@ void OculusAPIPlugin::handleOVREvents() {
// free the message handle to cleanup and not leak
ovr_FreeMessage(message);
}
}
#endif
}