diff options
| author | Rachel Bryk <RachelBryk@gmail.com> | 2013-01-09 22:33:51 -0500 |
|---|---|---|
| committer | Rachel Bryk <RachelBryk@gmail.com> | 2013-01-09 22:33:51 -0500 |
| commit | f1489a4e1807ef293e0b01be6f6096b19055fe39 (patch) | |
| tree | 1f19bac44e4dc32fade254aa108a3ad33b266fe5 /Source/Core/InputCommon | |
| parent | a8a71fdd8c55eecf1b42b22828ba82f053fbbd3b (diff) | |
| parent | b9fc26540e8abd557a4b08dc951a10ca69f7a0d8 (diff) | |
Merge branch 'controller-profiles'
Diffstat (limited to 'Source/Core/InputCommon')
| -rw-r--r-- | Source/Core/InputCommon/Src/InputConfig.cpp | 47 | ||||
| -rw-r--r-- | Source/Core/InputCommon/Src/InputConfig.h | 2 |
2 files changed, 45 insertions, 4 deletions
diff --git a/Source/Core/InputCommon/Src/InputConfig.cpp b/Source/Core/InputCommon/Src/InputConfig.cpp index b9d2a93b99..1988a9ebb7 100644 --- a/Source/Core/InputCommon/Src/InputConfig.cpp +++ b/Source/Core/InputCommon/Src/InputConfig.cpp @@ -16,6 +16,7 @@ // http://code.google.com/p/dolphin-emu/ #include "InputConfig.h" +#include "../../Core/Src/ConfigManager.h" InputPlugin::~InputPlugin() { @@ -26,18 +27,58 @@ InputPlugin::~InputPlugin() delete *i; } -bool InputPlugin::LoadConfig() +bool InputPlugin::LoadConfig(bool isGC) { IniFile inifile; + IniFile game_ini; + bool useProfile[4] = {false, false, false, false}; + std::string num[4] = {"1", "2", "3", "4"}; + std::string profile[4]; + std::string path; + + if (SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() != "00000000") + { + std::string type; + if (isGC) + { + type = "Pad"; + path = "Profiles/GCPad/"; + } + else + { + type = "Wiimote"; + path = "Profiles/Wiimote/"; + } + game_ini.Load(File::GetUserPath(D_GAMECONFIG_IDX) + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + ".ini"); + for (int i = 0; i < 4; i++) + { + if (game_ini.Exists("Controls", (type + "Profile" + num[i]).c_str())) + { + game_ini.Get("Controls", (type + "Profile" + num[i]).c_str(), &profile[i]); + if (File::Exists(File::GetUserPath(D_CONFIG_IDX) + path + profile[i] + ".ini")) + useProfile[i] = true; + else + PanicAlertT("Selected controller profile does not exist"); + } + } + } + if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini")) { std::vector< ControllerEmu* >::const_iterator i = controllers.begin(), e = controllers.end(); - for (; i!=e; ++i) + for (int n = 0; i!=e; ++i, ++n) { // load settings from ini - (*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str())); + if (useProfile[n]) + { + IniFile profile_ini; + profile_ini.Load(File::GetUserPath(D_CONFIG_IDX) + path + profile[n] + ".ini"); + (*i)->LoadConfig(profile_ini.GetOrCreateSection("Profile")); + } + else + (*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str())); // update refs (*i)->UpdateReferences(g_controller_interface); } diff --git a/Source/Core/InputCommon/Src/InputConfig.h b/Source/Core/InputCommon/Src/InputConfig.h index 4d25334ce7..71505bb935 100644 --- a/Source/Core/InputCommon/Src/InputConfig.h +++ b/Source/Core/InputCommon/Src/InputConfig.h @@ -42,7 +42,7 @@ public: ~InputPlugin(); - bool LoadConfig(); + bool LoadConfig(bool isGC); void SaveConfig(); std::vector< ControllerEmu* > controllers; |
