From e32b1526b334950068cf5f1a7eb29ea6a873274c Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Wed, 9 Jan 2013 15:03:43 -0500 Subject: [PATCH] Allow setting different profiles for different controllers, and automatically use the appropriate profile directory. --- Source/Core/Core/Src/BootManager.cpp | 8 +--- Source/Core/Core/Src/CoreParameter.h | 2 - Source/Core/Core/Src/HW/GCPad.cpp | 2 +- Source/Core/Core/Src/HW/Wiimote.cpp | 2 +- Source/Core/InputCommon/Src/InputConfig.cpp | 51 ++++++++++++++++----- Source/Core/InputCommon/Src/InputConfig.h | 2 +- 6 files changed, 44 insertions(+), 23 deletions(-) diff --git a/Source/Core/Core/Src/BootManager.cpp b/Source/Core/Core/Src/BootManager.cpp index 113a12f761..71148efabc 100644 --- a/Source/Core/Core/Src/BootManager.cpp +++ b/Source/Core/Core/Src/BootManager.cpp @@ -136,11 +136,6 @@ bool BootCore(const std::string& _rFilename) } } - if (game_ini.Exists("Core", "WiiProfile")) - game_ini.Get("Core", "WiiProfile", &StartUp.strWiiControllerProfile); - if (game_ini.Exists("Core", "GCProfile")) - game_ini.Get("Core", "GCProfile", &StartUp.strGCControllerProfile); - // Run the game // Init the core if (!Core::Init()) @@ -158,6 +153,7 @@ void Stop() SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter; + StartUp.m_strUniqueID = "00000000"; if (config_cache.valid) { config_cache.valid = false; @@ -173,8 +169,6 @@ void Stop() StartUp.bDSPHLE = config_cache.bDSPHLE; StartUp.bDisableWiimoteSpeaker = config_cache.bDisableWiimoteSpeaker; StartUp.m_strVideoBackend = config_cache.strBackend; - StartUp.strGCControllerProfile = ""; - StartUp.strWiiControllerProfile = ""; VideoBackend::ActivateBackend(StartUp.m_strVideoBackend); } } diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index d5e7537354..8aa6be83e5 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -139,8 +139,6 @@ struct SCoreStartupParameter int iTheme; int iPosX, iPosY, iWidth, iHeight; - std::string strGCControllerProfile; - std::string strWiiControllerProfile; enum EBootBS2 { BOOT_DEFAULT, diff --git a/Source/Core/Core/Src/HW/GCPad.cpp b/Source/Core/Core/Src/HW/GCPad.cpp index 62090dfc4f..c4798b3964 100644 --- a/Source/Core/Core/Src/HW/GCPad.cpp +++ b/Source/Core/Core/Src/HW/GCPad.cpp @@ -56,7 +56,7 @@ void Initialize(void* const hwnd) g_controller_interface.Initialize(); // load the saved controller config - g_plugin.LoadConfig(SConfig::GetInstance().m_LocalCoreStartupParameter.strGCControllerProfile); + g_plugin.LoadConfig(true); } void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) diff --git a/Source/Core/Core/Src/HW/Wiimote.cpp b/Source/Core/Core/Src/HW/Wiimote.cpp index 4b95677581..59fe8b7fa5 100644 --- a/Source/Core/Core/Src/HW/Wiimote.cpp +++ b/Source/Core/Core/Src/HW/Wiimote.cpp @@ -45,7 +45,7 @@ void Initialize(void* const hwnd) g_controller_interface.SetHwnd(hwnd); g_controller_interface.Initialize(); - g_plugin.LoadConfig(SConfig::GetInstance().m_LocalCoreStartupParameter.strWiiControllerProfile); + g_plugin.LoadConfig(false); WiimoteReal::Initialize(); 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); } diff --git a/Source/Core/InputCommon/Src/InputConfig.h b/Source/Core/InputCommon/Src/InputConfig.h index bf12217304..71505bb935 100644 --- a/Source/Core/InputCommon/Src/InputConfig.h +++ b/Source/Core/InputCommon/Src/InputConfig.h @@ -42,7 +42,7 @@ public: ~InputPlugin(); - bool LoadConfig(std::string ini); + bool LoadConfig(bool isGC); void SaveConfig(); std::vector< ControllerEmu* > controllers;