mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 12:05:23 +00:00
pad settings: Check duplicate button assignment
This commit is contained in:
parent
28b9f4238a
commit
5aee8a8a81
6 changed files with 68 additions and 8 deletions
|
@ -128,6 +128,7 @@ namespace gui
|
|||
const gui_save ib_confirm_exit = gui_save(main_window, "confirmationBoxExitGame", true);
|
||||
const gui_save ib_confirm_boot = gui_save(main_window, "confirmationBoxBootGame", true);
|
||||
const gui_save ib_obsolete_cfg = gui_save(main_window, "confirmationObsoleteCfg", true);
|
||||
const gui_save ib_same_buttons = gui_save(main_window, "confirmationSameButtons", true);
|
||||
|
||||
const gui_save fd_install_pkg = gui_save(main_window, "lastExplorePathPKG", "");
|
||||
const gui_save fd_install_pup = gui_save(main_window, "lastExplorePathPUP", "");
|
||||
|
|
|
@ -1525,13 +1525,48 @@ void pad_settings_dialog::ApplyCurrentPlayerConfig(int new_player_id)
|
|||
return;
|
||||
}
|
||||
|
||||
m_duplicate_buttons[m_last_player_id] = "";
|
||||
|
||||
auto& player = g_cfg_input.player[m_last_player_id];
|
||||
m_last_player_id = new_player_id;
|
||||
|
||||
// Check for invalid selection
|
||||
if (!ui->chooseDevice->isEnabled() || ui->chooseDevice->currentIndex() < 0)
|
||||
{
|
||||
const u32 played_id = GetPlayerIndex();
|
||||
g_cfg_input.player[played_id]->handler.from_default();
|
||||
g_cfg_input.player[played_id]->device.from_default();
|
||||
g_cfg_input.player[played_id]->config.from_default();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for duplicate button choices
|
||||
if (m_handler->m_type != pad_handler::null)
|
||||
{
|
||||
std::set<std::string> unique_keys;
|
||||
for (const auto& entry : m_cfg_entries)
|
||||
{
|
||||
// Let's ignore special keys, unless we're using a keyboard
|
||||
if (entry.first == button_ids::id_pressure_intensity && m_handler->m_type != pad_handler::keyboard)
|
||||
continue;
|
||||
|
||||
if (const auto& [it, ok] = unique_keys.insert(entry.second.key); !ok)
|
||||
{
|
||||
m_duplicate_buttons[m_last_player_id] = entry.second.key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply buttons
|
||||
for (const auto& entry : m_cfg_entries)
|
||||
{
|
||||
entry.second.cfg_text->from_string(entry.second.key);
|
||||
}
|
||||
|
||||
auto& cfg = g_cfg_input.player[m_last_player_id]->config;
|
||||
m_last_player_id = new_player_id;
|
||||
// Apply rest of config
|
||||
auto& cfg = player->config;
|
||||
|
||||
cfg.lstickmultiplier.set(ui->stick_multi_left->value() * 100);
|
||||
cfg.rstickmultiplier.set(ui->stick_multi_right->value() * 100);
|
||||
|
@ -1580,13 +1615,22 @@ void pad_settings_dialog::SaveExit()
|
|||
{
|
||||
ApplyCurrentPlayerConfig(m_last_player_id);
|
||||
|
||||
// Check for invalid selection
|
||||
if (!ui->chooseDevice->isEnabled() || ui->chooseDevice->currentIndex() < 0)
|
||||
for (const auto& [player_id, key] : m_duplicate_buttons)
|
||||
{
|
||||
const u32 played_id = GetPlayerIndex();
|
||||
g_cfg_input.player[played_id]->handler.from_default();
|
||||
g_cfg_input.player[played_id]->device.from_default();
|
||||
g_cfg_input.player[played_id]->config.from_default();
|
||||
if (!key.empty())
|
||||
{
|
||||
int result = QMessageBox::Yes;
|
||||
m_gui_settings->ShowConfirmationBox(
|
||||
tr("Warning!"),
|
||||
tr("The %0 button <b>%1</b> of <b>Player %2</b> was assigned at least twice.<br>Please consider adjusting the configuration.<br><br>Continue anyway?<br>")
|
||||
.arg(qstr(g_cfg_input.player[player_id]->handler.to_string())).arg(qstr(key)).arg(player_id + 1),
|
||||
gui::ib_same_buttons, &result, this);
|
||||
|
||||
if (result == QMessageBox::No)
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_title_id.empty())
|
||||
|
|
|
@ -128,6 +128,7 @@ private:
|
|||
QButtonGroup* m_pad_buttons = nullptr;
|
||||
u32 m_button_id = id_pad_begin;
|
||||
std::map<int /*id*/, pad_button /*info*/> m_cfg_entries;
|
||||
std::map<int /*id*/, std::string> m_duplicate_buttons;
|
||||
|
||||
// Real time stick values
|
||||
int m_lx = 0;
|
||||
|
|
|
@ -1539,6 +1539,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
|
|||
SubscribeTooltip(ui->cb_show_pkg_install, tooltips.settings.show_pkg_install);
|
||||
SubscribeTooltip(ui->cb_show_pup_install, tooltips.settings.show_pup_install);
|
||||
SubscribeTooltip(ui->cb_show_obsolete_cfg_dialog, tooltips.settings.show_obsolete_cfg);
|
||||
SubscribeTooltip(ui->cb_show_same_buttons_dialog, tooltips.settings.show_same_buttons);
|
||||
SubscribeTooltip(ui->gb_updates, tooltips.settings.check_update_start);
|
||||
|
||||
// Discord:
|
||||
|
@ -1612,6 +1613,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
|
|||
ui->cb_show_pkg_install->setChecked(m_gui_settings->GetValue(gui::ib_pkg_success).toBool());
|
||||
ui->cb_show_pup_install->setChecked(m_gui_settings->GetValue(gui::ib_pup_success).toBool());
|
||||
ui->cb_show_obsolete_cfg_dialog->setChecked(m_gui_settings->GetValue(gui::ib_obsolete_cfg).toBool());
|
||||
ui->cb_show_same_buttons_dialog->setChecked(m_gui_settings->GetValue(gui::ib_same_buttons).toBool());
|
||||
|
||||
ui->combo_updates->addItem(tr("Yes", "Updates"), gui::update_on);
|
||||
ui->combo_updates->addItem(tr("Background", "Updates"), gui::update_bkg);
|
||||
|
@ -1655,6 +1657,10 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
|
|||
{
|
||||
m_gui_settings->SetValue(gui::ib_obsolete_cfg, val);
|
||||
});
|
||||
connect(ui->cb_show_same_buttons_dialog, &QCheckBox::clicked, [this](bool val)
|
||||
{
|
||||
m_gui_settings->SetValue(gui::ib_same_buttons, val);
|
||||
});
|
||||
|
||||
connect(ui->cb_custom_colors, &QCheckBox::clicked, [this](bool val)
|
||||
{
|
||||
|
|
|
@ -3395,6 +3395,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_show_same_buttons_dialog">
|
||||
<property name="text">
|
||||
<string>Show Duplicate Buttons Dialog</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="guiTabSpacerRight">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -181,6 +181,7 @@ public:
|
|||
const QString show_pkg_install = tr("Shows a dialog when packages were installed successfully.");
|
||||
const QString show_pup_install = tr("Shows a dialog when firmware was installed successfully.");
|
||||
const QString show_obsolete_cfg = tr("Shows a dialog when obsolete settings were found.");
|
||||
const QString show_same_buttons = tr("Shows a dialog in the game pad configuration when the same button was assigned twice.");
|
||||
const QString check_update_start = tr("Checks if an update is available on startup and asks if you want to update.\nIf \"Automatic\" is selected, the update will run automatically without user confirmation.\nIf \"Background\" is selected, the check is done silently in the background and a new download option is shown in the top right corner of the menu if a new version was found.");
|
||||
const QString use_rich_presence = tr("Enables use of Discord Rich Presence to show what game you are playing on Discord.\nRequires a restart of RPCS3 to completely close the connection.");
|
||||
const QString discord_state = tr("Tell your friends what you are doing.");
|
||||
|
|
Loading…
Add table
Reference in a new issue