Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'controller-profiles'
  • Loading branch information
RachelBryk committed Jan 10, 2013
2 parents a8a71fd + b9fc265 commit f1489a4
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/BootManager.cpp
Expand Up @@ -47,7 +47,6 @@
#include "VideoBackendBase.h"
#include "Movie.h"


namespace BootManager
{

Expand Down Expand Up @@ -154,6 +153,7 @@ void Stop()

SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;

StartUp.m_strUniqueID = "00000000";
if (config_cache.valid)
{
config_cache.valid = false;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/CoreParameter.h
Expand Up @@ -138,7 +138,7 @@ struct SCoreStartupParameter

int iTheme;
int iPosX, iPosY, iWidth, iHeight;

enum EBootBS2
{
BOOT_DEFAULT,
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/Src/HW/GCPad.cpp
Expand Up @@ -20,6 +20,7 @@

#include "ControllerInterface/ControllerInterface.h"
#include "GCPadEmu.h"
#include "../ConfigManager.h"

#include "../../InputCommon/Src/InputConfig.h"

Expand Down Expand Up @@ -55,7 +56,7 @@ void Initialize(void* const hwnd)
g_controller_interface.Initialize();

// load the saved controller config
g_plugin.LoadConfig();
g_plugin.LoadConfig(true);
}

void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/Src/HW/Wiimote.cpp
Expand Up @@ -5,6 +5,7 @@
#include "WiimoteReal/WiimoteReal.h"
#include "WiimoteEmu/WiimoteEmu.h"
#include "Movie.h"
#include "../ConfigManager.h"

#include "ControllerInterface/ControllerInterface.h"

Expand Down Expand Up @@ -44,7 +45,7 @@ void Initialize(void* const hwnd)
g_controller_interface.SetHwnd(hwnd);
g_controller_interface.Initialize();

g_plugin.LoadConfig();
g_plugin.LoadConfig(false);

WiimoteReal::Initialize();

Expand Down
47 changes: 44 additions & 3 deletions Source/Core/InputCommon/Src/InputConfig.cpp
Expand Up @@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/

#include "InputConfig.h"
#include "../../Core/Src/ConfigManager.h"

InputPlugin::~InputPlugin()
{
Expand All @@ -26,18 +27,58 @@ InputPlugin::~InputPlugin()
delete *i;
}

bool InputPlugin::LoadConfig()
bool InputPlugin::LoadConfig(bool isGC)
{
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"))
{
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
(*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
(*i)->UpdateReferences(g_controller_interface);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/InputCommon/Src/InputConfig.h
Expand Up @@ -42,7 +42,7 @@ class InputPlugin

~InputPlugin();

bool LoadConfig();
bool LoadConfig(bool isGC);
void SaveConfig();

std::vector< ControllerEmu* > controllers;
Expand Down

0 comments on commit f1489a4

Please sign in to comment.