static void cwiid_callback(cwiid_wiimote_t *wiimote, int mesg_count, union cwiid_mesg mesg_array[], struct timespec *timestamp) { int i; t_wiimote *x=NULL; double pd_timestamp=0; // print_timestamp(timestamp, NULL); if(g_wiimoteList==NULL||wiimote==NULL) { post("no wii's known"); return; } x=getWiimoteObject(cwiid_get_id(wiimote)); if(NULL==x) { post("no wiimote loaded: %d%",cwiid_get_id(wiimote)); return; } pd_timestamp=wiimote_timestamp2logicaltime(x, timestamp); sys_lock(); for (i=0; i < mesg_count; i++) { #if 1 wiimote_queue(x, mesg_array+i, pd_timestamp); #else wiimote_cwiid_message(x, mesg_array+i); #endif } sys_unlock(); }
static void wiiproto_req_drm(struct wiimote_data *wdata, __u8 drm) { __u8 cmd[3]; if (drm == WIIPROTO_REQ_NULL) drm = select_drm(wdata); cmd[0] = WIIPROTO_REQ_DRM; cmd[1] = 0; cmd[2] = drm; wiimote_queue(wdata, cmd, sizeof(cmd)); }
static void wiiproto_req_leds(struct wiimote_data *wdata, int leds) { __u8 cmd[2]; leds &= WIIPROTO_FLAGS_LEDS; if ((wdata->state.flags & WIIPROTO_FLAGS_LEDS) == leds) return; wdata->state.flags = (wdata->state.flags & ~WIIPROTO_FLAGS_LEDS) | leds; cmd[0] = WIIPROTO_REQ_LED; cmd[1] = 0; if (leds & WIIPROTO_FLAG_LED1) cmd[1] |= 0x10; if (leds & WIIPROTO_FLAG_LED2) cmd[1] |= 0x20; if (leds & WIIPROTO_FLAG_LED3) cmd[1] |= 0x40; if (leds & WIIPROTO_FLAG_LED4) cmd[1] |= 0x80; wiimote_queue(wdata, cmd, sizeof(cmd)); }