mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-25 07:21:14 +01:00
sanchez's patch for real wiimote pair-up, unexpected disconnect, and wiiuse resource leakage.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5313 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
474363bc27
commit
4b5b074b81
BIN
Externals/WiiUse/Win32/wiiuse.dll
vendored
BIN
Externals/WiiUse/Win32/wiiuse.dll
vendored
Binary file not shown.
BIN
Externals/WiiUse/Win32/wiiuse.lib
vendored
BIN
Externals/WiiUse/Win32/wiiuse.lib
vendored
Binary file not shown.
BIN
Externals/WiiUse/X64/wiiuse.dll
vendored
BIN
Externals/WiiUse/X64/wiiuse.dll
vendored
Binary file not shown.
BIN
Externals/WiiUse/X64/wiiuse.lib
vendored
BIN
Externals/WiiUse/X64/wiiuse.lib
vendored
Binary file not shown.
40
Externals/WiiUseSrc/Src/io_win.c
vendored
40
Externals/WiiUseSrc/Src/io_win.c
vendored
@ -112,7 +112,10 @@ int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
|||||||
|
|
||||||
/* try to set the output report to see if the device is actually connected */
|
/* try to set the output report to see if the device is actually connected */
|
||||||
if (!wiiuse_set_report_type(wm[found])) {
|
if (!wiiuse_set_report_type(wm[found])) {
|
||||||
|
Sleep(10);
|
||||||
WIIMOTE_DISABLE_STATE(wm[found], WIIMOTE_STATE_CONNECTED);
|
WIIMOTE_DISABLE_STATE(wm[found], WIIMOTE_STATE_CONNECTED);
|
||||||
|
if (wm[found]->event == WIIUSE_UNEXPECTED_DISCONNECT)
|
||||||
|
break;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,6 +184,7 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
|||||||
if ((b == ERROR_HANDLE_EOF) || (b == ERROR_DEVICE_NOT_CONNECTED)) {
|
if ((b == ERROR_HANDLE_EOF) || (b == ERROR_DEVICE_NOT_CONNECTED)) {
|
||||||
/* remote disconnect */
|
/* remote disconnect */
|
||||||
wiiuse_disconnected(wm);
|
wiiuse_disconnected(wm);
|
||||||
|
wm->event = WIIUSE_UNEXPECTED_DISCONNECT;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +218,7 @@ int wiiuse_io_read(struct wiimote_t* wm) {
|
|||||||
|
|
||||||
|
|
||||||
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
|
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
|
||||||
DWORD bytes;
|
DWORD bytes, dw;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
||||||
@ -235,12 +239,42 @@ int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
WIIUSE_ERROR("Unable to determine bluetooth stack type.");
|
/*--------------------------------------------------------------
|
||||||
|
dw = GetLastError(); //checking for 121 = timeout on semaphore/device off/disconnected to avoid trouble with other stacks toshiba/widcomm
|
||||||
|
//995 = The I/O operation has been aborted because of either a thread exit or an application request.
|
||||||
|
|
||||||
|
if ( (dw == 121) || (dw == 995) ) {
|
||||||
|
WIIUSE_INFO("wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: WIIUSE_UNEXPECTED_DISCONNECT");
|
||||||
|
wiiuse_disconnected(wm);
|
||||||
|
wm->event = WIIUSE_UNEXPECTED_DISCONNECT;
|
||||||
|
}
|
||||||
|
else WIIUSE_ERROR("wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: WIIUSE_UNEXPECTED_DISCONNECT ERROR: %08x", dw);
|
||||||
|
--------------------------------------------------------------*/
|
||||||
|
|
||||||
|
//If the part below causes trouble on WIDCOMM/TOSHIBA stack uncomment the lines above, and comment out the 3 lines below instead.
|
||||||
|
|
||||||
|
WIIUSE_INFO("wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: WIIUSE_UNEXPECTED_DISCONNECT - time out");
|
||||||
|
wiiuse_disconnected(wm);
|
||||||
|
wm->event = WIIUSE_UNEXPECTED_DISCONNECT;
|
||||||
|
|
||||||
|
//WIIUSE_ERROR("wiiuse_io_write[WIIUSE_STACK_UNKNOWN]: Unable to determine bluetooth stack type || Wiimote timed out.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WIIUSE_STACK_MS:
|
case WIIUSE_STACK_MS:
|
||||||
return HidD_SetOutputReport(wm->dev_handle, buf + 1, len - 1);
|
i = HidD_SetOutputReport(wm->dev_handle, buf + 1, len - 1);
|
||||||
|
dw = GetLastError();
|
||||||
|
|
||||||
|
if (dw == 121) { // semaphore timeout
|
||||||
|
WIIUSE_INFO("wiiuse_io_write[WIIUSE_STACK_MS]: WIIUSE_UNEXPECTED_DISCONNECT");
|
||||||
|
wiiuse_disconnected(wm);
|
||||||
|
wm->event = WIIUSE_UNEXPECTED_DISCONNECT;
|
||||||
|
return 0;
|
||||||
|
}/* else if (dw)
|
||||||
|
WIIUSE_ERROR("wiiuse_io_write[WIIUSE_STACK_MS]: WIIUSE_UNEXPECTED_DISCONNECT ERROR: %08x", dw);
|
||||||
|
*/
|
||||||
|
// it is not important to catch all errors here at this place, rest will be covered by io_reads.
|
||||||
|
return i;
|
||||||
|
|
||||||
case WIIUSE_STACK_BLUESOLEIL:
|
case WIIUSE_STACK_BLUESOLEIL:
|
||||||
return WriteFile(wm->dev_handle, buf + 1, 22, &bytes, &wm->hid_overlap);
|
return WriteFile(wm->dev_handle, buf + 1, 22, &bytes, &wm->hid_overlap);
|
||||||
|
15
Externals/WiiUseSrc/Src/wiiuse.c
vendored
15
Externals/WiiUseSrc/Src/wiiuse.c
vendored
@ -172,13 +172,6 @@ void wiiuse_disconnected(struct wiimote_t* wm) {
|
|||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_CONNECTED);
|
||||||
|
|
||||||
/* reset a bunch of stuff */
|
/* reset a bunch of stuff */
|
||||||
#ifndef WIN32
|
|
||||||
wm->out_sock = -1;
|
|
||||||
wm->in_sock = -1;
|
|
||||||
#else
|
|
||||||
wm->dev_handle = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wm->leds = 0;
|
wm->leds = 0;
|
||||||
wm->state = WIIMOTE_INIT_STATES;
|
wm->state = WIIMOTE_INIT_STATES;
|
||||||
wm->read_req = NULL;
|
wm->read_req = NULL;
|
||||||
@ -188,6 +181,14 @@ void wiiuse_disconnected(struct wiimote_t* wm) {
|
|||||||
wm->btns_released = 0;
|
wm->btns_released = 0;
|
||||||
memset(wm->event_buf, 0, sizeof(wm->event_buf));
|
memset(wm->event_buf, 0, sizeof(wm->event_buf));
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
wm->out_sock = -1;
|
||||||
|
wm->in_sock = -1;
|
||||||
|
#else
|
||||||
|
CloseHandle(wm->dev_handle);
|
||||||
|
wm->dev_handle = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
wm->event = WIIUSE_DISCONNECT;
|
wm->event = WIIUSE_DISCONNECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +140,10 @@ void ReadData()
|
|||||||
//DEBUG_LOG(WIIMOTE, "Writing data to the Wiimote");
|
//DEBUG_LOG(WIIMOTE, "Writing data to the Wiimote");
|
||||||
SEvent& rEvent = m_EventWriteQueue.front();
|
SEvent& rEvent = m_EventWriteQueue.front();
|
||||||
wiiuse_io_write(m_pWiiMote, (byte*)rEvent.m_PayLoad, rEvent._Size);
|
wiiuse_io_write(m_pWiiMote, (byte*)rEvent.m_PayLoad, rEvent._Size);
|
||||||
|
if (m_pWiiMote->event == WIIUSE_UNEXPECTED_DISCONNECT)
|
||||||
|
{
|
||||||
|
NOTICE_LOG(WIIMOTE, "wiiuse_io_write: unexpected disconnect. handle: %08x", m_pWiiMote->dev_handle);
|
||||||
|
}
|
||||||
m_EventWriteQueue.pop();
|
m_EventWriteQueue.pop();
|
||||||
|
|
||||||
// InterruptDebugging(false, rEvent.m_PayLoad);
|
// InterruptDebugging(false, rEvent.m_PayLoad);
|
||||||
@ -176,6 +180,10 @@ void ReadData()
|
|||||||
m_pCriticalSection->Leave();
|
m_pCriticalSection->Leave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (m_pWiiMote->event == WIIUSE_UNEXPECTED_DISCONNECT)
|
||||||
|
{
|
||||||
|
NOTICE_LOG(WIIMOTE, "wiiuse_io_read: unexpected disconnect. handle: %08x", m_pWiiMote->dev_handle);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -339,6 +347,8 @@ int Initialize()
|
|||||||
// and also connecting in Linux/OSX.
|
// and also connecting in Linux/OSX.
|
||||||
// Windows connects to Wiimote in the wiiuse_find function
|
// Windows connects to Wiimote in the wiiuse_find function
|
||||||
g_pReadThread = new Common::Thread(ReadWiimote_ThreadFunc, NULL);
|
g_pReadThread = new Common::Thread(ReadWiimote_ThreadFunc, NULL);
|
||||||
|
// Don't run the Wiimote thread if no wiimotes were found
|
||||||
|
g_Shutdown = false;
|
||||||
NeedsConnect.Set();
|
NeedsConnect.Set();
|
||||||
Connected.Wait();
|
Connected.Wait();
|
||||||
}
|
}
|
||||||
@ -384,10 +394,6 @@ int Initialize()
|
|||||||
wiiuse_read_data(g_WiiMotesFromWiiUse[i], data, 0, sizeof(WiiMoteEmu::EepromData_0));
|
wiiuse_read_data(g_WiiMotesFromWiiUse[i], data, 0, sizeof(WiiMoteEmu::EepromData_0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't run the Wiimote thread if no wiimotes were found
|
|
||||||
if (g_NumberOfWiiMotes > 0)
|
|
||||||
g_Shutdown = false;
|
|
||||||
|
|
||||||
// Initialized, even if we didn't find a Wiimote
|
// Initialized, even if we didn't find a Wiimote
|
||||||
g_RealWiiMoteInitialized = true;
|
g_RealWiiMoteInitialized = true;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user