GameSettings: Add per-game input bindings from profiles

This just affects the **bindings**. You will still have to set the
controller type per game if this is different from the global default.
This commit is contained in:
Connor McLaughlin
2020-10-04 18:20:18 +10:00
parent 7278f055cb
commit 0b858658ca
7 changed files with 92 additions and 4 deletions

View File

@ -154,6 +154,9 @@ void GamePropertiesDialog::setupAdditionalUi()
m_ui.userControllerType2->addItem(
qApp->translate("ControllerType", Settings::GetControllerTypeDisplayName(static_cast<ControllerType>(i))));
}
m_ui.userInputProfile->addItem(tr("(unchanged)"));
for (const auto& it : m_host_interface->getInputProfileList())
m_ui.userInputProfile->addItem(QString::fromStdString(it.name));
m_ui.userMemoryCard1Type->addItem(tr("(unchanged)"));
for (u32 i = 0; i < static_cast<u32>(MemoryCardType::Count); i++)
@ -331,6 +334,18 @@ void GamePropertiesDialog::populateGameSettings()
QSignalBlocker sb(m_ui.userControllerType2);
m_ui.userControllerType2->setCurrentIndex(static_cast<int>(gs.controller_2_type.value()) + 1);
}
if (!gs.input_profile_name.empty())
{
QSignalBlocker sb(m_ui.userInputProfile);
int index = m_ui.userInputProfile->findText(QString::fromStdString(gs.input_profile_name));
if (index < 0)
{
index = m_ui.userInputProfile->count();
m_ui.userInputProfile->addItem(QString::fromStdString(gs.input_profile_name));
}
m_ui.userInputProfile->setCurrentIndex(index);
}
if (gs.memory_card_1_type.has_value())
{
@ -478,6 +493,14 @@ void GamePropertiesDialog::connectUi()
saveGameSettings();
});
connect(m_ui.userInputProfile, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
if (index <= 0)
m_game_settings.input_profile_name = {};
else
m_game_settings.input_profile_name = m_ui.userInputProfile->itemText(index).toStdString();
saveGameSettings();
});
connect(m_ui.userMemoryCard1Type, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {
if (index <= 0)
m_game_settings.memory_card_1_type.reset();

View File

@ -447,6 +447,16 @@
<item row="1" column="1">
<widget class="QComboBox" name="userControllerType2"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Input Profile For Bindings:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="userInputProfile"/>
</item>
</layout>
</widget>
</item>