diff options
| author | Lioncash <mathew1800@gmail.com> | 2015-10-25 22:28:15 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2015-11-19 02:41:33 -0500 |
| commit | b9975694ab133e964e84ae829e9ae93cca863cc4 (patch) | |
| tree | efe360c37c96b88a05db5de26099f706a62b72b8 /Source/Core/InputCommon/InputConfig.cpp | |
| parent | 59b54a77d33f2a59fabfc4d5a7643538d9b81327 (diff) | |
InputConfig: Clean up controller management
Diffstat (limited to 'Source/Core/InputCommon/InputConfig.cpp')
| -rw-r--r-- | Source/Core/InputCommon/InputConfig.cpp | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/Source/Core/InputCommon/InputConfig.cpp b/Source/Core/InputCommon/InputConfig.cpp index 6456e1e68f..f4a5900b96 100644 --- a/Source/Core/InputCommon/InputConfig.cpp +++ b/Source/Core/InputCommon/InputConfig.cpp @@ -2,10 +2,15 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Common/CommonPaths.h" +#include <vector> + +#include "Common/FileUtil.h" +#include "Common/IniFile.h" #include "Core/ConfigManager.h" #include "Core/HW/Wiimote.h" +#include "InputCommon/ControllerEmu.h" #include "InputCommon/InputConfig.h" +#include "InputCommon/ControllerInterface/ControllerInterface.h" bool InputConfig::LoadConfig(bool isGC) { @@ -52,25 +57,25 @@ bool InputConfig::LoadConfig(bool isGC) } } - if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini")) + if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + m_ini_name + ".ini")) { int n = 0; - for (ControllerEmu* pad : controllers) + for (auto& controller : m_controllers) { // Load settings from ini if (useProfile[n]) { IniFile profile_ini; profile_ini.Load(File::GetUserPath(D_CONFIG_IDX) + path + profile[n] + ".ini"); - pad->LoadConfig(profile_ini.GetOrCreateSection("Profile")); + controller->LoadConfig(profile_ini.GetOrCreateSection("Profile")); } else { - pad->LoadConfig(inifile.GetOrCreateSection(pad->GetName())); + controller->LoadConfig(inifile.GetOrCreateSection(controller->GetName())); } // Update refs - pad->UpdateReferences(g_controller_interface); + controller->UpdateReferences(g_controller_interface); // Next profile n++; @@ -79,21 +84,36 @@ bool InputConfig::LoadConfig(bool isGC) } else { - controllers[0]->LoadDefaults(g_controller_interface); - controllers[0]->UpdateReferences(g_controller_interface); + m_controllers[0]->LoadDefaults(g_controller_interface); + m_controllers[0]->UpdateReferences(g_controller_interface); return false; } } void InputConfig::SaveConfig() { - std::string ini_filename = File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini"; + std::string ini_filename = File::GetUserPath(D_CONFIG_IDX) + m_ini_name + ".ini"; IniFile inifile; inifile.Load(ini_filename); - for (ControllerEmu* pad : controllers) - pad->SaveConfig(inifile.GetOrCreateSection(pad->GetName())); + for (auto& controller : m_controllers) + controller->SaveConfig(inifile.GetOrCreateSection(controller->GetName())); inifile.Save(ini_filename); } + +ControllerEmu* InputConfig::GetController(int index) +{ + return m_controllers.at(index).get(); +} + +void InputConfig::ClearControllers() +{ + m_controllers.clear(); +} + +bool InputConfig::ControllersNeedToBeCreated() const +{ + return m_controllers.empty(); +} |
