Emulated Wiimote: Fixed a bug that would make PadMapping[0].ID = -1, that would lead to a segmentation fault in Linux when we tried to access joyinfo[-1]
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2287 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
9ed368b35a
commit
12a869304c
|
@ -55,7 +55,7 @@ void Config::Load(bool ChangePad)
|
|||
|
||||
// Default controls
|
||||
#ifdef _WIN32
|
||||
int WmA = 65, WmB = 65,
|
||||
int WmA = 65, WmB = 66,
|
||||
Wm1 = 49, Wm2 = 50,
|
||||
WmP = 80, WmM = 77, WmH = 72,
|
||||
WmL = 37, WmR = 39, WmU = 38, WmD = 40, // Regular directional keys
|
||||
|
@ -117,12 +117,11 @@ void Config::Load(bool ChangePad)
|
|||
// Don't update this when we are loading settings from the ConfigBox
|
||||
if(!ChangePad)
|
||||
{
|
||||
/* This pad Id could possibly be higher than the number of pads that are connected,
|
||||
but we check later, when needed, that that is not the case */
|
||||
iniFile.Get(SectionName.c_str(), "DeviceID", &WiiMoteEmu::PadMapping[i].ID, 0);
|
||||
iniFile.Get(SectionName.c_str(), "Enabled", &WiiMoteEmu::PadMapping[i].enabled, true);
|
||||
}
|
||||
|
||||
// Check if the pad ID is within the range of avaliable pads
|
||||
if (WiiMoteEmu::PadMapping[i].ID > (WiiMoteEmu::NumPads - 1)) WiiMoteEmu::PadMapping[i].ID = (WiiMoteEmu::NumPads - 1);
|
||||
// ===================
|
||||
|
||||
// ==================================================================
|
||||
|
|
|
@ -204,7 +204,9 @@ void ConfigDialog::SaveButtonMapping(int controller, bool DontChangeId, int From
|
|||
// Replace "" with "-1" in the GUI controls
|
||||
ToBlank(false);
|
||||
|
||||
// Set physical device Id
|
||||
/* Set physical device Id. GetSelection() should never be -1 here so we don't check that it's zero or higher. If it's possible that it can be
|
||||
-1 that's a bug that should be fixed. Because the m_Joyname[] combo box should always show <No Gamepad Detected>, or a gamepad name, not a
|
||||
a blank selection. */
|
||||
if(!DontChangeId) WiiMoteEmu::PadMapping[controller].ID = m_Joyname[FromSlot]->GetSelection();
|
||||
// Set enabled or disable status
|
||||
if(FromSlot == controller) WiiMoteEmu::PadMapping[controller].enabled = true; //m_Joyattach[FromSlot]->GetValue(); // Only enable one
|
||||
|
@ -228,8 +230,8 @@ void ConfigDialog::SaveButtonMapping(int controller, bool DontChangeId, int From
|
|||
m_AnalogTriggerL[FromSlot]->GetValue().ToLong(&value); WiiMoteEmu::PadMapping[controller].Axis.Tl = value;
|
||||
m_AnalogTriggerR[FromSlot]->GetValue().ToLong(&value); WiiMoteEmu::PadMapping[controller].Axis.Tr = value;
|
||||
|
||||
//Console::Print("WiiMoteEmu::PadMapping[%i].deadzone = %i, m_ComboDeadZone[%i]->GetSelection() = %i\n",
|
||||
// controller, WiiMoteEmu::PadMapping[controller].deadzone, FromSlot, m_ComboDeadZone[FromSlot]->GetSelection());
|
||||
//Console::Print("WiiMoteEmu::PadMapping[%i].ID = %i, m_Joyname[%i]->GetSelection() = %i\n",
|
||||
// controller, WiiMoteEmu::PadMapping[controller].ID, FromSlot, m_Joyname[FromSlot]->GetSelection());
|
||||
|
||||
// Replace "-1" with ""
|
||||
ToBlank();
|
||||
|
@ -611,7 +613,7 @@ void ConfigDialog::PadGetStatus()
|
|||
|
||||
// Check that Dolphin is in focus, otherwise don't update the pad status
|
||||
//if (IsFocus())
|
||||
WiiMoteEmu::GetJoyState(WiiMoteEmu::PadState[Page], WiiMoteEmu::PadMapping[Page], Page, WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[Page].ID].NumButtons);
|
||||
WiiMoteEmu::GetJoyState(WiiMoteEmu::PadState[Page], WiiMoteEmu::PadMapping[Page], Page, WiiMoteEmu::joyinfo.at(WiiMoteEmu::PadMapping[Page].ID).NumButtons);
|
||||
|
||||
|
||||
//////////////////////////////////////
|
||||
|
|
|
@ -48,8 +48,9 @@ bool StrangeHack = true;
|
|||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::PadGetStatus()
|
||||
{
|
||||
// Return if it's not detected
|
||||
if(PadMapping[notebookpage].ID >= SDL_NumJoysticks())
|
||||
/* Return if it's not detected. The ID should never be less than zero here, it can only be that
|
||||
because of a manual ini file change, but we make that check anway. */
|
||||
if(PadMapping[notebookpage].ID >= 0 && PadMapping[notebookpage].ID >= SDL_NumJoysticks())
|
||||
{
|
||||
m_TStatusIn[notebookpage]->SetLabel(wxT("Not connected"));
|
||||
m_TStatusOut[notebookpage]->SetLabel(wxT("Not connected"));
|
||||
|
|
Loading…
Reference in New Issue