fix crash when switching to real wiimote with "connect real wiimote" already enabled.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4767 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
195f734054
commit
eb16c51d5f
|
@ -271,6 +271,7 @@ void SendAcc(u8 _ReportID)
|
|||
void ClearEvents()
|
||||
{
|
||||
for (int i = 0; i < g_NumberOfWiiMotes; i++)
|
||||
if (g_WiimoteInUse[i])
|
||||
g_WiiMotes[i]->ClearEvents();
|
||||
}
|
||||
|
||||
|
@ -296,7 +297,7 @@ void FlashLights(bool Connect)
|
|||
}
|
||||
}
|
||||
|
||||
int Initialize()
|
||||
int Initialize() // None of this code is intelligible, oh well...
|
||||
{
|
||||
// Return if already initialized
|
||||
if (g_RealWiiMoteInitialized)
|
||||
|
@ -362,20 +363,13 @@ int Initialize()
|
|||
FlashLights(true);
|
||||
|
||||
// Create Wiimote classes
|
||||
int current_number = 0;
|
||||
for (int i = 0; i < g_NumberOfWiiMotes; i++) {
|
||||
|
||||
// Determine the number of the current WiiMote
|
||||
for (; current_number < MAX_WIIMOTES; current_number++)
|
||||
for (int i = 0; i < g_NumberOfWiiMotes; i++)
|
||||
{
|
||||
if (g_WiimoteInUse[current_number] == true)
|
||||
continue;
|
||||
if (WiiMoteEmu::WiiMapping[current_number].Source < 0)
|
||||
break;
|
||||
}
|
||||
g_WiiMotes[current_number] = new CWiiMote(current_number, g_WiiMotesFromWiiUse[i]);
|
||||
g_WiimoteInUse[current_number] = true;
|
||||
switch (current_number)
|
||||
// Why the fuck are there 2 values for "real wiimote"??? NOBODY KNOWS
|
||||
if ((WiiMoteEmu::WiiMapping[i].Source == -1) || (WiiMoteEmu::WiiMapping[i].Source == 2))
|
||||
{
|
||||
g_WiimoteInUse[i] = true;
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
wiiuse_set_leds(g_WiiMotesFromWiiUse[i], WIIMOTE_LED_1);
|
||||
|
@ -387,11 +381,14 @@ int Initialize()
|
|||
wiiuse_set_leds(g_WiiMotesFromWiiUse[i], WIIMOTE_LED_3);
|
||||
break;
|
||||
case 3:
|
||||
wiiuse_set_leds(g_WiiMotesFromWiiUse[i], WIIMOTE_LED_4);
|
||||
break;
|
||||
default:
|
||||
wiiuse_set_leds(g_WiiMotesFromWiiUse[i], WIIMOTE_LED_NONE);
|
||||
PanicAlert("Trying to create real wiimote %i WTF", i);
|
||||
break;
|
||||
}
|
||||
DEBUG_LOG(WIIMOTE, "Real WiiMote allocated as WiiMote #%i", current_number);
|
||||
g_WiiMotes[i] = new CWiiMote(i, g_WiiMotesFromWiiUse[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new thread and start listening for Wiimote data
|
||||
|
|
Loading…
Reference in New Issue