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