Hopefully make real wiimotes on OSX less crashy.
This commit is contained in:
parent
1998da867b
commit
1f1b4a6992
|
@ -41,7 +41,10 @@
|
|||
IOBluetoothDevice *device = [l2capChannel getDevice];
|
||||
WiimoteReal::Wiimote *wm = NULL;
|
||||
|
||||
for (int i = 0; i < MAX_WIIMOTES; i++) {
|
||||
std::lock_guard<std::recursive_mutex> lk(g_refresh_lock);
|
||||
|
||||
for (int i = 0; i < MAX_WIIMOTES; i++)
|
||||
{
|
||||
if (WiimoteReal::g_wiimotes[i] == NULL)
|
||||
continue;
|
||||
if ([device isEqual: WiimoteReal::g_wiimotes[i]->btd] == TRUE)
|
||||
|
@ -78,7 +81,10 @@
|
|||
IOBluetoothDevice *device = [l2capChannel getDevice];
|
||||
WiimoteReal::Wiimote *wm = NULL;
|
||||
|
||||
for (int i = 0; i < MAX_WIIMOTES; i++) {
|
||||
std::lock_guard<std::recursive_mutex> lk(g_refresh_lock);
|
||||
|
||||
for (int i = 0; i < MAX_WIIMOTES; i++)
|
||||
{
|
||||
if (WiimoteReal::g_wiimotes[i] == NULL)
|
||||
continue;
|
||||
if ([device isEqual: WiimoteReal::g_wiimotes[i]->btd] == TRUE)
|
||||
|
@ -237,8 +243,6 @@ int Wiimote::IORead(unsigned char *buf)
|
|||
if (!IsConnected())
|
||||
return 0;
|
||||
|
||||
// TODO: race conditions here, yo
|
||||
|
||||
bytes = inputlen;
|
||||
memcpy(buf, input, bytes);
|
||||
inputlen = 0;
|
||||
|
|
|
@ -360,13 +360,13 @@ void Wiimote::ThreadFunc()
|
|||
while (m_run_thread && IsConnected())
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
while (Write()) {}
|
||||
Common::SleepCurrentThread(1);
|
||||
// Reading happens elsewhere on OSX
|
||||
bool const did_something = Write();
|
||||
#else
|
||||
bool const did_something = Write() || Read();
|
||||
#endif
|
||||
if (!did_something)
|
||||
Common::SleepCurrentThread(1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue