Hopefully make real wiimotes on OSX less crashy.

This commit is contained in:
Jordan Woyak 2013-02-08 16:54:48 -06:00
parent 1998da867b
commit 1f1b4a6992
2 changed files with 11 additions and 7 deletions

View File

@ -40,8 +40,11 @@
{
IOBluetoothDevice *device = [l2capChannel getDevice];
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)
continue;
if ([device isEqual: WiimoteReal::g_wiimotes[i]->btd] == TRUE)
@ -77,8 +80,11 @@
{
IOBluetoothDevice *device = [l2capChannel getDevice];
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)
continue;
if ([device isEqual: WiimoteReal::g_wiimotes[i]->btd] == TRUE)
@ -236,8 +242,6 @@ int Wiimote::IORead(unsigned char *buf)
if (!IsConnected())
return 0;
// TODO: race conditions here, yo
bytes = inputlen;
memcpy(buf, input, bytes);

View File

@ -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
}
}