Game Development Reference
In-Depth Information
The Java classes of this project are
WiiTestActivity : This is the entry point to your application. It is in
charge of loading the GUI XML layout, creating a Wii controller object,
and interacting with the Wiimote.
IController : This is an interface designed to wrap the Wiimote calls in
a single unity. This will allow you to implement many types of controllers
(not just Wiimotes) such as Zeemotes, PS3 Sixaxis, and more. By
implementing this simple interface you can easily add support for a variety
of Bluetooth controllers. IController defines the following methods:
connect() : This method starts the connection process to the Bluetooth
device.
disconnect() : This method disconnects from the controller.
isConnected() : This method tells you if there is an active connection.
setListener(IController.IControllerListener listener) : This method
sets an event listener used to notify clients of events occurred in the
controller.
IController.IControllerListener : This is an interface within IController
that can be used to notify clients of controller events such as
onButtonEvent( boolean pressed, int ascii, int scanCode) : This method
fires when a button is pressed in the controller. It gives the state of the
button (pressed or released) plus an ASCII and scan code mapping, which
can be used to interact with a native game engine.
connected() : This event fires on successful connection to the Wiimote.
disconnected(String reason) : This event fires when the connection has
failed. A failure reason is given.
onMessage(String message) : This is more of a help message to let the host
know what is going on behind the scenes.
onJoystickEvent(float angleDeg, float distance) : This event fires when
there is joystick event, such as when the Nunchuck extension is plugged to
the Wiimote.
Wiimote : This class is in charge of interacting with the native WiiC
library. It loads the native library and provides a set of native methods to
interact with the native side. See the native component of the project
(“The WiiC Library”) for more details.
In the next section, you'll look at Java classes in more detail staring with WiitestActivity
and working your way down to Wiimote (where all the meat resides). But first, let's take a
look at the user interface of the application (see Figure 8-6 ).
 
Search WWH ::




Custom Search