Game Development Reference
In-Depth Information
Buttons in the Nunchuk will trigger core button events in the WiiC library.
Note
Finally, the Wiimote class uses the IController.IControllerListener interface to relay
messages back to the listener (see Listing 8-3).
Listing 8-3. Wii Controller Listener Interface
public static interface IControllerListener {
public void onButtonEvent( boolean pressed, int ascii, int scanCode);
public void connected();
public void disconnected(String reason);
public void onMessage(String message);
public void onJoystickEvent(float angleDeg, float distance);
}
This is the first component of your application. Now let's take a look at the native side of this
app, the WiiC library.
The WiiC Library
There are many libraries out there that provide Wii device connectivity (most of them based
on the same source). For instance, you could look at the Softwarebakery Wii libraries at:
http://softwarebakery.com/projects/wiidevicelibrary .
I tried them all, and of all those, WiiC appears to work best. The problem with WiiC and the
others is that they don't provide support for the new Wiimote (RVL-CNT-01-TR). So I had
to painfully figure out what was wrong and try to fix it. Thanks to the folks at WiiBrew I was
successful in this endeavor (the details of which I'll provide in the next sections). But first, to
make WiiC work with the new Wiimote, the following changes are required in the native side:
Handshake fixes : These are changes to the sockets used to send data
between the host and the controller.
Check for new device class : New Wiimotes use a different device class.
This is a type of ID used to identify the hardware among a plethora of
Bluetooth devices.
Other minor changes : These include report code changes and
miscellaneous changes to the Nunchuck handlers.
Fixes to the Handshake
When WiiC connects to the Wiimote it uses two sockets: the Control Pipe in port 11 and the
Data Pipe in port 13 (see Figure 8-7 ). In the old library, the Control Pipe was used to send
report requests to the controller.
 
Search WWH ::




Custom Search