Merge pull request #14787 from wayne-chen/oculusLoginFeature

MS20874: Only initialize plugin if started through Oculus Store
This commit is contained in:
Jeff Clinton 2019-01-29 10:57:03 -08:00 committed by GitHub
commit 536a76a791
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 96 additions and 68 deletions

View file

@ -802,6 +802,10 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
if (auto steamClient = pluginManager->getSteamClientPlugin()) {
steamClient->init();
}
if (auto oculusPlatform = pluginManager->getOculusPlatformPlugin()) {
oculusPlatform->init();
}
PROFILE_SET_THREAD_NAME("Main Thread");
#if defined(Q_OS_WIN)
@ -2745,6 +2749,10 @@ Application::~Application() {
steamClient->shutdown();
}
if (auto oculusPlatform = PluginManager::getInstance()->getOculusPlatformPlugin()) {
oculusPlatform->shutdown();
}
DependencyManager::destroy<PluginManager>();
DependencyManager::destroy<CompositorHelper>(); // must be destroyed before the FramebufferCache

View file

@ -20,6 +20,9 @@ public:
virtual QString getName() const = 0;
virtual QString getOculusUserID() const = 0;
virtual bool init() = 0;
virtual void shutdown() = 0;
virtual bool isRunning() const = 0;
virtual void requestNonceAndUserID(NonceUserIDCallback callback) = 0;

View file

@ -16,20 +16,31 @@
QString OculusAPIPlugin::NAME { "Oculus Rift" };
OculusAPIPlugin::OculusAPIPlugin() {
bool OculusAPIPlugin::init() {
if (qApp->property(hifi::properties::OCULUS_STORE).toBool()) {
_session = hifi::ovr::acquireRenderSession();
}
return _session;
}
OculusAPIPlugin::~OculusAPIPlugin() {
void OculusAPIPlugin::shutdown() {
if (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()) {
qCWarning(oculusLog) << "Oculus request failed: Oculus platform plugin not running";
callback("", "");
return;
}
_nonceUserIDCallback = callback;
ovr_User_GetUserProof();
ovr_User_GetLoggedInUser();
@ -38,7 +49,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 };
@ -104,6 +118,5 @@ void OculusAPIPlugin::handleOVREvents() {
// free the message handle to cleanup and not leak
ovr_FreeMessage(message);
}
}
#endif
}

View file

@ -16,13 +16,17 @@
class OculusAPIPlugin : public OculusPlatformPlugin {
public:
OculusAPIPlugin();
virtual ~OculusAPIPlugin();
OculusAPIPlugin() = default;
virtual ~OculusAPIPlugin() = default;
QString getName() const { return NAME; }
QString getOculusUserID() const { return _user; };
bool isRunning() const;
bool init();
void shutdown();
virtual void requestNonceAndUserID(NonceUserIDCallback callback);
virtual void handleOVREvents();