From b8691df723ab635b3db41e86c9324b3adb952abe Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Tue, 8 Jan 2013 19:15:11 -0500 Subject: Allow loading controller profiles from game ini. Currently loads the same profile for all 4 controllers, and overwrites the default control settings. --- Source/Core/InputCommon/Src/InputConfig.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Source/Core/InputCommon/Src/InputConfig.cpp') diff --git a/Source/Core/InputCommon/Src/InputConfig.cpp b/Source/Core/InputCommon/Src/InputConfig.cpp index b9d2a93b99..19be23ec74 100644 --- a/Source/Core/InputCommon/Src/InputConfig.cpp +++ b/Source/Core/InputCommon/Src/InputConfig.cpp @@ -26,10 +26,13 @@ InputPlugin::~InputPlugin() delete *i; } -bool InputPlugin::LoadConfig() +bool InputPlugin::LoadConfig(std::string ini) { IniFile inifile; - if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini")) + std::string ini2 = ini; + if (ini == "") + ini = ini_name; + if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini + ".ini")) { std::vector< ControllerEmu* >::const_iterator i = controllers.begin(), @@ -37,7 +40,11 @@ bool InputPlugin::LoadConfig() for (; i!=e; ++i) { // load settings from ini - (*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str())); + std::string section; + section = (*i)->GetName(); + if (ini2 != "") + section = "Profile"; + (*i)->LoadConfig(inifile.GetOrCreateSection(section.c_str())); // update refs (*i)->UpdateReferences(g_controller_interface); } -- cgit v1.2.3 From e32b1526b334950068cf5f1a7eb29ea6a873274c Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Wed, 9 Jan 2013 15:03:43 -0500 Subject: Allow setting different profiles for different controllers, and automatically use the appropriate profile directory. --- Source/Core/InputCommon/Src/InputConfig.cpp | 51 ++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'Source/Core/InputCommon/Src/InputConfig.cpp') diff --git a/Source/Core/InputCommon/Src/InputConfig.cpp b/Source/Core/InputCommon/Src/InputConfig.cpp index 19be23ec74..7d1bf11de8 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,25 +27,53 @@ InputPlugin::~InputPlugin() delete *i; } -bool InputPlugin::LoadConfig(std::string ini) +bool InputPlugin::LoadConfig(bool isGC) { IniFile inifile; - std::string ini2 = ini; - if (ini == "") - ini = ini_name; - if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini + ".ini")) + IniFile game_ini; + bool useProfile[4] = {false, false, false, false}; + std::string num[4] = {"1", "2", "3", "4"}; + std::string profile[4]; + + if (SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() != "00000000") + { + std::string type; + if (isGC) + type = "GC"; + else + type = "Wii"; + 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("Core", (type + "Profile" + num[i]).c_str())) + { + useProfile[i] = true; + game_ini.Get("Core", (type + "Profile" + num[i]).c_str(), &profile[i]); + } + } + } + + 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 - std::string section; - section = (*i)->GetName(); - if (ini2 != "") - section = "Profile"; - (*i)->LoadConfig(inifile.GetOrCreateSection(section.c_str())); + if (useProfile[n]) + { + IniFile profile_ini; + std::string path; + if (isGC) + path = "Profiles/GCPad/"; + else + path = "Profiles/Wiimote/"; + 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); } -- cgit v1.2.3 From fad2468e3014334e1a050d0c60deb244b85923ff Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Wed, 9 Jan 2013 20:41:14 -0500 Subject: Make sure profile actually exists. --- Source/Core/InputCommon/Src/InputConfig.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Source/Core/InputCommon/Src/InputConfig.cpp') diff --git a/Source/Core/InputCommon/Src/InputConfig.cpp b/Source/Core/InputCommon/Src/InputConfig.cpp index 7d1bf11de8..a0b396db0a 100644 --- a/Source/Core/InputCommon/Src/InputConfig.cpp +++ b/Source/Core/InputCommon/Src/InputConfig.cpp @@ -34,21 +34,31 @@ bool InputPlugin::LoadConfig(bool isGC) 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 = "GC"; + path = "Profiles/GCPad/"; + } else + { type = "Wii"; + 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("Core", (type + "Profile" + num[i]).c_str())) { - useProfile[i] = true; game_ini.Get("Core", (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"); } } } @@ -64,11 +74,6 @@ bool InputPlugin::LoadConfig(bool isGC) if (useProfile[n]) { IniFile profile_ini; - std::string path; - if (isGC) - path = "Profiles/GCPad/"; - else - path = "Profiles/Wiimote/"; profile_ini.Load(File::GetUserPath(D_CONFIG_IDX) + path + profile[n] + ".ini"); (*i)->LoadConfig(profile_ini.GetOrCreateSection("Profile")); } -- cgit v1.2.3 From b9fc26540e8abd557a4b08dc951a10ca69f7a0d8 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Wed, 9 Jan 2013 21:56:17 -0500 Subject: Change key names, and put it in section Controls. --- Source/Core/InputCommon/Src/InputConfig.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Source/Core/InputCommon/Src/InputConfig.cpp') diff --git a/Source/Core/InputCommon/Src/InputConfig.cpp b/Source/Core/InputCommon/Src/InputConfig.cpp index a0b396db0a..1988a9ebb7 100644 --- a/Source/Core/InputCommon/Src/InputConfig.cpp +++ b/Source/Core/InputCommon/Src/InputConfig.cpp @@ -41,20 +41,20 @@ bool InputPlugin::LoadConfig(bool isGC) std::string type; if (isGC) { - type = "GC"; + type = "Pad"; path = "Profiles/GCPad/"; } else { - type = "Wii"; + 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("Core", (type + "Profile" + num[i]).c_str())) + if (game_ini.Exists("Controls", (type + "Profile" + num[i]).c_str())) { - game_ini.Get("Core", (type + "Profile" + num[i]).c_str(), &profile[i]); + 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 -- cgit v1.2.3