Add remove default button

This commit is contained in:
rainmakerv3 2025-06-29 08:43:00 +08:00
parent f4c096ea4e
commit 22b9d04fb5
2 changed files with 41 additions and 12 deletions

View file

@ -122,9 +122,9 @@ ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, b
[this]() { CheckMapping(MappingButton); });
connect(this, &ControlSettings::AxisChanged, this,
[this]() { ConnectAxisInputs(MappingButton); });
connect(ui->ActiveGamepadBox, &QComboBox::currentIndexChanged, this,
&ControlSettings::ActiveControllerChanged);
connect(ui->DefaultGamepadButton, &QPushButton::clicked, this, [this]() {
char pszGUID[33];
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[ui->ActiveGamepadBox->currentIndex()]),
@ -138,6 +138,18 @@ ControlSettings::ControlSettings(std::shared_ptr<GameInfoClass> game_info_get, b
tr("Active controller set as default"));
});
connect(ui->RemoveDefaultGamepadButton, &QPushButton::clicked, this, [this]() {
char pszGUID[33];
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepads[ui->ActiveGamepadBox->currentIndex()]),
pszGUID, 33);
ui->DefaultGamepadName->setText("No default selected");
ui->DefaultGamepadLabel->setText("n/a");
Config::setDefaultControllerID("");
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
QMessageBox::information(this, tr("Default Controller Removed"),
tr("No default controller currently selected"));
});
RemapWrapper = SdlEventWrapper::Wrapper::GetInstance();
SdlEventWrapper::Wrapper::wrapperActive = true;
QObject::connect(RemapWrapper, &SdlEventWrapper::Wrapper::SDLEvent, this,

View file

@ -746,17 +746,34 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="DefaultGamepadButton">
<property name="font">
<font>
<pointsize>9</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Set Active Gamepad as Default</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QPushButton" name="DefaultGamepadButton">
<property name="font">
<font>
<pointsize>9</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Set Active Gamepad as Default</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="RemoveDefaultGamepadButton">
<property name="font">
<font>
<pointsize>9</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Remove Default Gamepad</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>