nJoy: Fixed bug that would cause the settings to be lost when nJoy was started without any detected gamepad

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2131 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-02-07 05:57:28 +00:00
parent 382b4af74b
commit 60e89dfc6f
5 changed files with 32 additions and 11 deletions

View File

@ -56,7 +56,6 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DolphinWX", "Core\DolphinWX\DolphinWX.vcproj", "{A72606EF-C5C1-4954-90AD-F0F93A8D97D9}"
ProjectSection(ProjectDependencies) = postProject
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160} = {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{8D612734-FAA5-4B8A-804F-4DEA2367D495} = {8D612734-FAA5-4B8A-804F-4DEA2367D495}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}

View File

@ -531,7 +531,7 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
}
// ===================================================
/* Here we produce a status report to send to the Wii. We currently ignore the status
/* Here we produce a 0x20 status report to send to the Wii. We currently ignore the status
request rs and all its eventual instructions it may include (for example turn off
rumble or something else) and just send the status report. */
// ----------------

View File

@ -96,6 +96,9 @@ void DEBUG_QUIT()
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void Config::Save(int Slot)
{
// If there are no good pads don't save
if (NumGoodPads == 0) return;
// Load ini file
IniFile file;
file.Load("nJoy.ini");
@ -180,6 +183,9 @@ void Config::Save(int Slot)
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void Config::Load(bool ChangePad, bool ChangeSaveByID)
{
// If there are no good pads don't load
if (NumGoodPads == 0) return;
// Load file
IniFile file;
file.Load("nJoy.ini");

View File

@ -372,17 +372,22 @@ void ConfigBox::SetButtonTextAll(int id, char text[128])
{
for (int i = 0; i < 4; i++)
{
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[notebookpage].ID].Name)
SetButtonText(id, text, i);
// Safety check to avoid crash
if(joyinfo.size() > PadMapping[i].ID)
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[notebookpage].ID].Name)
SetButtonText(id, text, i);
};
}
void ConfigBox::SaveButtonMappingAll(int Slot)
{
for (int i = 0; i < 4; i++)
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[Slot].ID].Name)
SaveButtonMapping(i, false, Slot);
{
// This can occur when no gamepad is detected
if(joyinfo.size() > PadMapping[i].ID)
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[Slot].ID].Name)
SaveButtonMapping(i, false, Slot);
}
}
void ConfigBox::UpdateGUIAll(int Slot)
@ -394,8 +399,12 @@ void ConfigBox::UpdateGUIAll(int Slot)
else
{
for (int i = 0; i < 4; i++)
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[Slot].ID].Name)
UpdateGUI(i);
{
// Safety check to avoid crash
if(joyinfo.size() > PadMapping[i].ID)
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[Slot].ID].Name)
UpdateGUI(i);
}
}
}
@ -455,6 +464,13 @@ void ConfigBox::ChangeSettings( wxCommandEvent& event )
// Called from: CreateGUIControls(), ChangeControllertype()
void ConfigBox::UpdateGUI(int _notebookpage)
{
// If there are no good pads disable the entire notebook
if (NumGoodPads == 0)
{
m_Notebook->Enable(false);
return;
}
// Update the GUI from PadMapping[]
UpdateGUIKeys(_notebookpage);
@ -596,7 +612,7 @@ void ConfigBox::CreateGUIControls()
}
else
{
arrayStringFor_Joyname.Add(wxString::FromAscii("No Joystick detected!"));
arrayStringFor_Joyname.Add(wxString::FromAscii("<No Gamepad Detected>"));
}
// --------------------------------------------------------------------

View File

@ -336,7 +336,7 @@ int Search_Devices()
// Warn the user if no gamepads are detected
if (NumGoodPads == 0 && emulator_running)
{
PanicAlert("No Joystick detected");
PanicAlert("nJoy: No Gamepad Detected");
return joyinfo.size();
}