Merge branch 'controller-profiles'

This commit is contained in:
Rachel Bryk 2013-01-09 22:33:51 -05:00
commit f1489a4e18
6 changed files with 51 additions and 8 deletions

View File

@ -47,7 +47,6 @@
#include "VideoBackendBase.h" #include "VideoBackendBase.h"
#include "Movie.h" #include "Movie.h"
namespace BootManager namespace BootManager
{ {
@ -154,6 +153,7 @@ void Stop()
SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter; SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
StartUp.m_strUniqueID = "00000000";
if (config_cache.valid) if (config_cache.valid)
{ {
config_cache.valid = false; config_cache.valid = false;

View File

@ -138,7 +138,7 @@ struct SCoreStartupParameter
int iTheme; int iTheme;
int iPosX, iPosY, iWidth, iHeight; int iPosX, iPosY, iWidth, iHeight;
enum EBootBS2 enum EBootBS2
{ {
BOOT_DEFAULT, BOOT_DEFAULT,

View File

@ -20,6 +20,7 @@
#include "ControllerInterface/ControllerInterface.h" #include "ControllerInterface/ControllerInterface.h"
#include "GCPadEmu.h" #include "GCPadEmu.h"
#include "../ConfigManager.h"
#include "../../InputCommon/Src/InputConfig.h" #include "../../InputCommon/Src/InputConfig.h"
@ -55,7 +56,7 @@ void Initialize(void* const hwnd)
g_controller_interface.Initialize(); g_controller_interface.Initialize();
// load the saved controller config // load the saved controller config
g_plugin.LoadConfig(); g_plugin.LoadConfig(true);
} }
void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)

View File

@ -5,6 +5,7 @@
#include "WiimoteReal/WiimoteReal.h" #include "WiimoteReal/WiimoteReal.h"
#include "WiimoteEmu/WiimoteEmu.h" #include "WiimoteEmu/WiimoteEmu.h"
#include "Movie.h" #include "Movie.h"
#include "../ConfigManager.h"
#include "ControllerInterface/ControllerInterface.h" #include "ControllerInterface/ControllerInterface.h"
@ -44,7 +45,7 @@ void Initialize(void* const hwnd)
g_controller_interface.SetHwnd(hwnd); g_controller_interface.SetHwnd(hwnd);
g_controller_interface.Initialize(); g_controller_interface.Initialize();
g_plugin.LoadConfig(); g_plugin.LoadConfig(false);
WiimoteReal::Initialize(); WiimoteReal::Initialize();

View File

@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "InputConfig.h" #include "InputConfig.h"
#include "../../Core/Src/ConfigManager.h"
InputPlugin::~InputPlugin() InputPlugin::~InputPlugin()
{ {
@ -26,18 +27,58 @@ InputPlugin::~InputPlugin()
delete *i; delete *i;
} }
bool InputPlugin::LoadConfig() bool InputPlugin::LoadConfig(bool isGC)
{ {
IniFile inifile; 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")) if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini"))
{ {
std::vector< ControllerEmu* >::const_iterator std::vector< ControllerEmu* >::const_iterator
i = controllers.begin(), i = controllers.begin(),
e = controllers.end(); e = controllers.end();
for (; i!=e; ++i) for (int n = 0; i!=e; ++i, ++n)
{ {
// load settings from ini // 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 // update refs
(*i)->UpdateReferences(g_controller_interface); (*i)->UpdateReferences(g_controller_interface);
} }

View File

@ -42,7 +42,7 @@ public:
~InputPlugin(); ~InputPlugin();
bool LoadConfig(); bool LoadConfig(bool isGC);
void SaveConfig(); void SaveConfig();
std::vector< ControllerEmu* > controllers; std::vector< ControllerEmu* > controllers;