From 35250df0b64e9ef2c3a2c076052498424fccd8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kotiuk?= Date: Thu, 20 Jan 2022 21:51:12 +0100 Subject: [PATCH 1/2] Remove unused function used for setting specified display for X11 calls --- src/commandlineutility.cpp | 19 ------------------- src/commandlineutility.h | 3 --- src/main.cpp | 27 --------------------------- src/x11extras.cpp | 16 ---------------- src/x11extras.h | 2 -- 5 files changed, 67 deletions(-) diff --git a/src/commandlineutility.cpp b/src/commandlineutility.cpp index 9b749a617..edb1d4469 100644 --- a/src/commandlineutility.cpp +++ b/src/commandlineutility.cpp @@ -40,7 +40,6 @@ CommandLineUtility::CommandLineUtility(QObject *parent) showRequest = false; unloadProfile = false; startSetNumber = 0; - displayString = ""; listControllers = false; mappingController = false; currentLogLevel = Logger::LOG_NONE; @@ -102,9 +101,6 @@ void CommandLineUtility::parseArguments(const QApplication &parsed_app) "only if you have sdl " "library. You can check your controller index, name or " "even GUID.")}, - // {"display", - // QCoreApplication::translate("main", "Use specified display for - // X11 calls")}, // {"next", // QCoreApplication::translate("main", "Advance profile loading set // options")}, @@ -182,19 +178,6 @@ void CommandLineUtility::parseArguments(const QApplication &parsed_app) parseArgsMap(parser); } -#ifdef WITH_X11 - if (parser.isSet("display")) - { - if (!parser.value("display").isEmpty()) - { - displayString = parser.value("display"); - } else - { - throw std::runtime_error(QObject::tr("No display string was specified.").toStdString()); - } - } -#endif - #if (defined(WITH_UINPUT) && defined(WITH_XTEST)) if (parser.isSet("eventgen")) @@ -456,8 +439,6 @@ bool CommandLineUtility::shouldMapController() { return mappingController; } QString CommandLineUtility::getEventGenerator() { return eventGenerator; } -QString CommandLineUtility::getDisplayString() { return displayString; } - Logger::LogLevel CommandLineUtility::getCurrentLogLevel() { return currentLogLevel; } QString CommandLineUtility::getCurrentLogFile() { return currentLogFile; } diff --git a/src/commandlineutility.h b/src/commandlineutility.h index fd0440f3f..199e4d4fd 100644 --- a/src/commandlineutility.h +++ b/src/commandlineutility.h @@ -117,8 +117,6 @@ class CommandLineUtility : public QObject QList *getJoyStartSetNumberList(); QList const &getControllerOptionsList(); - QString getDisplayString(); - Logger::LogLevel getCurrentLogLevel(); protected: @@ -137,7 +135,6 @@ class CommandLineUtility : public QObject QString profileLocation; QString controllerIDString; - QString displayString; QString eventGenerator; QString currentLogFile; diff --git a/src/main.cpp b/src/main.cpp index 59b919040..a0ef5f449 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -385,33 +385,6 @@ int main(int argc, char *argv[]) localServer = new LocalAntiMicroServer(); localServer->startLocalServer(); - #ifdef WITH_X11 - - if (QApplication::platformName() == QStringLiteral("xcb")) - { - if (!cmdutility.getDisplayString().isEmpty()) - { - X11Extras::getInstance()->syncDisplay(cmdutility.getDisplayString()); - - if (X11Extras::getInstance()->display() == nullptr) - { - qCritical() << QObject::tr("Display string \"%1\" is not valid.").arg(cmdutility.getDisplayString()); - - deleteInputDevices(joysticks); - delete joysticks; - joysticks = nullptr; - - delete localServer; - localServer = nullptr; - - X11Extras::getInstance()->closeDisplay(); - - exit(EXIT_FAILURE); - } - } - } - #endif - #elif defined(Q_OS_WIN) localServer = new LocalAntiMicroServer(); localServer->startLocalServer(); diff --git a/src/x11extras.cpp b/src/x11extras.cpp index 9a2a60047..930a87077 100644 --- a/src/x11extras.cpp +++ b/src/x11extras.cpp @@ -123,22 +123,6 @@ bool X11Extras::hasValidDisplay() { return (_display != nullptr); } */ void X11Extras::closeDisplay() { freeDisplay(); } -/** - * @brief Grab instance of active display. - */ -void X11Extras::syncDisplay() { _display = XOpenDisplay(nullptr); } - -/** - * @brief Grab instance of specified display. Useful for having the GUI - * on one display while generating events on another during ssh tunneling. - * @param Valid display string that X can use - */ -void X11Extras::syncDisplay(QString displayString) -{ - QByteArray tempByteArray = displayString.toLocal8Bit(); - _display = XOpenDisplay(tempByteArray.constData()); -} - void X11Extras::setCustomDisplay(QString displayString) { GlobalVariables::X11Extras::_customDisplayString = displayString; } /** diff --git a/src/x11extras.h b/src/x11extras.h index 47d8ea4e6..7b8e7b04d 100644 --- a/src/x11extras.h +++ b/src/x11extras.h @@ -58,8 +58,6 @@ class X11Extras : public QObject Window findClientWindow(Window window); Window findParentClient(Window window); void closeDisplay(); - void syncDisplay(); - void syncDisplay(QString displayString); static QString getXDisplayString(); QString getWindowTitle(Window window); QString getWindowClass(Window window); From 9d9c9ce5cdb7acdbaa8547c68669a1fcb0f82089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kotiuk?= Date: Sun, 23 Jan 2022 19:02:52 +0100 Subject: [PATCH 2/2] Remove unused --map flag used for opening only mapping window --- src/antimicrosettings.cpp | 4 -- src/commandlineutility.cpp | 41 +---------- src/commandlineutility.h | 3 - src/gui/gamecontrollermappingdialog.cpp | 6 -- src/gui/mainwindow.cpp | 92 +------------------------ src/gui/mainwindow.h | 3 - src/main.cpp | 61 ---------------- 7 files changed, 2 insertions(+), 208 deletions(-) diff --git a/src/antimicrosettings.cpp b/src/antimicrosettings.cpp index 35a7abbbb..1bad48ef8 100644 --- a/src/antimicrosettings.cpp +++ b/src/antimicrosettings.cpp @@ -63,10 +63,6 @@ void AntiMicroSettings::importFromCommandLine(CommandLineUtility &cmdutility) { getCmdSettings().setValue("LaunchInTray", 1); } - if (cmdutility.shouldMapController()) - { - getCmdSettings().setValue("DisplaySDLMapping", 1); - } } /** * @brief applies settings from command line to logger diff --git a/src/commandlineutility.cpp b/src/commandlineutility.cpp index edb1d4469..201097e04 100644 --- a/src/commandlineutility.cpp +++ b/src/commandlineutility.cpp @@ -41,7 +41,6 @@ CommandLineUtility::CommandLineUtility(QObject *parent) unloadProfile = false; startSetNumber = 0; listControllers = false; - mappingController = false; currentLogLevel = Logger::LOG_NONE; currentListsIndex = 0; @@ -104,11 +103,7 @@ void CommandLineUtility::parseArguments(const QApplication &parsed_app) // {"next", // QCoreApplication::translate("main", "Advance profile loading set // options")}, - // {"map", - // QCoreApplication::translate("main", "Open game controller - // mapping window of selected controller. Value can be - // a controller index or GUID."), - // QCoreApplication::translate("main", "value")}, + }); parser.process(parsed_app); @@ -173,11 +168,6 @@ void CommandLineUtility::parseArguments(const QApplication &parsed_app) listControllers = true; } - if (parser.isSet("map")) - { - parseArgsMap(parser); - } - #if (defined(WITH_UINPUT) && defined(WITH_XTEST)) if (parser.isSet("eventgen")) @@ -380,33 +370,6 @@ void CommandLineUtility::parseArgsStartSet(const QCommandLineParser &parser) } } -void CommandLineUtility::parseArgsMap(const QCommandLineParser &parser) -{ - QString mapOptionText = parser.value("map"); - - if (!mapOptionText.isEmpty()) - { - bool validNumber = false; - int tempNumber = mapOptionText.toInt(&validNumber); - - if (validNumber) - { - controllerNumber = tempNumber; - mappingController = true; - } else if (!mapOptionText.isEmpty()) - { - controllerIDString = mapOptionText; - mappingController = true; - } else - { - throw std::runtime_error(QObject::tr("Controller identifier is not a valid value.").toStdString()); - } - } else - { - throw std::runtime_error(QObject::tr("No controller was specified.").toStdString()); - } -} - bool CommandLineUtility::isLaunchInTrayEnabled() { return launchInTray; } bool CommandLineUtility::isTrayHidden() { return hideTrayIcon; } @@ -435,8 +398,6 @@ int CommandLineUtility::getJoyStartSetNumber() { return startSetNumber - 1; } bool CommandLineUtility::shouldListControllers() { return listControllers; } -bool CommandLineUtility::shouldMapController() { return mappingController; } - QString CommandLineUtility::getEventGenerator() { return eventGenerator; } Logger::LogLevel CommandLineUtility::getCurrentLogLevel() { return currentLogLevel; } diff --git a/src/commandlineutility.h b/src/commandlineutility.h index 199e4d4fd..819350a9e 100644 --- a/src/commandlineutility.h +++ b/src/commandlineutility.h @@ -102,7 +102,6 @@ class CommandLineUtility : public QObject bool isShowRequested(); bool isUnloadRequested(); bool shouldListControllers(); - bool shouldMapController(); bool hasProfileInOptions(); int getControllerNumber(); @@ -127,7 +126,6 @@ class CommandLineUtility : public QObject bool showRequest; bool unloadProfile; bool listControllers; - bool mappingController; int startSetNumber; int controllerNumber; @@ -148,7 +146,6 @@ class CommandLineUtility : public QObject void parseArgsPrControle(const QCommandLineParser &parser); void parseArgsUnload(const QCommandLineParser &parser); void parseArgsStartSet(const QCommandLineParser &parser); - void parseArgsMap(const QCommandLineParser &parser); }; #endif // COMMANDLINEPARSER_H diff --git a/src/gui/gamecontrollermappingdialog.cpp b/src/gui/gamecontrollermappingdialog.cpp index a83463ac2..559c9f97c 100644 --- a/src/gui/gamecontrollermappingdialog.cpp +++ b/src/gui/gamecontrollermappingdialog.cpp @@ -332,14 +332,8 @@ void GameControllerMappingDialog::saveChanges() settings->setValue(QString("Mappings/%1%2").arg(device->getUniqueIDString()).arg("Disable"), "0"); settings->sync(); - bool displayMapping = settings->runtimeValue("DisplaySDLMapping", false).toBool(); settings->getLock()->unlock(); - if (displayMapping) - { - PRINT_STDOUT() << generateSDLMappingString(); - } - emit mappingUpdate(mappingString, device); } diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 6476127a9..acc27087d 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -120,8 +120,7 @@ MainWindow::MainWindow(QMap *joysticks, CommandLi #endif signalDisconnect = false; - showTrayIcon = !cmdutility->isTrayHidden() && graphical && !cmdutility->shouldListControllers() && - !cmdutility->shouldMapController(); + showTrayIcon = !cmdutility->isTrayHidden() && graphical && !cmdutility->shouldListControllers(); m_joysticks = joysticks; @@ -174,7 +173,6 @@ MainWindow::MainWindow(QMap *joysticks, CommandLi connect(ui->actionOptions, &QAction::triggered, this, &MainWindow::openMainSettingsDialog); connect(ui->actionWiki, &QAction::triggered, this, &MainWindow::openWikiPage); connect(ui->actionCalibration, &QAction::triggered, this, &MainWindow::openCalibration); - connect(ui->actionGameController_Mapping, &QAction::triggered, this, &MainWindow::openGameControllerMappingWindow); #if defined(WITH_X11) if (QApplication::platformName() == QStringLiteral("xcb")) @@ -299,44 +297,6 @@ void MainWindow::alterConfigFromSettings() } } -void MainWindow::controllerMapOpening() -{ - if (m_cmdutility->shouldMapController()) - { - m_graphical = false; - - const QList tempList = m_cmdutility->getControllerOptionsList(); - ControllerOptionsInfo temp = tempList.at(0); - - if (temp.hasControllerNumber()) - { - int joypadIndex = m_cmdutility->getControllerNumber(); - - qDebug() << "It was antimicrox --map controllerNumber"; - qDebug() << "controllerNumber: " << joypadIndex; - - selectControllerJoyTab(joypadIndex); - openGameControllerMappingWindow(true); - } else if (temp.hasControllerID()) - { - QString joypadGUID = m_cmdutility->getControllerID(); - - qDebug() << "It was antimicrox --map controllerID"; - qDebug() << "controllerID: " << joypadGUID; - - selectControllerJoyTab(joypadGUID); - openGameControllerMappingWindow(true); - } else - { - qDebug() << "Could not find a proper controller identifier. Exiting"; - - qInfo() << tr("Could not find a proper controller identifier. " - "Exiting."); - qApp->quit(); - } - } -} - void MainWindow::fillButtons() { fillButtonsMap(m_joysticks); } void MainWindow::makeJoystickTabs() @@ -1468,36 +1428,6 @@ void MainWindow::restartAsElevated() } #endif -void MainWindow::openGameControllerMappingWindow(bool openAsMain) -{ - int index = ui->tabWidget->currentIndex(); - if (index >= 0) - { - JoyTabWidget *joyTab = qobject_cast(ui->tabWidget->widget(index)); // static_cast - InputDevice *joystick = joyTab->getJoystick(); - if (joystick != nullptr) - { - GameControllerMappingDialog *dialog = new GameControllerMappingDialog(joystick, m_settings, this); - - if (openAsMain) - { - dialog->setParent(nullptr); - dialog->setWindowFlags(Qt::Window); - connect(dialog, &GameControllerMappingDialog::finished, qApp, &QApplication::quit); - } else - { - connect(dialog, &GameControllerMappingDialog::mappingUpdate, this, &MainWindow::propogateMappingUpdate); - } - - dialog->show(); - } - } else if (openAsMain) - { - qInfo() << tr("Could not find controller. Exiting."); - qApp->quit(); - } -} - void MainWindow::propogateMappingUpdate(QString mapping, InputDevice *device) { emit mappingUpdated(mapping, device); } void MainWindow::testMappingUpdateNow(int index, InputDevice *device) @@ -1806,26 +1736,6 @@ void MainWindow::updateButtonPressed() #endif -/** - * @brief Select appropriate tab with the specified index. - * @param Index of appropriate tab. - */ -void MainWindow::selectControllerJoyTab(int index) -{ - if ((index > 0) && m_joysticks->contains(index - 1)) - { - JoyTabWidget *widget = qobject_cast(ui->tabWidget->widget(index - 1)); // static_cast - if (widget != nullptr) - { - qDebug() << "JoyTabWidget was not a null pointer in selectControllerJoyTab of index"; - ui->tabWidget->setCurrentIndex(index - 1); - } else - { - qDebug() << "JoyTabWidget was a NULL POINTER in selectControllerJoyTab of index"; - } - } -} - /** * @brief Select appropriate tab that has a device with the specified GUID. * @param GUID of joystick device. diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index e7c1c5418..3f52023d3 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -107,12 +107,10 @@ class MainWindow : public QMainWindow void quitProgram(); void changeWindowStatus(); void refreshTabHelperThreads(); - void controllerMapOpening(); void testMappingUpdateNow(int index, InputDevice *device); void removeJoyTab(SDL_JoystickID deviceID); void addJoyTab(InputDevice *device); void selectControllerJoyTab(QString GUID); - void selectControllerJoyTab(int index); void handleInstanceDisconnect(); private slots: @@ -144,7 +142,6 @@ class MainWindow : public QMainWindow void restartAsElevated(); #endif - void openGameControllerMappingWindow(bool openAsMain = false); void propogateMappingUpdate(QString mapping, InputDevice *device); void autoprofileLoad(AutoProfileInfo *info); // MainConfiguration class void checkAutoProfileWatcherTimer(); // MainConfiguration class diff --git a/src/main.cpp b/src/main.cpp index a0ef5f449..106ba909b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -479,67 +479,6 @@ int main(int argc, char *argv[]) #endif delete appLogger; return 0; - } else if (cmdutility.shouldMapController()) - { - PadderCommon::mouseHelperObj.initDeskWid(); - QPointer joypad_worker = new InputDaemon(joysticks, &settings); - inputEventThread = new QThread; - - MainWindow *mainWindow = new MainWindow(joysticks, &cmdutility, &settings); - - QObject::connect(&antimicrox, &QApplication::aboutToQuit, mainWindow, &MainWindow::removeJoyTabs); - QObject::connect(&antimicrox, &QApplication::aboutToQuit, joypad_worker.data(), &InputDaemon::quit); - QObject::connect(&antimicrox, &QApplication::aboutToQuit, &PadderCommon::mouseHelperObj, &MouseHelper::deleteDeskWid, - Qt::DirectConnection); - QObject::connect(&antimicrox, &QApplication::aboutToQuit, joypad_worker.data(), &InputDaemon::deleteLater, - Qt::BlockingQueuedConnection); - - mainWindow->makeJoystickTabs(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) - QTimer::singleShot(0, mainWindow, &MainWindow::controllerMapOpening); -#else - QTimer::singleShot(0, mainWindow, SLOT(controllerMapOpening())); -#endif - - joypad_worker->startWorker(); - - joypad_worker->moveToThread(inputEventThread); - PadderCommon::mouseHelperObj.moveToThread(inputEventThread); - inputEventThread->start(QThread::HighPriority); - - int app_result = antimicrox.exec(); - - inputEventThread->quit(); - inputEventThread->wait(); - - delete joysticks; - joysticks = nullptr; - - delete localServer; - localServer = nullptr; - - delete inputEventThread; - inputEventThread = nullptr; - -#ifdef WITH_X11 - - if (QApplication::platformName() == QStringLiteral("xcb")) - { - X11Extras::getInstance()->closeDisplay(); - } - -#endif - - delete mainWindow; - mainWindow = nullptr; - - if (!joypad_worker.isNull()) - { - delete joypad_worker; - joypad_worker.clear(); - } - delete appLogger; - return app_result; } bool status = true;