mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:08:00 +02:00
Refactor display/input disabling
This commit is contained in:
parent
ec29cfcd51
commit
b05dd3443d
3 changed files with 39 additions and 35 deletions
|
@ -1038,12 +1038,10 @@ Application::Application(
|
||||||
DependencyManager::set<PathUtils>();
|
DependencyManager::set<PathUtils>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::initializePluginManager() {
|
void Application::initializePluginManager(const QCommandLineParser& parser) {
|
||||||
DependencyManager::set<PluginManager>();
|
DependencyManager::set<PluginManager>();
|
||||||
auto pluginManager = PluginManager::getInstance();
|
auto pluginManager = PluginManager::getInstance();
|
||||||
|
|
||||||
qWarning() << "Input plugins: " << getInputPlugins().size();
|
|
||||||
|
|
||||||
// To avoid any confusion: the getInputPlugins and getDisplayPlugins are not the ones
|
// To avoid any confusion: the getInputPlugins and getDisplayPlugins are not the ones
|
||||||
// from PluginManager, but functions exported by input-plugins/InputPlugin.cpp and
|
// from PluginManager, but functions exported by input-plugins/InputPlugin.cpp and
|
||||||
// display-plugins/DisplayPlugin.cpp.
|
// display-plugins/DisplayPlugin.cpp.
|
||||||
|
@ -1052,6 +1050,30 @@ void Application::initializePluginManager() {
|
||||||
pluginManager->setInputPluginProvider([] { return getInputPlugins(); });
|
pluginManager->setInputPluginProvider([] { return getInputPlugins(); });
|
||||||
pluginManager->setDisplayPluginProvider([] { return getDisplayPlugins(); });
|
pluginManager->setDisplayPluginProvider([] { return getDisplayPlugins(); });
|
||||||
pluginManager->setInputPluginSettingsPersister([](const InputPluginList& plugins) { saveInputPluginSettings(plugins); });
|
pluginManager->setInputPluginSettingsPersister([](const InputPluginList& plugins) { saveInputPluginSettings(plugins); });
|
||||||
|
|
||||||
|
|
||||||
|
// This must be a member function -- PluginManager must exist, and for that
|
||||||
|
// QApplication must exist, or it can't find the plugin path, as QCoreApplication:applicationDirPath
|
||||||
|
// won't work yet.
|
||||||
|
|
||||||
|
if (parser.isSet("display")) {
|
||||||
|
auto preferredDisplays = parser.value("display").split(',', Qt::SkipEmptyParts);
|
||||||
|
qInfo() << "Setting prefered display plugins:" << preferredDisplays;
|
||||||
|
PluginManager::getInstance()->setPreferredDisplayPlugins(preferredDisplays);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parser.isSet("disableDisplays")) {
|
||||||
|
auto disabledDisplays = parser.value("disableDisplays").split(',', Qt::SkipEmptyParts);
|
||||||
|
qInfo() << "Disabling following display plugins:" << disabledDisplays;
|
||||||
|
PluginManager::getInstance()->disableDisplays(disabledDisplays);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parser.isSet("disableInputs")) {
|
||||||
|
auto disabledInputs = parser.value("disableInputs").split(',', Qt::SkipEmptyParts);
|
||||||
|
qInfo() << "Disabling following input plugins:" << disabledInputs;
|
||||||
|
PluginManager::getInstance()->disableInputs(disabledInputs);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::initialize(const QCommandLineParser &parser) {
|
void Application::initialize(const QCommandLineParser &parser) {
|
||||||
|
@ -8818,31 +8840,6 @@ void Application::sendLambdaEvent(const std::function<void()>& f) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::configurePlugins(const QCommandLineParser& parser) {
|
|
||||||
// This must be a member function -- PluginManager must exist, and for that
|
|
||||||
// QApplication must exist, or it can't find the plugin path, as QCoreApplication:applicationDirPath
|
|
||||||
// won't work yet.
|
|
||||||
|
|
||||||
if (parser.isSet("display")) {
|
|
||||||
auto preferredDisplays = parser.value("display").split(',', Qt::SkipEmptyParts);
|
|
||||||
qInfo() << "Setting prefered display plugins:" << preferredDisplays;
|
|
||||||
PluginManager::getInstance()->setPreferredDisplayPlugins(preferredDisplays);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parser.isSet("disable-displays")) {
|
|
||||||
auto disabledDisplays = parser.value("disable-displays").split(',', Qt::SkipEmptyParts);
|
|
||||||
qInfo() << "Disabling following display plugins:" << disabledDisplays;
|
|
||||||
PluginManager::getInstance()->disableDisplays(disabledDisplays);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parser.isSet("disable-inputs")) {
|
|
||||||
auto disabledInputs = parser.value("disable-inputs").split(',', Qt::SkipEmptyParts);
|
|
||||||
qInfo() << "Disabling following input plugins:" << disabledInputs;
|
|
||||||
PluginManager::getInstance()->disableInputs(disabledInputs);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::shutdownPlugins() {
|
void Application::shutdownPlugins() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,16 @@ class Application : public QApplication,
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void initializePluginManager();
|
/**
|
||||||
|
* @brief Initialize the plugin manager
|
||||||
|
*
|
||||||
|
* This both does the initial startup and parses arguments. This
|
||||||
|
* is necessary because the plugin manager's options must be set
|
||||||
|
* before any usage of it is made, or they won't apply.
|
||||||
|
*
|
||||||
|
* @param parser
|
||||||
|
*/
|
||||||
|
void initializePluginManager(const QCommandLineParser& parser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize everything
|
* @brief Initialize everything
|
||||||
|
@ -151,8 +160,6 @@ public:
|
||||||
|
|
||||||
virtual DisplayPluginPointer getActiveDisplayPlugin() const override;
|
virtual DisplayPluginPointer getActiveDisplayPlugin() const override;
|
||||||
|
|
||||||
// FIXME? Empty methods, do we still need them?
|
|
||||||
void configurePlugins(const QCommandLineParser& parser);
|
|
||||||
static void shutdownPlugins();
|
static void shutdownPlugins();
|
||||||
|
|
||||||
Application(
|
Application(
|
||||||
|
|
|
@ -142,12 +142,12 @@ int main(int argc, const char* argv[]) {
|
||||||
"displays"
|
"displays"
|
||||||
);
|
);
|
||||||
QCommandLineOption disableDisplaysOption(
|
QCommandLineOption disableDisplaysOption(
|
||||||
"disable-displays",
|
"disableDisplays",
|
||||||
"Displays to disable. Valid options include \"OpenVR (Vive)\" and \"Oculus Rift\"",
|
"Displays to disable. Valid options include \"OpenVR (Vive)\" and \"Oculus Rift\"",
|
||||||
"string"
|
"string"
|
||||||
);
|
);
|
||||||
QCommandLineOption disableInputsOption(
|
QCommandLineOption disableInputsOption(
|
||||||
"disable-inputs",
|
"disableInputs",
|
||||||
"Inputs to disable. Valid options include \"OpenVR (Vive)\" and \"Oculus Rift\"",
|
"Inputs to disable. Valid options include \"OpenVR (Vive)\" and \"Oculus Rift\"",
|
||||||
"string"
|
"string"
|
||||||
);
|
);
|
||||||
|
@ -365,7 +365,7 @@ int main(int argc, const char* argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.initializePluginManager();
|
app.initializePluginManager(parser);
|
||||||
|
|
||||||
if (parser.isSet(getPluginsOption)) {
|
if (parser.isSet(getPluginsOption)) {
|
||||||
auto pluginManager = PluginManager::getInstance();
|
auto pluginManager = PluginManager::getInstance();
|
||||||
|
@ -648,7 +648,7 @@ int main(int argc, const char* argv[]) {
|
||||||
// Oculus initialization MUST PRECEDE OpenGL context creation.
|
// Oculus initialization MUST PRECEDE OpenGL context creation.
|
||||||
// The nature of the Application constructor means this has to be either here,
|
// The nature of the Application constructor means this has to be either here,
|
||||||
// or in the main window ctor, before GL startup.
|
// or in the main window ctor, before GL startup.
|
||||||
app.configurePlugins(parser);
|
//app.configurePlugins(parser);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// If we're running in steam mode, we need to do an explicit check to ensure we're up to the required min spec
|
// If we're running in steam mode, we need to do an explicit check to ensure we're up to the required min spec
|
||||||
|
|
Loading…
Reference in a new issue