Skip to content

Commit

Permalink
Allow loading controller profiles from game ini.
Browse files Browse the repository at this point in the history
Currently loads the same profile for all 4 controllers, and overwrites the default control settings.
  • Loading branch information
RachelBryk committed Jan 9, 2013
1 parent 4f4aa48 commit b8691df
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
8 changes: 7 additions & 1 deletion Source/Core/Core/Src/BootManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include "VideoBackendBase.h"
#include "Movie.h"


namespace BootManager
{

Expand Down Expand Up @@ -137,6 +136,11 @@ 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())
Expand Down Expand Up @@ -169,6 +173,8 @@ 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);
}
}
Expand Down
4 changes: 3 additions & 1 deletion Source/Core/Core/Src/CoreParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ struct SCoreStartupParameter

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


std::string strGCControllerProfile;
std::string strWiiControllerProfile;
enum EBootBS2
{
BOOT_DEFAULT,
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/Src/HW/GCPad.cpp
Original file line number Diff line number Diff line change
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(SConfig::GetInstance().m_LocalCoreStartupParameter.strGCControllerProfile);
}

void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/Src/HW/Wiimote.cpp
Original file line number Diff line number Diff line change
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(SConfig::GetInstance().m_LocalCoreStartupParameter.strWiiControllerProfile);

WiimoteReal::Initialize();

Expand Down
13 changes: 10 additions & 3 deletions Source/Core/InputCommon/Src/InputConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,25 @@ InputPlugin::~InputPlugin()
delete *i;
}

bool InputPlugin::LoadConfig()
bool InputPlugin::LoadConfig(std::string ini)
{
IniFile inifile;
if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini_name + ".ini"))
std::string ini2 = ini;
if (ini == "")
ini = ini_name;
if (inifile.Load(File::GetUserPath(D_CONFIG_IDX) + ini + ".ini"))
{
std::vector< ControllerEmu* >::const_iterator
i = controllers.begin(),
e = controllers.end();
for (; i!=e; ++i)
{
// load settings from ini
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
std::string section;
section = (*i)->GetName();
if (ini2 != "")
section = "Profile";
(*i)->LoadConfig(inifile.GetOrCreateSection(section.c_str()));
// update refs
(*i)->UpdateReferences(g_controller_interface);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/InputCommon/Src/InputConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class InputPlugin

~InputPlugin();

bool LoadConfig();
bool LoadConfig(std::string ini);
void SaveConfig();

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

0 comments on commit b8691df

Please sign in to comment.