summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2013-01-10 15:23:42 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2013-01-10 15:23:42 -0600
commite1c8bea2f6edc53644fd95d0f4a3f99526439577 (patch)
tree7a80f35b90249f6396c47579ddc715832571ab6c /Source/Core
parentd6b53af115818878b0520f8d91e255351a4f48b8 (diff)
fix crash, but now 100% cpu usage on disconnect
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp b/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp
index b01caf06c8..1fb61f7715 100644
--- a/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp
+++ b/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp
@@ -136,10 +136,10 @@ int FindWiimotes(Wiimote** wm, int max_wiimotes)
// Connect to a wiimote with a known address.
bool Wiimote::Connect()
{
- struct sockaddr_l2 addr;
-
- if (IsConnected()) return false;
+ if (IsConnected())
+ return false;
+ sockaddr_l2 addr;
addr.l2_family = AF_BLUETOOTH;
addr.l2_bdaddr = bdaddr;
addr.l2_cid = 0;
@@ -206,17 +206,15 @@ void Wiimote::RealDisconnect()
int Wiimote::IORead(unsigned char *buf)
{
- struct timeval tv;
- fd_set fds;
- int r;
-
if (!IsConnected())
return 0;
// Block select for 1/2000th of a second
+ timeval tv;
tv.tv_sec = 0;
tv.tv_usec = WIIMOTE_DEFAULT_TIMEOUT * 1000;
+ fd_set fds;
FD_ZERO(&fds);
FD_SET(in_sock, &fds);
@@ -230,7 +228,7 @@ int Wiimote::IORead(unsigned char *buf)
return 0;
// Read the pending message into the buffer
- r = read(in_sock, buf, MAX_PAYLOAD);
+ int r = read(in_sock, buf, MAX_PAYLOAD);
if (r == -1)
{
// Error reading data
@@ -241,17 +239,17 @@ int Wiimote::IORead(unsigned char *buf)
// This can happen if the bluetooth dongle is disconnected
ERROR_LOG(WIIMOTE, "Bluetooth appears to be disconnected. "
"Wiimote %i will be disconnected.", index + 1);
- RealDisconnect();
+ //RealDisconnect();
}
return 0;
}
- if (!r)
+ else if (!r)
{
// Disconnect
- RealDisconnect();
- return 0;
+ //RealDisconnect();
}
+
return r;
}