Game Development Reference
In-Depth Information
Listing 8-7. Event ACK Implementation
static void event_ack(struct wiimote_t *wm, byte *msg)
{
wiic_pressed_buttons(wm,msg);
WIIC_DEBUG("Event ACK [%02x %02x %02x %02x]", msg[0], msg[1], msg[2], msg[3]);
wm->event = WIIC_ACK;
/* if another request exists send it to the wiimote */
if (wm->read_req)
wiic_send_next_pending_read_request(wm);
}
void propagate_event(struct wiimote_t* wm, byte event, byte* msg) {
// ...
switch (event) {
// ...
case WM_RPT_ACK:
{
/* Vladimir ACK */
event_ack(wm, msg);
return;
}
// ...
}
event_ack gets propagated within the main event handler in events.c . Hold on; you're
almost done.
Fixes to the Nunchuk Handler
Finally, if you wish to support a Nunchuck (very useful for first-person shooters), its
handshake logic must be slightly altered. The expansion ID for the Nunchuck in the new
Wiimote has changed, so the code must be changed to reflect this. The following fragment
has been taken from the file wiic_internal.h :
#define EXP_ID_CODE_NUNCHUK 0x9A1EFEFE
#define EXP_ID_CODE_NUNCHUK_TR01 0xA4200000
It includes an expansion ID for the new Nunchuk ( EXP_ID_CODE_NUNCHUK_TR01 with the
value 0xA4200000 ). Furthermore, the Nunchuck event data sent by the new Wiimote is
now unencrypted. So locate the nunchuk.c file and see how the decryption logic has been
commented out, as shown in the following fragment:
int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, unsigned short
len) {
/* decrypt data - old wiimotes only*/
/*
for (i = 0; i < len; ++i)
 
Search WWH ::




Custom Search