Skip to content

Instantly share code, notes, and snippets.

@rpavlik
Created November 22, 2011 20:18
Show Gist options
  • Save rpavlik/0da060e5936046066c87 to your computer and use it in GitHub Desktop.
Save rpavlik/0da060e5936046066c87 to your computer and use it in GitHub Desktop.
diff --git a/src/wiiuse.c b/src/wiiuse.c
index 625afea..b4dd821 100644
--- a/src/wiiuse.c
+++ b/src/wiiuse.c
@@ -628,7 +628,6 @@ WIIUSE_DEBUG("chaud2fois");
* This function is not part of the wiiuse API.
*/
void wiiuse_send_next_pending_write_request(struct wiimote_t* wm) {
- byte buf[21] = {0}; /* the payload is always 23 */
struct data_req_t* req = wm->data_req;
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
@@ -640,28 +639,8 @@ void wiiuse_send_next_pending_write_request(struct wiimote_t* wm) {
if (!req)
return;
- WIIUSE_DEBUG("Writing %i bytes to memory location 0x%x...", req->len, req->addr);
-
- #ifdef WITH_WIIUSE_DEBUG
- {
- unsigned int i = 0;
- printf("Write data is: ");
- for (; i < req->len; ++i)
- printf("%x ", req->data[i]);
- printf("\n");
- }
- #endif
+ wiiuse_write_data(wm, req->addr, req->data, req->len);
- /* the offset is in big endian */
- *(int*)(buf) = BIG_ENDIAN_LONG(req->addr);
-
- /* length */
- *(byte*)(buf + 4) = req->len;//BIG_ENDIAN_SHORT(req->len);
-
- /* data */
- memcpy(buf + 5, req->data, req->len);
-
- wiiuse_send(wm, WM_CMD_WRITE_DATA, buf, 21);
req->state = REQ_SENT;
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment