mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
Restore split behavior for inputs/displays on quit
This commit is contained in:
parent
882ad2f6fb
commit
45921a5c8d
3 changed files with 15 additions and 2 deletions
|
@ -161,7 +161,10 @@ static bool isBadPose(vr::HmdMatrix34_t* mat) {
|
||||||
|
|
||||||
bool OpenVrDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
|
bool OpenVrDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
|
||||||
handleOpenVrEvents();
|
handleOpenVrEvents();
|
||||||
|
if (openVrQuitRequested()) {
|
||||||
|
QMetaObject::invokeMethod(qApp, "quit");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
double displayFrequency = _system->GetFloatTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_DisplayFrequency_Float);
|
double displayFrequency = _system->GetFloatTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_DisplayFrequency_Float);
|
||||||
double frameDuration = 1.f / displayFrequency;
|
double frameDuration = 1.f / displayFrequency;
|
||||||
double vsyncToPhotons = _system->GetFloatTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SecondsFromVsyncToPhotons_Float);
|
double vsyncToPhotons = _system->GetFloatTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SecondsFromVsyncToPhotons_Float);
|
||||||
|
|
|
@ -34,6 +34,11 @@ using Lock = std::unique_lock<Mutex>;
|
||||||
static int refCount { 0 };
|
static int refCount { 0 };
|
||||||
static Mutex mutex;
|
static Mutex mutex;
|
||||||
static vr::IVRSystem* activeHmd { nullptr };
|
static vr::IVRSystem* activeHmd { nullptr };
|
||||||
|
static bool _openVrQuitRequested { false };
|
||||||
|
|
||||||
|
bool openVrQuitRequested() {
|
||||||
|
return _openVrQuitRequested;
|
||||||
|
}
|
||||||
|
|
||||||
static const uint32_t RELEASE_OPENVR_HMD_DELAY_MS = 5000;
|
static const uint32_t RELEASE_OPENVR_HMD_DELAY_MS = 5000;
|
||||||
|
|
||||||
|
@ -99,6 +104,7 @@ void releaseOpenVrSystem() {
|
||||||
qCDebug(displayplugins) << "OpenVR: zero refcount, deallocate VR system";
|
qCDebug(displayplugins) << "OpenVR: zero refcount, deallocate VR system";
|
||||||
#endif
|
#endif
|
||||||
vr::VR_Shutdown();
|
vr::VR_Shutdown();
|
||||||
|
_openVrQuitRequested = false;
|
||||||
activeHmd = nullptr;
|
activeHmd = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,8 +263,8 @@ void handleOpenVrEvents() {
|
||||||
while (activeHmd->PollNextEvent(&event, sizeof(event))) {
|
while (activeHmd->PollNextEvent(&event, sizeof(event))) {
|
||||||
switch (event.eventType) {
|
switch (event.eventType) {
|
||||||
case vr::VREvent_Quit:
|
case vr::VREvent_Quit:
|
||||||
|
_openVrQuitRequested = true;
|
||||||
activeHmd->AcknowledgeQuit_Exiting();
|
activeHmd->AcknowledgeQuit_Exiting();
|
||||||
QMetaObject::invokeMethod(qApp, "quit");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case vr::VREvent_KeyboardDone:
|
case vr::VREvent_KeyboardDone:
|
||||||
|
|
|
@ -214,6 +214,10 @@ void ViveControllerManager::renderHand(const controller::Pose& pose, gpu::Batch&
|
||||||
void ViveControllerManager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
void ViveControllerManager::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
handleOpenVrEvents();
|
handleOpenVrEvents();
|
||||||
|
if (openVrQuitRequested()) {
|
||||||
|
deactivate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// because update mutates the internal state we need to lock
|
// because update mutates the internal state we need to lock
|
||||||
userInputMapper->withLock([&, this]() {
|
userInputMapper->withLock([&, this]() {
|
||||||
|
|
Loading…
Reference in a new issue