Game Development Reference
In-Depth Information
After compilation, the file libwiimote.so will be created in the project libs/armeabi folder.
Listing 8-13 shows the Android make file for WiiC.
Listing 8-13. Android Make File for the WiiC Library
LOCAL_MODULE := wiimote
DIR := WiiCNew/src/wiic
SOURCES := $(DIR)/balanceboard.c $(DIR)/classic.c \
$(DIR)/dynamics.c $(DIR)/events.c \
$(DIR)/io.c $(DIR)/io_nix.c \
$(DIR)/ir.c $(DIR)/nunchuk.c \
$(DIR)/guitar_hero_3.c $(DIR)/speaker.c \
$(DIR)/motionplus.c $(DIR)/wiic.c \
android/jni_wiic.c android/jni_wiic_handlers.c \
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/$(DIR)
LOCAL_CFLAGS := -DLINUX -DANDROID
LOCAL_SRC_FILES := $(SOURCES)
LOCAL_LDLIBS := -L$(LOCAL_PATH)/lib -Ljni/lib -llog -lbluetooth
include $(BUILD_SHARED_LIBRARY)
Note that the compilation script requires the Bluetooth headers files to be included in
your project, plus the linking step requires the libbluetooth.so file to succeed. Both
things are missing from the NDK since native Bluetooth is not considered a stable API
by Google. Fortunately, Android uses the standard BlueZ Bluetooth stack from which the
Bluetooth headers can be obtained (I have already included both the Bluetooth headers and
libbluetooth.so in the companion source code).
Tip libbluetooth.so required for the linking step can be obtained from a real device. Connect
the device to your PC using the USB cable, open a DOS prompt, and issue the command
adb pull /system/lib/libbluetooth.so
This will extract the library from the device into the current working folder.
You are now ready to test. Connect your phone to the USB port of your laptop and run the
app. From the Eclipse menu, click Run ➤ Run Configurations, type a new name, select the
Wiimote project from the topic source code, and click Run. Figure 8-9 shows the app in
action using the Android emulator.
 
 
Search WWH ::




Custom Search