Restore split behavior for inputs/displays on quit

This commit is contained in:
Atlante45 2016-06-20 14:15:45 -07:00
parent 882ad2f6fb
commit 45921a5c8d
3 changed files with 15 additions and 2 deletions

View file

@ -161,7 +161,10 @@ static bool isBadPose(vr::HmdMatrix34_t* mat) {
bool OpenVrDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
handleOpenVrEvents();
if (openVrQuitRequested()) {
QMetaObject::invokeMethod(qApp, "quit");
return false;
}
double displayFrequency = _system->GetFloatTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_DisplayFrequency_Float);
double frameDuration = 1.f / displayFrequency;
double vsyncToPhotons = _system->GetFloatTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SecondsFromVsyncToPhotons_Float);

View file

@ -34,6 +34,11 @@ using Lock = std::unique_lock<Mutex>;
static int refCount { 0 };
static Mutex mutex;
static vr::IVRSystem* activeHmd { nullptr };
static bool _openVrQuitRequested { false };
bool openVrQuitRequested() {
return _openVrQuitRequested;
}
static const uint32_t RELEASE_OPENVR_HMD_DELAY_MS = 5000;
@ -99,6 +104,7 @@ void releaseOpenVrSystem() {
qCDebug(displayplugins) << "OpenVR: zero refcount, deallocate VR system";
#endif
vr::VR_Shutdown();
_openVrQuitRequested = false;
activeHmd = nullptr;
}
}
@ -257,8 +263,8 @@ void handleOpenVrEvents() {
while (activeHmd->PollNextEvent(&event, sizeof(event))) {
switch (event.eventType) {
case vr::VREvent_Quit:
_openVrQuitRequested = true;
activeHmd->AcknowledgeQuit_Exiting();
QMetaObject::invokeMethod(qApp, "quit");
break;
case vr::VREvent_KeyboardDone:

View file

@ -214,6 +214,10 @@ void ViveControllerManager::renderHand(const controller::Pose& pose, gpu::Batch&
void ViveControllerManager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
handleOpenVrEvents();
if (openVrQuitRequested()) {
deactivate();
return;
}
// because update mutates the internal state we need to lock
userInputMapper->withLock([&, this]() {