mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:56:44 +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["active_display_plugin"] = getActiveDisplayPlugin()->getName();
|
||||||
properties["using_hmd"] = isHMDMode();
|
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();
|
auto glInfo = getGLContextData();
|
||||||
properties["gl_info"] = glInfo;
|
properties["gl_info"] = glInfo;
|
||||||
properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemSize());
|
properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemSize());
|
||||||
|
@ -3001,9 +2976,19 @@ void Application::initializeDisplayPlugins() {
|
||||||
if (displayPlugin->getName() == lastActiveDisplayPluginName) {
|
if (displayPlugin->getName() == lastActiveDisplayPluginName) {
|
||||||
targetDisplayPlugin = displayPlugin;
|
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,
|
QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged,
|
||||||
[this](const QSize& size) { resizeGL(); });
|
[this](const QSize& size) { resizeGL(); });
|
||||||
QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset);
|
QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset);
|
||||||
|
|
||||||
if (displayPlugin->isHmd()) {
|
if (displayPlugin->isHmd()) {
|
||||||
auto hmdDisplayPlugin = dynamic_cast<HmdDisplayPlugin*>(displayPlugin.get());
|
auto hmdDisplayPlugin = dynamic_cast<HmdDisplayPlugin*>(displayPlugin.get());
|
||||||
QObject::connect(hmdDisplayPlugin, &HmdDisplayPlugin::hmdMountedChanged,
|
QObject::connect(hmdDisplayPlugin, &HmdDisplayPlugin::hmdMountedChanged,
|
||||||
|
@ -3021,6 +3006,17 @@ void Application::initializeDisplayPlugins() {
|
||||||
setDisplayPlugin(targetDisplayPlugin);
|
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
|
// Submit a default frame to render until the engine starts up
|
||||||
updateRenderArgs(0.0f);
|
updateRenderArgs(0.0f);
|
||||||
}
|
}
|
||||||
|
@ -8942,6 +8938,7 @@ void Application::switchDisplayMode() {
|
||||||
if (!_autoSwitchDisplayModeSupportedHMDPlugin) {
|
if (!_autoSwitchDisplayModeSupportedHMDPlugin) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool currentHMDWornStatus = _autoSwitchDisplayModeSupportedHMDPlugin->isDisplayVisible();
|
bool currentHMDWornStatus = _autoSwitchDisplayModeSupportedHMDPlugin->isDisplayVisible();
|
||||||
if (currentHMDWornStatus != _previousHMDWornStatus) {
|
if (currentHMDWornStatus != _previousHMDWornStatus) {
|
||||||
// Switch to respective mode as soon as currentHMDWornStatus changes
|
// Switch to respective mode as soon as currentHMDWornStatus changes
|
||||||
|
|
|
@ -807,7 +807,7 @@ private:
|
||||||
std::queue<SnapshotOperator> _snapshotOperators;
|
std::queue<SnapshotOperator> _snapshotOperators;
|
||||||
bool _hasPrimarySnapshot { false };
|
bool _hasPrimarySnapshot { false };
|
||||||
|
|
||||||
DisplayPluginPointer _autoSwitchDisplayModeSupportedHMDPlugin;
|
DisplayPluginPointer _autoSwitchDisplayModeSupportedHMDPlugin { nullptr };
|
||||||
QString _autoSwitchDisplayModeSupportedHMDPluginName;
|
QString _autoSwitchDisplayModeSupportedHMDPluginName;
|
||||||
bool _previousHMDWornStatus;
|
bool _previousHMDWornStatus;
|
||||||
void startHMDStandBySession();
|
void startHMDStandBySession();
|
||||||
|
|
Loading…
Reference in a new issue