mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 18:45:36 +00:00
If duplicate unique inputs found, show which buttons have duplicates
This commit is contained in:
parent
226058d2e9
commit
65227f8bb3
@ -372,14 +372,32 @@ void KBMSettings::SaveKBMConfig(bool CloseOnSave) {
|
||||
file.close();
|
||||
|
||||
// Prevent duplicate inputs for KBM as this breaks the engine
|
||||
bool duplicateFound = false;
|
||||
QSet<QString> duplicateInputs;
|
||||
for (auto it = inputs.begin(); it != inputs.end(); ++it) {
|
||||
if (std::find(it + 1, inputs.end(), *it) != inputs.end()) {
|
||||
QMessageBox::information(this, tr("Unable to Save"),
|
||||
tr("Cannot bind any unique input more than once"));
|
||||
return;
|
||||
duplicateFound = true;
|
||||
duplicateInputs.insert(QString::fromStdString(*it));
|
||||
}
|
||||
}
|
||||
|
||||
if (duplicateFound) {
|
||||
QStringList DuplicateButtons;
|
||||
for (QString i : duplicateInputs) {
|
||||
for (const auto& j : ButtonsList) {
|
||||
if (j->text() == i)
|
||||
DuplicateButtons.append(j->objectName() + " - " + i);
|
||||
}
|
||||
}
|
||||
QString DuplicateList = DuplicateButtons.join("\n");
|
||||
QMessageBox::information(
|
||||
this, tr("Unable to Save"),
|
||||
QString(tr("Cannot bind any unique input more than once. "
|
||||
"Duplicate inputs mapped to the following buttons:\n\n%1")
|
||||
.arg(DuplicateList)));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> save;
|
||||
bool CurrentLineEmpty = false, LastLineEmpty = false;
|
||||
for (auto const& line : lines) {
|
||||
|
Loading…
Reference in New Issue
Block a user