Merge pull request #9167 from Atlante45/feat/oculus-reorient-quit

Honor reorient and quit request from OVR
This commit is contained in:
Chris Collins 2016-12-09 16:03:41 -08:00 committed by GitHub
commit c912d77a95
5 changed files with 40 additions and 5 deletions

View file

@ -4751,7 +4751,7 @@ void Application::resetSensors(bool andReload) {
DependencyManager::get<EyeTracker>()->reset(); DependencyManager::get<EyeTracker>()->reset();
getActiveDisplayPlugin()->resetSensors(); getActiveDisplayPlugin()->resetSensors();
_overlayConductor.centerUI(); _overlayConductor.centerUI();
getMyAvatar()->reset(andReload); getMyAvatar()->reset(true, andReload);
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection); QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection);
} }
@ -5736,6 +5736,7 @@ void Application::updateDisplayMode() {
QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) { QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) {
resizeGL(); resizeGL();
}); });
QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset);
first = false; first = false;
} }

View file

@ -205,7 +205,8 @@ public:
signals: signals:
void recommendedFramebufferSizeChanged(const QSize & size); void recommendedFramebufferSizeChanged(const QSize& size);
void resetSensorsRequested();
protected: protected:
void incrementPresentCount(); void incrementPresentCount();

View file

@ -21,6 +21,15 @@ void OculusBaseDisplayPlugin::resetSensors() {
} }
bool OculusBaseDisplayPlugin::beginFrameRender(uint32_t frameIndex) { bool OculusBaseDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
handleOVREvents();
if (quitRequested()) {
QMetaObject::invokeMethod(qApp, "quit");
return false;
}
if (reorientRequested()) {
emit resetSensorsRequested();
}
_currentRenderFrameInfo = FrameInfo(); _currentRenderFrameInfo = FrameInfo();
_currentRenderFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds(); _currentRenderFrameInfo.sensorSampleTime = ovr_GetTimeInSeconds();
_currentRenderFrameInfo.predictedDisplayTime = ovr_GetPredictedDisplayTime(_session, frameIndex); _currentRenderFrameInfo.predictedDisplayTime = ovr_GetPredictedDisplayTime(_session, frameIndex);

View file

@ -20,15 +20,15 @@
#include <controllers/Pose.h> #include <controllers/Pose.h>
#include <NumericalConstants.h> #include <NumericalConstants.h>
using Mutex = std::mutex;
using Lock = std::unique_lock<Mutex>;
Q_DECLARE_LOGGING_CATEGORY(oculus) Q_DECLARE_LOGGING_CATEGORY(oculus)
Q_LOGGING_CATEGORY(oculus, "hifi.plugins.oculus") Q_LOGGING_CATEGORY(oculus, "hifi.plugins.oculus")
static std::atomic<uint32_t> refCount { 0 }; static std::atomic<uint32_t> refCount { 0 };
static ovrSession session { nullptr }; static ovrSession session { nullptr };
static bool _quitRequested { false };
static bool _reorientRequested { false };
inline ovrErrorInfo getError() { inline ovrErrorInfo getError() {
ovrErrorInfo error; ovrErrorInfo error;
ovr_GetLastErrorInfo(&error); ovr_GetLastErrorInfo(&error);
@ -116,6 +116,26 @@ void releaseOculusSession() {
#endif #endif
} }
void handleOVREvents() {
if (!session) {
return;
}
ovrSessionStatus status;
if (!OVR_SUCCESS(ovr_GetSessionStatus(session, &status))) {
return;
}
_quitRequested = status.ShouldQuit;
_reorientRequested = status.ShouldRecenter;
}
bool quitRequested() {
return _quitRequested;
}
bool reorientRequested() {
return _reorientRequested;
}
controller::Pose ovrControllerPoseToHandPose( controller::Pose ovrControllerPoseToHandPose(
ovrHandType hand, ovrHandType hand,

View file

@ -20,6 +20,10 @@ bool oculusAvailable();
ovrSession acquireOculusSession(); ovrSession acquireOculusSession();
void releaseOculusSession(); void releaseOculusSession();
void handleOVREvents();
bool quitRequested();
bool reorientRequested();
// Convenience method for looping over each eye with a lambda // Convenience method for looping over each eye with a lambda
template <typename Function> template <typename Function>
inline void ovr_for_each_eye(Function function) { inline void ovr_for_each_eye(Function function) {