int wiiuse_write_data(struct wiimote_t *wm,uint addr,ubyte *data,ubyte len,cmd_blk_cb cb) { struct op_t *op; struct cmd_blk_t *cmd; if(!wm || !WIIMOTE_IS_CONNECTED(wm)) return 0; if(!data || !len) return 0; cmd = (struct cmd_blk_t*)__lwp_queue_get(&wm->cmdq); if(!cmd) return 0; cmd->cb = cb; cmd->len = 22; op = (struct op_t*)cmd->data; op->cmd = WM_CMD_WRITE_DATA; op->buffer = NULL; op->wait = 0; op->writedata.addr = BIG_ENDIAN_LONG(addr); op->writedata.size = (len&0x0f); memcpy(op->writedata.data,data,len); memset(op->writedata.data+len,0,(16 - len)); __wiiuse_push_command(wm,cmd); return 1; }
//Get the first event of the event queue s32 MOUSE_getEvent(mouseEvent* event) { mousenode *n = (mousenode*) __lwp_queue_get(mousequeue); if (!n) return 0; *event = n->event; // CTS free(n); return 1; }
//Get the first event of the event queue s32 KEYBOARD_getEvent(keyboardEvent* event) { node *n = (node*) __lwp_queue_get(queue); if (!n) return 0; *event = n->event; // CTS free(n); return 1; }
int wiiuse_sendcmd(struct wiimote_t *wm,ubyte report_type,ubyte *msg,int len,cmd_blk_cb cb) { struct cmd_blk_t *cmd; cmd = (struct cmd_blk_t*)__lwp_queue_get(&wm->cmdq); if(!cmd) return 0; cmd->cb = cb; cmd->len = (1+len); cmd->data[0] = report_type; memcpy(cmd->data+1,msg,len); __wiiuse_push_command(wm,cmd); return 1; }
int wiiuse_write_streamdata(struct wiimote_t *wm,ubyte *data,ubyte len,cmd_blk_cb cb) { struct cmd_blk_t *cmd; if(!wm || !WIIMOTE_IS_CONNECTED(wm)) return 0; if(!data || !len || len>20) return 0; cmd = (struct cmd_blk_t*)__lwp_queue_get(&wm->cmdq); if(!cmd) return 0; cmd->cb = cb; cmd->len = 22; cmd->data[0] = WM_CMD_STREAM_DATA; cmd->data[1] = (len<<3); memcpy(cmd->data+2,data,len); __wiiuse_push_command(wm,cmd); return 1; }
int wiiuse_read_data(struct wiimote_t *wm,ubyte *buffer,uint addr,uword len,cmd_blk_cb cb) { struct op_t *op; struct cmd_blk_t *cmd; if(!wm || !WIIMOTE_IS_CONNECTED(wm)) return 0; if(!buffer || !len) return 0; cmd = (struct cmd_blk_t*)__lwp_queue_get(&wm->cmdq); if(!cmd) return 0; cmd->cb = cb; cmd->len = 7; op = (struct op_t*)cmd->data; op->cmd = WM_CMD_READ_DATA; op->buffer = buffer; op->wait = len; op->readdata.addr = BIG_ENDIAN_LONG(addr); op->readdata.size = BIG_ENDIAN_SHORT(len); __wiiuse_push_command(wm,cmd); return 1; }