mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 23:29:44 -06:00
fix crash, but now 100% cpu usage on disconnect
This commit is contained in:
@ -136,10 +136,10 @@ int FindWiimotes(Wiimote** wm, int max_wiimotes)
|
|||||||
// Connect to a wiimote with a known address.
|
// Connect to a wiimote with a known address.
|
||||||
bool Wiimote::Connect()
|
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_family = AF_BLUETOOTH;
|
||||||
addr.l2_bdaddr = bdaddr;
|
addr.l2_bdaddr = bdaddr;
|
||||||
addr.l2_cid = 0;
|
addr.l2_cid = 0;
|
||||||
@ -206,17 +206,15 @@ void Wiimote::RealDisconnect()
|
|||||||
|
|
||||||
int Wiimote::IORead(unsigned char *buf)
|
int Wiimote::IORead(unsigned char *buf)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
|
||||||
fd_set fds;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
if (!IsConnected())
|
if (!IsConnected())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Block select for 1/2000th of a second
|
// Block select for 1/2000th of a second
|
||||||
|
timeval tv;
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
tv.tv_usec = WIIMOTE_DEFAULT_TIMEOUT * 1000;
|
tv.tv_usec = WIIMOTE_DEFAULT_TIMEOUT * 1000;
|
||||||
|
|
||||||
|
fd_set fds;
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(in_sock, &fds);
|
FD_SET(in_sock, &fds);
|
||||||
|
|
||||||
@ -230,7 +228,7 @@ int Wiimote::IORead(unsigned char *buf)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Read the pending message into the buffer
|
// 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)
|
if (r == -1)
|
||||||
{
|
{
|
||||||
// Error reading data
|
// Error reading data
|
||||||
@ -241,17 +239,17 @@ int Wiimote::IORead(unsigned char *buf)
|
|||||||
// This can happen if the bluetooth dongle is disconnected
|
// This can happen if the bluetooth dongle is disconnected
|
||||||
ERROR_LOG(WIIMOTE, "Bluetooth appears to be disconnected. "
|
ERROR_LOG(WIIMOTE, "Bluetooth appears to be disconnected. "
|
||||||
"Wiimote %i will be disconnected.", index + 1);
|
"Wiimote %i will be disconnected.", index + 1);
|
||||||
RealDisconnect();
|
//RealDisconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!r)
|
else if (!r)
|
||||||
{
|
{
|
||||||
// Disconnect
|
// Disconnect
|
||||||
RealDisconnect();
|
//RealDisconnect();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user