mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-10 14:39:01 +01:00
better fix for linux wiimote disconnect crash
This commit is contained in:
parent
e1c8bea2f6
commit
1c10d3a1bb
@ -195,20 +195,30 @@ void Wiimote::RealDisconnect()
|
|||||||
if (m_wiimote_thread.joinable())
|
if (m_wiimote_thread.joinable())
|
||||||
m_wiimote_thread.join();
|
m_wiimote_thread.join();
|
||||||
|
|
||||||
Host_ConnectWiimote(index, false);
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
close(out_sock);
|
void Wiimote::Close()
|
||||||
close(in_sock);
|
{
|
||||||
|
if (IsOpen())
|
||||||
|
{
|
||||||
|
Host_ConnectWiimote(index, false);
|
||||||
|
|
||||||
out_sock = -1;
|
close(out_sock);
|
||||||
in_sock = -1;
|
close(in_sock);
|
||||||
|
|
||||||
|
out_sock = -1;
|
||||||
|
in_sock = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Wiimote::IsOpen() const
|
||||||
|
{
|
||||||
|
return out_sock != -1 && in_sock != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Wiimote::IORead(unsigned char *buf)
|
int Wiimote::IORead(unsigned char *buf)
|
||||||
{
|
{
|
||||||
if (!IsConnected())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// Block select for 1/2000th of a second
|
// Block select for 1/2000th of a second
|
||||||
timeval tv;
|
timeval tv;
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
@ -239,7 +249,7 @@ 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();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -247,7 +257,7 @@ int Wiimote::IORead(unsigned char *buf)
|
|||||||
else if (!r)
|
else if (!r)
|
||||||
{
|
{
|
||||||
// Disconnect
|
// Disconnect
|
||||||
//RealDisconnect();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
@ -294,6 +294,11 @@ void Wiimote::RealDisconnect()
|
|||||||
ResetEvent(&hid_overlap);
|
ResetEvent(&hid_overlap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Wiimote::IsOpen() const
|
||||||
|
{
|
||||||
|
return IsConnected();
|
||||||
|
}
|
||||||
|
|
||||||
int Wiimote::IORead(unsigned char* buf)
|
int Wiimote::IORead(unsigned char* buf)
|
||||||
{
|
{
|
||||||
DWORD b, r;
|
DWORD b, r;
|
||||||
|
@ -227,6 +227,11 @@ void Wiimote::RealDisconnect()
|
|||||||
ichan = NULL;
|
ichan = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Wiimote::IsOpen() const
|
||||||
|
{
|
||||||
|
return IsConnected();
|
||||||
|
}
|
||||||
|
|
||||||
int Wiimote::IORead(unsigned char *buf)
|
int Wiimote::IORead(unsigned char *buf)
|
||||||
{
|
{
|
||||||
int bytes;
|
int bytes;
|
||||||
|
@ -312,7 +312,7 @@ void Wiimote::ThreadFunc()
|
|||||||
Rumble();
|
Rumble();
|
||||||
|
|
||||||
// main loop
|
// main loop
|
||||||
while (IsConnected())
|
while (IsOpen())
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
while (Write()) {}
|
while (Write()) {}
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
bool Write();
|
bool Write();
|
||||||
bool Connect();
|
bool Connect();
|
||||||
bool IsConnected();
|
bool IsConnected();
|
||||||
|
bool IsOpen() const;
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
void DisableDataReporting();
|
void DisableDataReporting();
|
||||||
void Rumble();
|
void Rumble();
|
||||||
@ -72,6 +73,9 @@ public:
|
|||||||
bdaddr_t bdaddr; // Bluetooth address
|
bdaddr_t bdaddr; // Bluetooth address
|
||||||
int out_sock; // Output socket
|
int out_sock; // Output socket
|
||||||
int in_sock; // Input socket
|
int in_sock; // Input socket
|
||||||
|
|
||||||
|
void Close();
|
||||||
|
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
char devicepath[255]; // Unique wiimote reference
|
char devicepath[255]; // Unique wiimote reference
|
||||||
//ULONGLONG btaddr; // Bluetooth address
|
//ULONGLONG btaddr; // Bluetooth address
|
||||||
|
Loading…
x
Reference in New Issue
Block a user