From 9b5cc05b9f1dea27c7ae8a8353413a04fb80ecdf Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Sun, 28 Jul 2024 14:44:55 +0200 Subject: [PATCH] RMG-Input: add 'SDL controller mode' option --- Source/RMG-Input/UserInterface/MainDialog.cpp | 6 ++- .../RMG-Input/UserInterface/OptionsDialog.cpp | 6 +++ .../RMG-Input/UserInterface/OptionsDialog.ui | 50 +++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/Source/RMG-Input/UserInterface/MainDialog.cpp b/Source/RMG-Input/UserInterface/MainDialog.cpp index 0c816a2f..efcdfbec 100644 --- a/Source/RMG-Input/UserInterface/MainDialog.cpp +++ b/Source/RMG-Input/UserInterface/MainDialog.cpp @@ -139,12 +139,14 @@ void MainDialog::openInputDevice(QString deviceName, int deviceNum) } } - if (SDL_IsGameController(deviceNum) == SDL_TRUE) + int controllerMode = CoreSettingsGetIntValue(SettingsID::Input_ControllerMode); + if ((controllerMode == 0 && SDL_IsGameController(deviceNum) == SDL_TRUE) || + (controllerMode == 2)) { this->currentJoystick = nullptr; this->currentController = SDL_GameControllerOpen(deviceNum); } - else + else if (controllerMode == 0 || controllerMode == 1) { this->currentJoystick = SDL_JoystickOpen(deviceNum); this->currentController = nullptr; diff --git a/Source/RMG-Input/UserInterface/OptionsDialog.cpp b/Source/RMG-Input/UserInterface/OptionsDialog.cpp index b27a3303..b56938a9 100644 --- a/Source/RMG-Input/UserInterface/OptionsDialog.cpp +++ b/Source/RMG-Input/UserInterface/OptionsDialog.cpp @@ -31,6 +31,9 @@ OptionsDialog::OptionsDialog(QWidget* parent, OptionsDialogSettings settings, this->filterEventsForButtonsCheckBox->setChecked(settings.FilterEventsForButtons); this->filterEventsForAxisCheckBox->setChecked(settings.FilterEventsForAxis); + // global settings + this->sdlControllerModeComboBox->setCurrentIndex(CoreSettingsGetIntValue(SettingsID::Input_ControllerMode)); + if (!CoreIsEmulationRunning() && !CoreIsEmulationPaused()) { this->hideEmulationInfoText(); @@ -86,6 +89,9 @@ void OptionsDialog::accept() this->settings.FilterEventsForButtons = this->filterEventsForButtonsCheckBox->isChecked(); this->settings.FilterEventsForAxis = this->filterEventsForAxisCheckBox->isChecked(); + // save global settings now + CoreSettingsSetValue(SettingsID::Input_ControllerMode, this->sdlControllerModeComboBox->currentIndex()); + QDialog::accept(); } diff --git a/Source/RMG-Input/UserInterface/OptionsDialog.ui b/Source/RMG-Input/UserInterface/OptionsDialog.ui index a6a427a2..6bebc882 100644 --- a/Source/RMG-Input/UserInterface/OptionsDialog.ui +++ b/Source/RMG-Input/UserInterface/OptionsDialog.ui @@ -238,6 +238,56 @@ + + + Advanced + + + + + + + + SDL controller mode + + + + + + + + Automatic + + + + + Joystick + + + + + Controller + + + + + + + + + + Qt::Orientation::Vertical + + + + 20 + 322 + + + + + +