Use SetEvent instead of CancelIoEx for XP compatibility.

This commit is contained in:
comex 2013-09-07 15:43:17 -04:00
parent 508888c935
commit f4586570ac
1 changed files with 8 additions and 12 deletions

View File

@ -560,7 +560,7 @@ bool Wiimote::IsConnected() const
void _IOWakeup(HANDLE &dev_handle, OVERLAPPED &hid_overlap_read) void _IOWakeup(HANDLE &dev_handle, OVERLAPPED &hid_overlap_read)
{ {
CancelIoEx(dev_handle, &hid_overlap_read); SetEvent(hid_overlap_read.hEvent);
} }
// positive = read packet // positive = read packet
@ -582,26 +582,22 @@ int _IORead(HANDLE &dev_handle, OVERLAPPED &hid_overlap_read, u8* buf, int index
if (ERROR_IO_PENDING == read_err) if (ERROR_IO_PENDING == read_err)
{ {
auto const wait_result = WaitForSingleObject(hid_overlap_read.hEvent, INFINITE); auto const wait_result = WaitForSingleObject(hid_overlap_read.hEvent, INFINITE);
if (WAIT_TIMEOUT == wait_result)
{ // In case the event was signalled by _IOWakeup before the read completed, cancel it.
CancelIo(dev_handle); CancelIo(dev_handle);
}
else if (WAIT_FAILED == wait_result) if (WAIT_FAILED == wait_result)
{ {
WARN_LOG(WIIMOTE, "A wait error occurred on reading from Wiimote %i.", index + 1); WARN_LOG(WIIMOTE, "A wait error occurred on reading from Wiimote %i.", index + 1);
CancelIo(dev_handle);
} }
if (!GetOverlappedResult(dev_handle, &hid_overlap_read, &bytes, TRUE)) if (!GetOverlappedResult(dev_handle, &hid_overlap_read, &bytes, FALSE))
{ {
auto const overlapped_err = GetLastError(); auto const overlapped_err = GetLastError();
if (ERROR_OPERATION_ABORTED == overlapped_err) if (ERROR_OPERATION_ABORTED == overlapped_err)
{ {
/* // It was.
if (buf[1] != 0)
WARN_LOG(WIIMOTE, "Packet ignored. This may indicate a problem.");
*/
return -1; return -1;
} }