Allow loading controller profiles from game ini.

Currently loads the same profile for all 4 controllers, and overwrites the default control settings.
This commit is contained in:
Rachel Bryk 2013-01-08 19:15:11 -05:00
parent 4f4aa4860d
commit b8691df723
6 changed files with 25 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
{ {
@ -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 // Run the game
// Init the core // Init the core
if (!Core::Init()) if (!Core::Init())
@ -169,6 +173,8 @@ void Stop()
StartUp.bDSPHLE = config_cache.bDSPHLE; StartUp.bDSPHLE = config_cache.bDSPHLE;
StartUp.bDisableWiimoteSpeaker = config_cache.bDisableWiimoteSpeaker; StartUp.bDisableWiimoteSpeaker = config_cache.bDisableWiimoteSpeaker;
StartUp.m_strVideoBackend = config_cache.strBackend; StartUp.m_strVideoBackend = config_cache.strBackend;
StartUp.strGCControllerProfile = "";
StartUp.strWiiControllerProfile = "";
VideoBackend::ActivateBackend(StartUp.m_strVideoBackend); VideoBackend::ActivateBackend(StartUp.m_strVideoBackend);
} }
} }

View File

@ -138,7 +138,9 @@ struct SCoreStartupParameter
int iTheme; int iTheme;
int iPosX, iPosY, iWidth, iHeight; int iPosX, iPosY, iWidth, iHeight;
std::string strGCControllerProfile;
std::string strWiiControllerProfile;
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(SConfig::GetInstance().m_LocalCoreStartupParameter.strGCControllerProfile);
} }
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(SConfig::GetInstance().m_LocalCoreStartupParameter.strWiiControllerProfile);
WiimoteReal::Initialize(); WiimoteReal::Initialize();

View File

@ -26,10 +26,13 @@ InputPlugin::~InputPlugin()
delete *i; delete *i;
} }
bool InputPlugin::LoadConfig() bool InputPlugin::LoadConfig(std::string ini)
{ {
IniFile inifile; 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 std::vector< ControllerEmu* >::const_iterator
i = controllers.begin(), i = controllers.begin(),
@ -37,7 +40,11 @@ bool InputPlugin::LoadConfig()
for (; i!=e; ++i) for (; i!=e; ++i)
{ {
// load settings from ini // 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 // 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(std::string ini);
void SaveConfig(); void SaveConfig();
std::vector< ControllerEmu* > controllers; std::vector< ControllerEmu* > controllers;