Config: toggle background controller inputs (#3424)

This commit is contained in:
rainmakerv2
2025-08-17 00:45:54 +08:00
committed by GitHub
parent e93fd00dc7
commit 3a929515e7
7 changed files with 46 additions and 10 deletions

View File

@@ -1020,7 +1020,9 @@ void ControlSettings::Cleanup() {
SDL_QuitSubSystem(SDL_INIT_EVENTS);
SDL_Quit();
} else {
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
if (!Config::getBackgroundControllerInput()) {
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
}
SDL_Event checkGamepad{};
checkGamepad.type = SDL_EVENT_CHANGE_CONTROLLER;
SDL_PushEvent(&checkGamepad);

View File

@@ -385,7 +385,9 @@ void hotkeys::Cleanup() {
SDL_QuitSubSystem(SDL_INIT_EVENTS);
SDL_Quit();
} else {
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
if (!Config::getBackgroundControllerInput()) {
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
}
}
}

View File

@@ -394,6 +394,7 @@ SettingsDialog::SettingsDialog(std::shared_ptr<gui_settings> gui_settings,
// Input
ui->hideCursorGroupBox->installEventFilter(this);
ui->idleTimeoutGroupBox->installEventFilter(this);
ui->backgroundControllerCheckBox->installEventFilter(this);
// Graphics
ui->graphicsAdapterGroupBox->installEventFilter(this);
@@ -581,6 +582,8 @@ void SettingsDialog::LoadValuesFromConfig() {
ui->motionControlsCheckBox->setChecked(
toml::find_or<bool>(data, "Input", "isMotionControlsEnabled", true));
ui->backgroundControllerCheckBox->setChecked(
toml::find_or<bool>(data, "Input", "backgroundControllerInput", false));
ui->removeFolderButton->setEnabled(!ui->gameFoldersListWidget->selectedItems().isEmpty());
SyncRealTimeWidgetstoConfig();
@@ -712,6 +715,8 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
text = tr("Hide Cursor:\\nChoose when the cursor will disappear:\\nNever: You will always see the mouse.\\nidle: Set a time for it to disappear after being idle.\\nAlways: you will never see the mouse.");
} else if (elementName == "idleTimeoutGroupBox") {
text = tr("Hide Idle Cursor Timeout:\\nThe duration (seconds) after which the cursor that has been idle hides itself.");
} else if (elementName == "backgroundControllerCheckBox") {
text = tr("Enable Controller Background Input:\\nAllow shadPS4 to detect controller inputs when the game window is not in focus.");
}
// Graphics
@@ -797,6 +802,7 @@ void SettingsDialog::UpdateSettings() {
Config::setFullscreenMode(
screenModeMap.value(ui->displayModeComboBox->currentText()).toStdString());
Config::setIsMotionControlsEnabled(ui->motionControlsCheckBox->isChecked());
Config::setBackgroundControllerInput(ui->backgroundControllerCheckBox->isChecked());
Config::setisTrophyPopupDisabled(ui->disableTrophycheckBox->isChecked());
Config::setTrophyNotificationDuration(ui->popUpDurationSpinBox->value());

View File

@@ -74,7 +74,7 @@
<x>0</x>
<y>0</y>
<width>946</width>
<height>540</height>
<height>536</height>
</rect>
</property>
<layout class="QVBoxLayout" name="generalTabVLayout" stretch="0">
@@ -369,7 +369,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>375</width>
<width>400</width>
<height>68</height>
</rect>
</property>
@@ -539,7 +539,7 @@
<x>0</x>
<y>0</y>
<width>946</width>
<height>540</height>
<height>536</height>
</rect>
</property>
<layout class="QVBoxLayout" name="guiTabVLayout" stretch="0">
@@ -988,7 +988,7 @@
<x>0</x>
<y>0</y>
<width>946</width>
<height>540</height>
<height>536</height>
</rect>
</property>
<layout class="QVBoxLayout" name="graphicsTabVLayout" stretch="0,0">
@@ -1283,7 +1283,7 @@
<x>0</x>
<y>0</y>
<width>946</width>
<height>540</height>
<height>536</height>
</rect>
</property>
<layout class="QVBoxLayout" name="userTabVLayout" stretch="0,0,1">
@@ -1525,7 +1525,7 @@
<x>0</x>
<y>0</y>
<width>946</width>
<height>540</height>
<height>536</height>
</rect>
</property>
<layout class="QVBoxLayout" name="inputTabVLayout" stretch="0,0">
@@ -1726,6 +1726,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="backgroundControllerCheckBox">
<property name="text">
<string>Enable Background Controller Input</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -1790,7 +1797,7 @@
<x>0</x>
<y>0</y>
<width>946</width>
<height>540</height>
<height>536</height>
</rect>
</property>
<layout class="QVBoxLayout" name="pathsTabLayout">
@@ -1932,7 +1939,7 @@
<x>0</x>
<y>0</y>
<width>946</width>
<height>540</height>
<height>536</height>
</rect>
</property>
<layout class="QVBoxLayout" name="debugTabVLayout" stretch="0,0">