Skip to content

Commit

Permalink
RMG-Input: add 'SDL controller mode' option
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Jul 28, 2024
1 parent e112e32 commit 9b5cc05
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Source/RMG-Input/UserInterface/MainDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions Source/RMG-Input/UserInterface/OptionsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}

Expand Down
50 changes: 50 additions & 0 deletions Source/RMG-Input/UserInterface/OptionsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,56 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Advanced</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>SDL controller mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="sdlControllerModeComboBox">
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text">
<string>Joystick</string>
</property>
</item>
<item>
<property name="text">
<string>Controller</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>322</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
Expand Down

0 comments on commit 9b5cc05

Please sign in to comment.