1
0
Fork 0

citra_qt: configure_input.cpp: update the modifier settings for both the sticks (#6033)

The Controller config UI exposes the Circle mod, only for the Circle pad's modifier, So after changing the binding, it leaves the default binding for the c-stick untouched, and the user is nagged about the (default) D key being bound to something, when trying to bind it to any other button.

With this PR we update the modifier for both the Circle Pad and C-stick.
This commit is contained in:
SachinVin 2022-06-11 11:53:27 +05:30 committed by GitHub
parent 3f16cd9c82
commit 88a4759702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 57 additions and 3 deletions

View File

@ -27,6 +27,14 @@ const std::array<std::string, ConfigureInput::ANALOG_SUB_BUTTONS_NUM>
"modifier",
}};
enum class AnalogSubButtons {
up,
down,
left,
right,
modifier,
};
static QString GetKeyName(int key_code) {
switch (key_code) {
case Qt::Key_Shift:
@ -163,7 +171,7 @@ ConfigureInput::ConfigureInput(QWidget* parent)
ui->buttonCircleDown,
ui->buttonCircleLeft,
ui->buttonCircleRight,
ui->buttonCircleMod,
nullptr,
},
{
ui->buttonCStickUp,
@ -289,6 +297,50 @@ ConfigureInput::ConfigureInput(QWidget* parent)
});
}
// The Circle Mod button is common for both the sticks, so update the modifier settings
// for both the sticks.
connect(ui->buttonCircleMod, &QPushButton::clicked, [=]() {
HandleClick(
ui->buttonCircleMod,
[=](const Common::ParamPackage& params) {
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs;
analog_id++) {
SetAnalogButton(params, analogs_param[analog_id], "modifier");
}
ApplyConfiguration();
Settings::SaveProfile(ui->profile->currentIndex());
},
InputCommon::Polling::DeviceType::Button);
});
connect(ui->buttonCircleMod, &QPushButton::customContextMenuRequested,
[&](const QPoint& menu_location) {
QMenu context_menu;
context_menu.addAction(tr("Clear"), [&] {
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs;
analog_id++) {
analogs_param[analog_id].Erase("modifier");
}
ui->buttonCircleMod->setText(tr("[not set]"));
ApplyConfiguration();
Settings::SaveProfile(ui->profile->currentIndex());
});
context_menu.addAction(tr("Restore Default"), [&] {
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs;
analog_id++) {
Common::ParamPackage params{InputCommon::GenerateKeyboardParam(
Config::default_analogs[analog_id]
[static_cast<u32>(AnalogSubButtons::modifier)])};
SetAnalogButton(params, analogs_param[analog_id], "modifier");
ui->buttonCircleMod->setText(
AnalogToText(analogs_param[analog_id], "modifier"));
}
ApplyConfiguration();
Settings::SaveProfile(ui->profile->currentIndex());
});
context_menu.exec(ui->buttonCircleMod->mapToGlobal(menu_location));
});
connect(ui->buttonMotionTouch, &QPushButton::clicked, [this] {
QDialog* motion_touch_dialog = new ConfigureMotionTouch(this);
return motion_touch_dialog->exec();
@ -363,14 +415,14 @@ QList<QKeySequence> ConfigureInput::GetUsedKeyboardKeys() {
continue;
}
auto button_param = buttons_param[button];
const auto& button_param = buttons_param[button];
if (button_param.Get("engine", "") == "keyboard") {
list << QKeySequence(button_param.Get("code", 0));
}
}
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; ++analog_id) {
auto analog_param = analogs_param[analog_id];
const auto& analog_param = analogs_param[analog_id];
if (analog_param.Get("engine", "") == "analog_from_button") {
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; ++sub_button_id) {
const Common::ParamPackage sub_button{
@ -467,6 +519,8 @@ void ConfigureInput::UpdateButtonLabels() {
}
}
ui->buttonCircleMod->setText(AnalogToText(analogs_param[0], "modifier"));
EmitInputKeysChanged();
}