mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-14 01:07:12 +02:00
Merge pull request #14533 from SamGondelman/oculusHome
Case 22439: Fix HMD auto switch detection
This commit is contained in:
commit
1ac1735d55
2 changed files with 23 additions and 26 deletions
|
@ -2220,31 +2220,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
properties["active_display_plugin"] = getActiveDisplayPlugin()->getName();
|
||||
properties["using_hmd"] = isHMDMode();
|
||||
|
||||
_autoSwitchDisplayModeSupportedHMDPlugin = nullptr;
|
||||
foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) {
|
||||
if (displayPlugin->isHmd() &&
|
||||
displayPlugin->getSupportsAutoSwitch()) {
|
||||
_autoSwitchDisplayModeSupportedHMDPlugin = displayPlugin;
|
||||
_autoSwitchDisplayModeSupportedHMDPluginName =
|
||||
_autoSwitchDisplayModeSupportedHMDPlugin->getName();
|
||||
_previousHMDWornStatus =
|
||||
_autoSwitchDisplayModeSupportedHMDPlugin->isDisplayVisible();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_autoSwitchDisplayModeSupportedHMDPlugin) {
|
||||
if (getActiveDisplayPlugin() != _autoSwitchDisplayModeSupportedHMDPlugin &&
|
||||
!_autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) {
|
||||
startHMDStandBySession();
|
||||
}
|
||||
// Poll periodically to check whether the user has worn HMD or not. Switch Display mode accordingly.
|
||||
// If the user wears HMD then switch to VR mode. If the user removes HMD then switch to Desktop mode.
|
||||
QTimer* autoSwitchDisplayModeTimer = new QTimer(this);
|
||||
connect(autoSwitchDisplayModeTimer, SIGNAL(timeout()), this, SLOT(switchDisplayMode()));
|
||||
autoSwitchDisplayModeTimer->start(INTERVAL_TO_CHECK_HMD_WORN_STATUS);
|
||||
}
|
||||
|
||||
auto glInfo = getGLContextData();
|
||||
properties["gl_info"] = glInfo;
|
||||
properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemSize());
|
||||
|
@ -3001,9 +2976,19 @@ void Application::initializeDisplayPlugins() {
|
|||
if (displayPlugin->getName() == lastActiveDisplayPluginName) {
|
||||
targetDisplayPlugin = displayPlugin;
|
||||
}
|
||||
|
||||
if (!_autoSwitchDisplayModeSupportedHMDPlugin) {
|
||||
if (displayPlugin->isHmd() && displayPlugin->getSupportsAutoSwitch()) {
|
||||
_autoSwitchDisplayModeSupportedHMDPlugin = displayPlugin;
|
||||
_autoSwitchDisplayModeSupportedHMDPluginName = _autoSwitchDisplayModeSupportedHMDPlugin->getName();
|
||||
_previousHMDWornStatus = _autoSwitchDisplayModeSupportedHMDPlugin->isDisplayVisible() && _autoSwitchDisplayModeSupportedHMDPlugin->isActive();
|
||||
}
|
||||
}
|
||||
|
||||
QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged,
|
||||
[this](const QSize& size) { resizeGL(); });
|
||||
QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset);
|
||||
|
||||
if (displayPlugin->isHmd()) {
|
||||
auto hmdDisplayPlugin = dynamic_cast<HmdDisplayPlugin*>(displayPlugin.get());
|
||||
QObject::connect(hmdDisplayPlugin, &HmdDisplayPlugin::hmdMountedChanged,
|
||||
|
@ -3021,6 +3006,17 @@ void Application::initializeDisplayPlugins() {
|
|||
setDisplayPlugin(targetDisplayPlugin);
|
||||
}
|
||||
|
||||
if (_autoSwitchDisplayModeSupportedHMDPlugin) {
|
||||
if (getActiveDisplayPlugin() != _autoSwitchDisplayModeSupportedHMDPlugin && !_autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) {
|
||||
startHMDStandBySession();
|
||||
}
|
||||
// Poll periodically to check whether the user has worn HMD or not. Switch Display mode accordingly.
|
||||
// If the user wears HMD then switch to VR mode. If the user removes HMD then switch to Desktop mode.
|
||||
QTimer* autoSwitchDisplayModeTimer = new QTimer(this);
|
||||
connect(autoSwitchDisplayModeTimer, SIGNAL(timeout()), this, SLOT(switchDisplayMode()));
|
||||
autoSwitchDisplayModeTimer->start(INTERVAL_TO_CHECK_HMD_WORN_STATUS);
|
||||
}
|
||||
|
||||
// Submit a default frame to render until the engine starts up
|
||||
updateRenderArgs(0.0f);
|
||||
}
|
||||
|
@ -8942,6 +8938,7 @@ void Application::switchDisplayMode() {
|
|||
if (!_autoSwitchDisplayModeSupportedHMDPlugin) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool currentHMDWornStatus = _autoSwitchDisplayModeSupportedHMDPlugin->isDisplayVisible();
|
||||
if (currentHMDWornStatus != _previousHMDWornStatus) {
|
||||
// Switch to respective mode as soon as currentHMDWornStatus changes
|
||||
|
|
|
@ -807,7 +807,7 @@ private:
|
|||
std::queue<SnapshotOperator> _snapshotOperators;
|
||||
bool _hasPrimarySnapshot { false };
|
||||
|
||||
DisplayPluginPointer _autoSwitchDisplayModeSupportedHMDPlugin;
|
||||
DisplayPluginPointer _autoSwitchDisplayModeSupportedHMDPlugin { nullptr };
|
||||
QString _autoSwitchDisplayModeSupportedHMDPluginName;
|
||||
bool _previousHMDWornStatus;
|
||||
void startHMDStandBySession();
|
||||
|
|
Loading…
Reference in a new issue