Game Development Reference
In-Depth Information
This has been an introduction on how the Wiimote works. Now let's put this knowledge to
the test. In the next section you will create an Android app to perform the following tasks:
Connect or disconnect to the Wiimote and display information about the
handshake process.
Send typical commands such as turning LEDs on or off, or making it
rumble.
Display information when buttons are pressed/released as well as
joystick data (if you have a Nunchuk).
Let's continue.
A Wiimote Controller App
This section covers the Wiimote Android app in detail, which is made of three main
components:
An Android project : This contains the Java activity and GUI window that
can be run to connect and interact with the Wiimote.
A native library : This component uses a modified version of the open
source WiiC library (available online at http://wiic.sourceforge.net/ )
to control Wii devices natively. I should mention that the standard WiiC
library does not support the latest Wiimote; I have made changes to the
original to get it working.
A WiiC JNI interface : This is a small C program that binds WiiC library
calls with the Wiimote Java class of your app, thus allowing for WiiC
access within your Java code. It is the glue that binds the previous
components together.
Let's create an Android project to host your app (the full source is available from the topic's
companion media).
The Wiimote Android Project
Perform the following steps to create the skeleton for the Wiimote controller app.
1.
From the Eclipse main menu, click File ➤ New ➤ Project, then expand
the Android tree and select Android Application Project (see Figure 8-3 ).
Click Next.
 
Search WWH ::




Custom Search