Game Development Reference
In-Depth Information
wii = new Wiimote(this);
wii.setListener(new IController.IControllerListener() {
@Override
public void onButtonEvent(boolean pressed, int ascii, int scanCode) {
Log.d(TAG, "Event pressed=" + pressed + " ASCII=" + ascii + " sc="
+ scanCode);
postLog("Event pressed=" + pressed + " ASCII=" + ascii);
}
@Override
public void disconnected(String reason) {
Log.e(TAG, "Disconnected from wiimote");
postLog("Disconnected: " + reason);
}
@Override
public void connected() {
Log.d(TAG, "Connected to wiimote");
postLog("Connected to wiimote");
}
@Override
public void onMessage(String message) {
postLog(message);
}
@Override
public void onJoystickEvent(float angleDeg, float distance) {
}
});
}
Listing 8-1 also shows how to create a Wiimote controller and listen for events by declaring
an instance of IController and setting a controller listener, as shown in the next fragment:
IController wii;
wii = new Wiimote(this);
wii.setListener(new IController.IControllerListener() {
public void onButtonEvent(boolean pressed, int ascii, int scanCode) {
}
public void disconnected(String reason) {
}
public void connected() {
}
public void onMessage(String message) {
}
public void onJoystickEvent(float angleDeg, float distance) {
}
});
 
Search WWH ::




Custom Search