Game Development Reference
In-Depth Information
// New Wiimote RVL-CNT-01-TR
#define WM_DEV_CLASS1_0 0x08
#define WM_DEV_CLASS1_1 0x05
#define WM_DEV_CLASS1_2 0x00
You now simply change the if statement within the for loop in Listing 8-5 to account for the
new device classes; thus Listing 8-5 becomes Listing 8-6.
Listing 8-6. Changes to io_nix.c (wiic_find) to Check for the New Wiimote
/* display discovered devices */
for (; (i < found_devices) && (found_wiimotes < max_wiimotes); ++i) {
if ( ((scan_info[i].dev_class[0] == WM_DEV_CLASS_0) &&
(scan_info[i].dev_class[1] == WM_DEV_CLASS_1) &&
(scan_info[i].dev_class[2] == WM_DEV_CLASS_2))
||
// RVL-CNT-01-TR
((scan_info[i].dev_class[0] == WM_DEV_CLASS1_0) &&
(scan_info[i].dev_class[1] == WM_DEV_CLASS1_1) &&
(scan_info[i].dev_class[2] == WM_DEV_CLASS1_2))
)
{
/* found a wiimote */
++found_wiimotes;
}
}
Other Changes
Finally, here are some minor changes to get things working:
The set report code must be changed from 0x50 to 0xA0 within
wiic_internal.h .
// OLD #define WM_SET_REPORT 0x50
#define WM_SET_REPORT 0xA0
WM_RPT_WRITE ) must be changed to a WM_RPT_ACK .
This is required because after an input report is received, an
acknowledgment (ACK) must be sent back to the Wiimote (again in
wiic_internal.h ).
The report write code (
// OLD #define WM_RPT_WRITE 0x22
#define WM_RPT_ACK 0x22
As you can see, the report code remains the same (0x22) but it has been renamed to
WM_RPT_ACK ; obviously you need an implementation of this ACK event within events.c
(see Listing 8-7).
 
Search WWH ::




Custom Search