Tags: Game and Graphics
Android game developers using NVIDIA’s Tegra Android Developer Pack sample code have known for over a year and a half that Android can support all game controller buttons and axes in pure native (C/C++) code. But until now, developers wanting to access the all-important analog axes on those controllers had to manually query non-NDK (i.e. non “stable”) APIs from Android libraries at runtime. In addition to being a bit of an inconvenience to query the function needed, there was always the chance that a later version of Android would change that API and break existing games (since the function was not officially exported to the NDK). Well, that has all changed for the better with the release of the r9b version of the NDK. Android now supports the previously-missing game controller functions.
The better news is that existing apps that used NVIDIA’s sample code should work on Android KitKat with no modifications whatsoever. So existing controller-based apps should keep working just fine. Apps upgrading to the NDK’s new r9b release can now replace calls to the queried function pointer with direct calls to the Android function AMotionEvent_getAxisValue. They can remove their use of the TADP nv_input sample library, as the #defines in that header are now in the NDK’s android/input.h.
Better yet is that Google made this change retroactive; in other words, NDK r9b actually added declarations and linkable symbols for the missing functions in all API levels 13 and newer, the exact set of OSes that always had the functions (internally) in the first place. So by moving to using the Android-exported versions of the functions you need not change your call signatures and you need not raise your targeted or min application API spec!
This upgrade in NDK r9b does indeed make the longstanding TADP sample library nv_input redundant; the function it queried at runtime from Android can now be linked at built time in the NDK. We’ll be updating our existing NativeGamepad app in the next version of TADP to remove its dependency on nv_input and removing the library from TADP. Having the NDK making this TADP helper library redundant is a good thing for everyone! We couldn’t be happier – anything that makes it easier for apps to add great controller support to their Android apps is music to our ears.