revert to r4531, but keep the changes from the following revisions: 4533,4550-4551,4556-4559

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4566 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2009-11-14 17:08:32 +00:00
parent 18305c7c49
commit 06aa62504c
66 changed files with 2170 additions and 1570 deletions

View file

@ -46,7 +46,6 @@ Config::Config()
{
// Clear the memory
//memset(this, 0, sizeof(Config));
Loaded = false;
}
@ -96,7 +95,7 @@ void DEBUG_QUIT()
void Config::Save(int Slot)
{
// If there are no good pads don't save
if (NumPads == 0) return;
if (NumGoodPads == 0) return;
// Load ini file
IniFile file;
@ -128,27 +127,22 @@ void Config::Save(int Slot)
// Save the physical device ID
file.Set(SectionName.c_str(), "joy_id", PadMapping[i].ID);
file.Set(SectionName.c_str(), "joy_name", PadMapping[i].Name);
// ===================
// ==================================================================
// Joypad or slot specific settings
// -----------------
// Current joypad device ID: PadMapping[i].ID
// Current joypad name: IDToName(PadMapping[i].ID])
// Current joypad device ID: PadMapping[i].ID
// Current joypad name: joyinfo[PadMapping[i].ID].Name
if(g_Config.bSaveByID)
{
/* Save joypad specific settings. Check for "PadMapping[i].ID < SDL_NumJoysticks()" to
avoid reading a joyinfo that does't exist */
if((u32)PadMapping[i].ID >= joyinfo.size()) continue;
// Create a new section name after the joypad name
SectionName = IDToName(PadMapping[i].ID);
// Don't save a blank name
if (SectionName == "")
{
ERROR_LOG(PAD, "ID %i has no name, will not save", PadMapping[i].ID);
continue;
}
SectionName = joyinfo[PadMapping[i].ID].Name;
}
NOTICE_LOG(PAD, "Save settings for ID %i '%s' from PadMapping[%i]", PadMapping[i].ID, SectionName.c_str(), i);
file.Set(SectionName.c_str(), "l_shoulder", PadMapping[i].buttons[InputCommon::CTL_L_SHOULDER]);
file.Set(SectionName.c_str(), "r_shoulder", PadMapping[i].buttons[InputCommon::CTL_R_SHOULDER]);
@ -186,6 +180,8 @@ void Config::Save(int Slot)
file.Set(SectionName.c_str(), "SquareToCircleC", PadMapping[i].bSquareToCircleC);
}
INFO_LOG(CONSOLE, "%i: Save: %i\n", 0, PadMapping[0].halfpress);
file.Save(FULL_CONFIG_DIR "nJoy.ini");
}
@ -193,7 +189,8 @@ void Config::Save(int Slot)
// -----------------------
void Config::Load(bool ChangePad, bool ChangeSaveByID)
{
Loaded = true;
// If there are no good pads don't load
if (NumGoodPads == 0) return;
// Load file
IniFile file;
@ -214,9 +211,6 @@ void Config::Load(bool ChangePad, bool ChangeSaveByID)
}
// =============
// If there are no good pads don't load anymore
if (NumPads == 0) return;
for (int i = 0; i < 4; i++)
{
std::string SectionName = StringFromFormat("PAD%i", i+1);
@ -225,32 +219,23 @@ void Config::Load(bool ChangePad, bool ChangeSaveByID)
if (!ChangePad)
{
file.Get(SectionName.c_str(), "joy_id", &PadMapping[i].ID, 0);
file.Get(SectionName.c_str(), "joy_name", &PadMapping[i].Name, "");
}
// ==================================================================
// Joypad or slot specific settings
// -----------------
// Current joypad device ID: PadMapping[i].ID
// Current joypad name: IDToName(PadMapping[i].ID)
if (g_Config.bSaveByID)
// Current joypad device ID: PadMapping[i].ID
// Current joypad name: joyinfo[PadMapping[i].ID].Name
if(g_Config.bSaveByID)
{
// Prevent a crash from illegal access to joyinfo that will only have values for
// the current amount of connected pads
if((u32)PadMapping[i].ID >= joyinfo.size()) continue;
// Create a section name
SectionName = PadMapping[i].Name;
// Don't load settings for a non-connected device
if (!IsConnected(SectionName))
{
ERROR_LOG(PAD, "Slot %i: The device '%s' is not connected, will not load settings", SectionName.c_str());
continue;
}
// Don't load a blank ID
if (SectionName == "")
{
ERROR_LOG(PAD, "Slot %i has no device name, will not load settings", i);
continue;
}
SectionName = joyinfo[PadMapping[i].ID].Name;
}
file.Get(SectionName.c_str(), "l_shoulder", &PadMapping[i].buttons[InputCommon::CTL_L_SHOULDER], 4);
file.Get(SectionName.c_str(), "r_shoulder", &PadMapping[i].buttons[InputCommon::CTL_R_SHOULDER], 5);
file.Get(SectionName.c_str(), "a_button", &PadMapping[i].buttons[InputCommon::CTL_A_BUTTON], 0);
@ -284,11 +269,8 @@ void Config::Load(bool ChangePad, bool ChangeSaveByID)
file.Get(SectionName.c_str(), "RadiusOnOffC", &Tmp, false); PadMapping[i].bRadiusOnOffC = Tmp;
file.Get(SectionName.c_str(), "DiagonalC", &PadMapping[i].SDiagonalC, "100%");
file.Get(SectionName.c_str(), "SquareToCircleC", &Tmp, false); PadMapping[i].bSquareToCircleC = Tmp;
NOTICE_LOG(PAD, "Slot %i: Load settings for ID %i '%s'", i, PadMapping[i].ID, SectionName.c_str());
}
//INFO_LOG(PAD, "%i: Load: %i\n", 0, PadMapping[0].halfpress);
INFO_LOG(CONSOLE, "%i: Load: %i\n", 0, PadMapping[0].halfpress);
}