This short development tutorial teaches you the basics of how to integrate and initialize wiigee. Overall, the event-driven architecture of the library makes it very easy to integrate it into your current project. However, the download section also offers you a small but complete demo application demonstrating how the library could be used. This tutorial covers this basic code.
Four major steps will suffice to integrate wiigee into an existing project.
1 – Add wiigee to your project
First, add the wiigee jar-file to the classpath of your project. For example, in Eclipse this is done via the java build path tab in the project properties. Afterwards, make at least it’s control-class accessible via a common import-command like
Note, that you may also need to integrate a JSR-82 Bluetooth implementation in the same way. We used the avetana Bluetooth library in our case but successfully tested BlueCove as well.
2 – Get a Wiigee instance
Set up a
wiigee-object by getting an instance via:
WiimoteWiigee wiigee = new WiimoteWiigee();
3 – Set up buttons for the training and recognition process (optional)
There are three buttons you have to configure in order to control the flow of the training and the recognition process. The TrainButton starts the recording process for a single gesture and has to be held down during recording. If enough gestures are recorded, a CloseGestureButton finishes the gesture recording session. To initiate a recognition process, you have to press and hold the RecognitionButton during movement of the wiimote. The system starts to recognize your gesture after you've released this button. For more information on this, consult the Background-section.
Set the three buttons up via (this is the default configuration):
4 – Set up event listeners
In order to be informed when a button on your wiimote was pressed or to get pure motion acceleration data, your class has to implement the interface
WiimoteListener. Analogously, if you want to be informed when a specific gesture occured, your class has to implement the interface
GestureListener. Let's assume that
myguiis the class implementing these interfaces. You then have to add this class as the appropriate listener to your
That's all. The only thing left to do is making the wiimote discoverable during the execution of your application. You do this by pressing the wiimote buttons and at once. If your wiimote connected successfully, use the configured buttons (see step 3) to start the training or the recognition process. You are now able to perform gesture recognition with your wiimote. For further information, consult the Background-section and the JavaDoc. Have fun!