mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 09:18:45 +02:00
Initial Commit : Switch from HMD [Oculus Rift] mode to Desktop mode automatically when user removing Oculus Rift.
This commit is contained in:
parent
f8b92b6666
commit
0c4cd96bfd
2 changed files with 46 additions and 2 deletions
|
@ -1338,6 +1338,13 @@ 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();
|
||||||
|
|
||||||
|
if (isOculusRiftPluginAvailable()){
|
||||||
|
qCDebug(interfaceapp) << "Oculus Rift Plugin is available";
|
||||||
|
QTimer *switchModeTimer = new QTimer(this);
|
||||||
|
connect(switchModeTimer, SIGNAL(timeout()), this, SLOT(switchmode()));
|
||||||
|
switchModeTimer->start(500);
|
||||||
|
}
|
||||||
|
|
||||||
auto glInfo = getGLContextData();
|
auto glInfo = getGLContextData();
|
||||||
properties["gl_info"] = glInfo;
|
properties["gl_info"] = glInfo;
|
||||||
properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemory());
|
properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemory());
|
||||||
|
@ -6833,6 +6840,39 @@ void Application::updateDisplayMode() {
|
||||||
Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin");
|
Q_ASSERT_X(_displayPlugin, "Application::updateDisplayMode", "could not find an activated display plugin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::isOculusRiftPluginAvailable(){
|
||||||
|
bool isOculusRiftPluginAvailable = false;
|
||||||
|
auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
|
||||||
|
// Default to the first item on the list, in case none of the menu items match
|
||||||
|
DisplayPluginPointer defaultplugin = displayPlugins.at(0);
|
||||||
|
if (defaultplugin->isHmd() && defaultplugin->getName() == "Oculus Rift"){
|
||||||
|
oculusRiftPlugin = defaultplugin;
|
||||||
|
return true; // No need to iterate again,so return
|
||||||
|
}
|
||||||
|
// Iterate to check If Oculus Rift Plugin is available
|
||||||
|
foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) {
|
||||||
|
QString pluginname = displayPlugin->getName();
|
||||||
|
if (displayPlugin->isHmd() && pluginname == "Oculus Rift") {
|
||||||
|
oculusRiftPlugin = displayPlugin;
|
||||||
|
_isDisplayVisible = displayPlugin->isDisplayVisible();
|
||||||
|
isOculusRiftPluginAvailable = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isOculusRiftPluginAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::switchmode(){
|
||||||
|
bool isDisplayVisible = oculusRiftPlugin->isDisplayVisible();
|
||||||
|
if (isDisplayVisible != _isDisplayVisible){
|
||||||
|
if (isDisplayVisible == false && _isDisplayVisible == true){
|
||||||
|
qCDebug(interfaceapp) << "switching from HMD to desktop mode";
|
||||||
|
setActiveDisplayPlugin("Desktop");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_isDisplayVisible = isDisplayVisible; // assign current status
|
||||||
|
}
|
||||||
|
|
||||||
mat4 Application::getEyeProjection(int eye) const {
|
mat4 Application::getEyeProjection(int eye) const {
|
||||||
QMutexLocker viewLocker(&_viewMutex);
|
QMutexLocker viewLocker(&_viewMutex);
|
||||||
if (isHMDMode()) {
|
if (isHMDMode()) {
|
||||||
|
|
|
@ -152,7 +152,7 @@ public:
|
||||||
void paintGL();
|
void paintGL();
|
||||||
void resizeGL();
|
void resizeGL();
|
||||||
|
|
||||||
bool event(QEvent* event) override;
|
bool event(QEvent* event) override;
|
||||||
bool eventFilter(QObject* object, QEvent* event) override;
|
bool eventFilter(QObject* object, QEvent* event) override;
|
||||||
|
|
||||||
glm::uvec2 getCanvasSize() const;
|
glm::uvec2 getCanvasSize() const;
|
||||||
|
@ -443,7 +443,7 @@ private slots:
|
||||||
void addAssetToWorldErrorTimeout();
|
void addAssetToWorldErrorTimeout();
|
||||||
|
|
||||||
void handleSandboxStatus(QNetworkReply* reply);
|
void handleSandboxStatus(QNetworkReply* reply);
|
||||||
|
void switchmode();
|
||||||
private:
|
private:
|
||||||
static void initDisplay();
|
static void initDisplay();
|
||||||
void init();
|
void init();
|
||||||
|
@ -683,6 +683,10 @@ private:
|
||||||
FileScriptingInterface* _fileDownload;
|
FileScriptingInterface* _fileDownload;
|
||||||
AudioInjector* _snapshotSoundInjector { nullptr };
|
AudioInjector* _snapshotSoundInjector { nullptr };
|
||||||
SharedSoundPointer _snapshotSound;
|
SharedSoundPointer _snapshotSound;
|
||||||
|
|
||||||
|
bool isOculusRiftPluginAvailable();
|
||||||
|
DisplayPluginPointer oculusRiftPlugin;
|
||||||
|
bool _isDisplayVisible;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue