[mac]wiiuse_io_read: Add buffer and length parameters
-According to the new signature for wiiuse_io_read
This commit is contained in:
@@ -206,7 +206,7 @@ int wiiuse_poll(struct wiimote_t** wm, int wiimotes) {
|
|||||||
for (i = 0; i < wiimotes; ++i) {
|
for (i = 0; i < wiimotes; ++i) {
|
||||||
wm[i]->event = WIIUSE_NONE;
|
wm[i]->event = WIIUSE_NONE;
|
||||||
|
|
||||||
if (wiiuse_io_read(wm[i])) {
|
if (wiiuse_io_read(wm[i],wm[i]->event_buf,sizeof(wm[i]->event_buf))) {
|
||||||
/* propagate the event, messages should be read as in linux, starting from the second element */
|
/* propagate the event, messages should be read as in linux, starting from the second element */
|
||||||
propagate_event(wm[i], wm[i]->event_buf[1], wm[i]->event_buf+2);
|
propagate_event(wm[i], wm[i]->event_buf[1], wm[i]->event_buf+2);
|
||||||
evnt += (wm[i]->event != WIIUSE_NONE);
|
evnt += (wm[i]->event != WIIUSE_NONE);
|
||||||
@@ -214,6 +214,9 @@ int wiiuse_poll(struct wiimote_t** wm, int wiimotes) {
|
|||||||
/* clear out the event buffer */
|
/* clear out the event buffer */
|
||||||
memset(wm[i]->event_buf, 0, sizeof(wm[i]->event_buf));
|
memset(wm[i]->event_buf, 0, sizeof(wm[i]->event_buf));
|
||||||
} else {
|
} else {
|
||||||
|
/* send out any waiting writes */
|
||||||
|
wiiuse_send_next_pending_write_request(wm[i]);
|
||||||
|
|
||||||
idle_cycle(wm[i]);
|
idle_cycle(wm[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/io_mac.m
10
src/io_mac.m
@@ -663,7 +663,7 @@ int wiiuse_load(struct wiimote_t** wm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Defined in io.h
|
// Defined in io.h
|
||||||
int wiiuse_io_read(struct wiimote_t* wm)
|
int wiiuse_io_read(struct wiimote_t* wm, byte* buf, int len)
|
||||||
{
|
{
|
||||||
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
|
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -723,12 +723,12 @@ int wiiuse_io_read(struct wiimote_t* wm)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forward to WiiC
|
// Forward to the parameter buffer
|
||||||
if(length < sizeof(wm->event_buf))
|
if(length <= len)
|
||||||
memcpy(wm->event_buf,buffer,length);
|
memcpy(buf,buffer,length);
|
||||||
else {
|
else {
|
||||||
WIIUSE_DEBUG("Received data are more than the buffer.... strange! (id %i)", wm->unid);
|
WIIUSE_DEBUG("Received data are more than the buffer.... strange! (id %i)", wm->unid);
|
||||||
memcpy(wm->event_buf,buffer,sizeof(wm->event_buf));
|
memcpy(buf,buffer,len);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the consumed message
|
// Release the consumed message
|
||||||
|
|||||||
Reference in New Issue
Block a user