mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:35:08 +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["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();
|
||||
properties["gl_info"] = glInfo;
|
||||
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");
|
||||
}
|
||||
|
||||
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 {
|
||||
QMutexLocker viewLocker(&_viewMutex);
|
||||
if (isHMDMode()) {
|
||||
|
|
|
@ -152,7 +152,7 @@ public:
|
|||
void paintGL();
|
||||
void resizeGL();
|
||||
|
||||
bool event(QEvent* event) override;
|
||||
bool event(QEvent* event) override;
|
||||
bool eventFilter(QObject* object, QEvent* event) override;
|
||||
|
||||
glm::uvec2 getCanvasSize() const;
|
||||
|
@ -443,7 +443,7 @@ private slots:
|
|||
void addAssetToWorldErrorTimeout();
|
||||
|
||||
void handleSandboxStatus(QNetworkReply* reply);
|
||||
|
||||
void switchmode();
|
||||
private:
|
||||
static void initDisplay();
|
||||
void init();
|
||||
|
@ -683,6 +683,10 @@ private:
|
|||
FileScriptingInterface* _fileDownload;
|
||||
AudioInjector* _snapshotSoundInjector { nullptr };
|
||||
SharedSoundPointer _snapshotSound;
|
||||
|
||||
bool isOculusRiftPluginAvailable();
|
||||
DisplayPluginPointer oculusRiftPlugin;
|
||||
bool _isDisplayVisible;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue