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,7 +271,8 @@ void SendAcc(u8 _ReportID)
|
||||||
void ClearEvents()
|
void ClearEvents()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < g_NumberOfWiiMotes; i++)
|
for (int i = 0; i < g_NumberOfWiiMotes; i++)
|
||||||
g_WiiMotes[i]->ClearEvents();
|
if (g_WiimoteInUse[i])
|
||||||
|
g_WiiMotes[i]->ClearEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flash lights, and if connecting, also rumble
|
// Flash lights, and if connecting, also rumble
|
||||||
|
@ -296,7 +297,7 @@ void FlashLights(bool Connect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Initialize()
|
int Initialize() // None of this code is intelligible, oh well...
|
||||||
{
|
{
|
||||||
// Return if already initialized
|
// Return if already initialized
|
||||||
if (g_RealWiiMoteInitialized)
|
if (g_RealWiiMoteInitialized)
|
||||||
|
@ -362,21 +363,14 @@ int Initialize()
|
||||||
FlashLights(true);
|
FlashLights(true);
|
||||||
|
|
||||||
// Create Wiimote classes
|
// Create Wiimote classes
|
||||||
int current_number = 0;
|
for (int i = 0; i < g_NumberOfWiiMotes; i++)
|
||||||
for (int i = 0; i < g_NumberOfWiiMotes; i++) {
|
{
|
||||||
|
// Why the fuck are there 2 values for "real wiimote"??? NOBODY KNOWS
|
||||||
// Determine the number of the current WiiMote
|
if ((WiiMoteEmu::WiiMapping[i].Source == -1) || (WiiMoteEmu::WiiMapping[i].Source == 2))
|
||||||
for (; current_number < MAX_WIIMOTES; current_number++)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
|
g_WiimoteInUse[i] = true;
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
case 0:
|
case 0:
|
||||||
wiiuse_set_leds(g_WiiMotesFromWiiUse[i], WIIMOTE_LED_1);
|
wiiuse_set_leds(g_WiiMotesFromWiiUse[i], WIIMOTE_LED_1);
|
||||||
break;
|
break;
|
||||||
|
@ -387,11 +381,14 @@ int Initialize()
|
||||||
wiiuse_set_leds(g_WiiMotesFromWiiUse[i], WIIMOTE_LED_3);
|
wiiuse_set_leds(g_WiiMotesFromWiiUse[i], WIIMOTE_LED_3);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
default:
|
wiiuse_set_leds(g_WiiMotesFromWiiUse[i], WIIMOTE_LED_4);
|
||||||
wiiuse_set_leds(g_WiiMotesFromWiiUse[i], WIIMOTE_LED_NONE);
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
PanicAlert("Trying to create real wiimote %i WTF", i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
g_WiiMotes[i] = new CWiiMote(i, g_WiiMotesFromWiiUse[i]);
|
||||||
}
|
}
|
||||||
DEBUG_LOG(WIIMOTE, "Real WiiMote allocated as WiiMote #%i", current_number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new thread and start listening for Wiimote data
|
// Create a new thread and start listening for Wiimote data
|
||||||
|
|
Loading…
Reference in New Issue