
Are you a game developer? The new Xperia™ PLAY features an analog touch pad for full gaming experiences. And the good thing is, you will be able to utilize it for your games too! You can use native code, that is, code written in C or C++, in conjunction with the Android™ Native Development Kit (NDK) to access touch events from the Xperia™ PLAY touch pad. Please note that you cannot use the Android SDK to access these touch events.
There are two important elements in using native code to handle touch events from the Xperia™ PLAY touch pad: the NDK and the NativeActivity class in the Android SDK. The NDK lets you create native code for your Android application. The NativeActivity class enables you to write an Android activity in native code. In addition, the NativeActivity class handles the communication between the Android framework and your native code. However, because the native activity runs on the same thread as your Android application, you’ll need to take actions in your code to prevent the native activity from blocking the application. This could force you into some tricky thread synchronization operations.
But there’s a solution. The NDK offers a static helper library named native-app-glue that handles the thread creation for you. Beyond that, the helper library interface provides a facility called a looper that listens for activity lifecycle events as well as input events coming from the input queue attached to the activity.
See how simple it is to use the native-app-glue library and the looper to detect and process touch events from the Xperia™ PLAY touch pad. Download the full tutorial below and find out.
More information:
Sort by