Game Development Reference
In-Depth Information
Now you can start writing code that connects to your Zeemote. First, you must download
the SDK with the libraries required to enable it in your app. The latest Zeemote SDK is
available online at http://devzone.zeemote.com:8088/devzone/account/devInfo . Download
them and put under the libs directory of your project.
The required JARs for the Zeemote SDK 1.9.2 are:
ZControllerLib-android-1.9.2.jar
ZControllerLib-android-ui-1.9.2.jar
ZControllerLib-common-1.9.2.jar
zc-strings-1.9.2.jar
It also includes the native libZControllerLib_Android.so . You will need to include all these
files in the app you wish to enable the Zeemote.
Listing 8-14 shows the simple class of Zeemote that connects to a controller and listens for
status, button, and joystick events. The steps can be summarized as follows.
Create an instance of Controller by calling new
Controller(Controller.CONTROLLER_1) . This object is used to
interface with the device.
1.
2.
Listen for controller events by implementing any of the API interfaces:
IStatusListener : This interface fires the events
batteryUpdate(BatteryEvent) , which gives information about power levels;
connected(ControllerEvent) , which fires when the controller is successfully
connected; and disconnected(DisconnectEvent) , which fires when a
disconnection occurs.
IButtonListener : This interface fires the events
buttonPressed(ButtonEvent) or buttonPressed(ButtonEvent) whenever any
of the four buttons is pressed and released.
IJoystickListener : This interface fires the event
joystickMoved(JoystickEvent) , which gives the scaled XY coordinated of
the joystick.
3.
Handle the above events accordingly.
Listing 8-14. Class to Connect a Zeemote
public class Zeemote implements IStatusListener, IJoystickListener,
IButtonListener
{
private static final String TAG = "Zeemote";
private Controller mZeeController;
private Context mContext;
public Zeemote(Context context) {
mContext = context;
mZeeController = new Controller(Controller.CONTROLLER_1);
 
Search WWH ::




Custom Search