fix Windows compilation, wiiuse_wait_report and wiiuse_probe_motion_plus
This commit is contained in:
12
src/io.c
12
src/io.c
@@ -122,13 +122,19 @@ void wiiuse_disconnect(struct wiimote_t* wm) {
|
||||
*/
|
||||
void wiiuse_wait_report(struct wiimote_t *wm, int report, byte *buffer, int bufferLength)
|
||||
{
|
||||
byte readReport;
|
||||
for(;;)
|
||||
{
|
||||
if(wiiuse_os_read(wm, buffer, bufferLength) > 0) {
|
||||
if(buffer[1] == report) {
|
||||
#ifdef WIIUSE_WIN32
|
||||
readReport = buffer[0];
|
||||
#else
|
||||
readReport = buffer[1];
|
||||
#endif
|
||||
if(readReport == report) {
|
||||
break;
|
||||
} else {
|
||||
WIIUSE_WARNING("(id %i) dropping report 0x%x, waiting for 0x%x", wm->unid, buffer[1], report);
|
||||
WIIUSE_WARNING("(id %i) dropping report 0x%x, waiting for 0x%x", wm->unid, readReport, report);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,7 +160,7 @@ void wiiuse_read(struct wiimote_t *wm, byte memory, unsigned addr, unsigned shor
|
||||
unsigned n_full_reports;
|
||||
unsigned last_report;
|
||||
byte *output;
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* address in big endian first, the leading byte will
|
||||
|
||||
@@ -47,11 +47,15 @@ void wiiuse_probe_motion_plus(struct wiimote_t *wm)
|
||||
{
|
||||
byte buf[MAX_PAYLOAD];
|
||||
unsigned id;
|
||||
unsigned short offset = 0;
|
||||
#ifdef WIIUSE_WIN32
|
||||
offset = 1;
|
||||
#endif
|
||||
|
||||
wiiuse_read(wm, 0, WM_EXP_MOTION_PLUS_IDENT, 6, buf);
|
||||
|
||||
/* check error code */
|
||||
if(buf[4] & 0x0f)
|
||||
if(buf[4-offset] & 0x0f)
|
||||
{
|
||||
WIIUSE_DEBUG("No Motion+ available, stopping probe.");
|
||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_MPLUS_PRESENT);
|
||||
@@ -59,7 +63,7 @@ void wiiuse_probe_motion_plus(struct wiimote_t *wm)
|
||||
}
|
||||
|
||||
/* decode the id*/
|
||||
id = from_big_endian_uint32_t(buf + 2);
|
||||
id = from_big_endian_uint32_t(buf + 2 - offset);
|
||||
|
||||
if(id != EXP_ID_CODE_INACTIVE_MOTION_PLUS &&
|
||||
id != EXP_ID_CODE_NLA_MOTION_PLUS &&
|
||||
|
||||
13
src/os_win.c
13
src/os_win.c
@@ -225,7 +225,7 @@ int wiiuse_os_read(struct wiimote_t* wm, byte* buf, int len) {
|
||||
if (r == WAIT_TIMEOUT) {
|
||||
/* timeout - cancel and continue */
|
||||
|
||||
if (*wm->event_buf)
|
||||
if (*buf)
|
||||
WIIUSE_WARNING("Packet ignored. This may indicate a problem (timeout is %i ms).", wm->timeout);
|
||||
|
||||
CancelIo(wm->dev_handle);
|
||||
@@ -238,6 +238,17 @@ int wiiuse_os_read(struct wiimote_t* wm, byte* buf, int len) {
|
||||
|
||||
if (!GetOverlappedResult(wm->dev_handle, &wm->hid_overlap, &b, 0))
|
||||
return 0;
|
||||
|
||||
#ifdef WITH_WIIUSE_DEBUG
|
||||
{
|
||||
int i;
|
||||
printf("[DEBUG] (id %i) RECV: (%x) ", wm->unid, buf[0]);
|
||||
for(i = 1; i < b; i++) {
|
||||
printf("%x ", buf[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ResetEvent(wm->hid_overlap.hEvent);
|
||||
|
||||
Reference in New Issue
Block a user