summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/InputConfig.cpp
diff options
context:
space:
mode:
authorspycrab <spycrab@users.noreply.github.com>2018-07-12 20:36:53 +0200
committerGitHub <noreply@github.com>2018-07-12 20:36:53 +0200
commitcc6526f5535e253f72589d1a63968a4696d47892 (patch)
tree317de9d8facb3d4974df0cf8e3c3863800ad8f8e /Source/Core/InputCommon/InputConfig.cpp
parent303f5e0dc2ff62064571b53020e69c625a50186d (diff)
parentbce8041cce88926adf68c7b35b4e79d72420bb36 (diff)
Merge pull request #6222 from iwubcode/emulated_input_improvements
Emulated wii input improvements
Diffstat (limited to 'Source/Core/InputCommon/InputConfig.cpp')
-rw-r--r--Source/Core/InputCommon/InputConfig.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/Source/Core/InputCommon/InputConfig.cpp b/Source/Core/InputCommon/InputConfig.cpp
index 2a5766fbbe..ac74c0ea7e 100644
--- a/Source/Core/InputCommon/InputConfig.cpp
+++ b/Source/Core/InputCommon/InputConfig.cpp
@@ -7,12 +7,15 @@
#include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Common/MsgHandler.h"
+#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
+#include "Core/Core.h"
#include "Core/HW/Wiimote.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/InputConfig.h"
+#include "InputCommon/InputProfile.h"
InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name,
const std::string& profile_name)
@@ -51,17 +54,24 @@ bool InputConfig::LoadConfig(bool isGC)
{
if (control_section->Exists(type + "Profile" + num[i]))
{
- if (control_section->Get(type + "Profile" + num[i], &profile[i]))
+ std::string profile_setting;
+ if (control_section->Get(type + "Profile" + num[i], &profile_setting))
{
- if (File::Exists(File::GetUserPath(D_CONFIG_IDX) + path + profile[i] + ".ini"))
- {
- useProfile[i] = true;
- }
- else
+ auto profiles = InputProfile::GetProfilesFromSetting(
+ profile_setting, File::GetUserPath(D_CONFIG_IDX) + path);
+
+ if (profiles.empty())
{
+ const std::string error =
+ "No profiles found for game setting '" + profile_setting + "'";
// TODO: PanicAlert shouldn't be used for this.
- PanicAlertT("Selected controller profile does not exist");
+ PanicAlertT("%s", error.c_str());
+ continue;
}
+
+ // Use the first profile by default
+ profile[i] = profiles[0];
+ useProfile[i] = true;
}
}
}
@@ -75,8 +85,14 @@ bool InputConfig::LoadConfig(bool isGC)
// Load settings from ini
if (useProfile[n])
{
+ std::string base;
+ SplitPath(profile[n], nullptr, &base, nullptr);
+ Core::DisplayMessage("Loading game specific input profile '" + base + "' for device '" +
+ controller->GetName() + "'",
+ 6000);
+
IniFile profile_ini;
- profile_ini.Load(File::GetUserPath(D_CONFIG_IDX) + path + profile[n] + ".ini");
+ profile_ini.Load(profile[n]);
controller->LoadConfig(profile_ini.GetOrCreateSection("Profile"));
}
else
@@ -128,6 +144,11 @@ bool InputConfig::ControllersNeedToBeCreated() const
return m_controllers.empty();
}
+std::size_t InputConfig::GetControllerCount() const
+{
+ return m_controllers.size();
+}
+
bool InputConfig::IsControllerControlledByGamepadDevice(int index) const
{
if (static_cast<size_t>(index) >= m_controllers.size())