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

@ -121,7 +121,7 @@ bool Entry::LoadFromStream(ByteStream* stream)
!ReadOptionalFromStream(stream, &controller_2_type) || !ReadOptionalFromStream(stream, &memory_card_1_type) ||
!ReadOptionalFromStream(stream, &memory_card_2_type) ||
!ReadStringFromStream(stream, &memory_card_1_shared_path) ||
!ReadStringFromStream(stream, &memory_card_2_shared_path))
!ReadStringFromStream(stream, &memory_card_2_shared_path) || !ReadStringFromStream(stream, &input_profile_name))
{
return false;
}
@ -162,7 +162,7 @@ bool Entry::SaveToStream(ByteStream* stream) const
WriteOptionalToStream(stream, gpu_pgxp) && WriteOptionalToStream(stream, controller_1_type) &&
WriteOptionalToStream(stream, controller_2_type) && WriteOptionalToStream(stream, memory_card_1_type) &&
WriteOptionalToStream(stream, memory_card_2_type) && WriteStringToStream(stream, memory_card_1_shared_path) &&
WriteStringToStream(stream, memory_card_2_shared_path);
WriteStringToStream(stream, memory_card_2_shared_path) && WriteStringToStream(stream, input_profile_name);
}
static void ParseIniSection(Entry* entry, const char* section, const CSimpleIniA& ini)
@ -247,6 +247,9 @@ static void ParseIniSection(Entry* entry, const char* section, const CSimpleIniA
cvalue = ini.GetValue(section, "MemoryCard2SharedPath");
if (cvalue)
entry->memory_card_2_shared_path = cvalue;
cvalue = ini.GetValue(section, "InputProfileName");
if (cvalue)
entry->input_profile_name = cvalue;
}
static void StoreIniSection(const Entry& entry, const char* section, CSimpleIniA& ini)
@ -316,6 +319,8 @@ static void StoreIniSection(const Entry& entry, const char* section, CSimpleIniA
ini.SetValue(section, "MemoryCard1SharedPath", entry.memory_card_1_shared_path.c_str());
if (!entry.memory_card_2_shared_path.empty())
ini.SetValue(section, "MemoryCard2SharedPath", entry.memory_card_2_shared_path.c_str());
if (!entry.input_profile_name.empty())
ini.SetValue(section, "InputProfileName", entry.input_profile_name.c_str());
}
Database::Database() = default;