diff --git a/rpcs3/rpcs3qt/gui_settings.h b/rpcs3/rpcs3qt/gui_settings.h index 7b559deb31..27b3c573e7 100644 --- a/rpcs3/rpcs3qt/gui_settings.h +++ b/rpcs3/rpcs3qt/gui_settings.h @@ -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", ""); diff --git a/rpcs3/rpcs3qt/pad_settings_dialog.cpp b/rpcs3/rpcs3qt/pad_settings_dialog.cpp index 46c274f1c4..3a840a711c 100644 --- a/rpcs3/rpcs3qt/pad_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/pad_settings_dialog.cpp @@ -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 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 %1 of Player %2 was assigned at least twice.
Please consider adjusting the configuration.

Continue anyway?
") + .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()) diff --git a/rpcs3/rpcs3qt/pad_settings_dialog.h b/rpcs3/rpcs3qt/pad_settings_dialog.h index 74b38d5206..14e8d41872 100644 --- a/rpcs3/rpcs3qt/pad_settings_dialog.h +++ b/rpcs3/rpcs3qt/pad_settings_dialog.h @@ -128,6 +128,7 @@ private: QButtonGroup* m_pad_buttons = nullptr; u32 m_button_id = id_pad_begin; std::map m_cfg_entries; + std::map m_duplicate_buttons; // Real time stick values int m_lx = 0; diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index 73ba11694a..6fca2baa0c 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -1539,6 +1539,7 @@ settings_dialog::settings_dialog(std::shared_ptr 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, 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, 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) { diff --git a/rpcs3/rpcs3qt/settings_dialog.ui b/rpcs3/rpcs3qt/settings_dialog.ui index 86176104fd..34f275c8b9 100644 --- a/rpcs3/rpcs3qt/settings_dialog.ui +++ b/rpcs3/rpcs3qt/settings_dialog.ui @@ -3395,6 +3395,13 @@ + + + + Show Duplicate Buttons Dialog + + + diff --git a/rpcs3/rpcs3qt/tooltips.h b/rpcs3/rpcs3qt/tooltips.h index a500482d8c..dc8b5a2787 100644 --- a/rpcs3/rpcs3qt/tooltips.h +++ b/rpcs3/rpcs3qt/tooltips.h @@ -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.");