A Cordova plugin to handle the HTML5 gamepad API for iOS and Android. This plugin injects the
navigator.getGamepads function into the system along with the
gamepaddisconnected events into the window event management making any Cordova application to be able to use the underlying game controllers in the system with the same standard API. If the gamepad API is already available (the underlying Cordova webview already supports it) no modifications are made.
This plugin has been published in the Cordova Plugin Registry (Plugman) so adding it to any Cordova project version 3.0 and above can be done using the Cordova Command Line Interface (CLI).
Install the plugin with the following command line:
cordova plugin add com.judax.cordova.plugin.gamepad
No modifications are needed in your app in order to be able use this plugin. Of course, you need to use the HTML5 Gamepad API as it is shown in the specification (http://www.w3.org/TR/gamepad/).
NOTE: The current version is not 100% compliant with the latest version of the W3C Gamepad API spec. It is based on a previous spec version that did not include the GamepadButton interface, so the recommendation is to use the following conditional when querying for gamepad button data:
if (typeof gamepad.buttons[j]["value"] !== "undefined") value = gamepad.buttons[j]["value"]; else value = gamepad.buttons[j];
Add support for Gamepad on Android bellow 2.3. There might be some problems to do this as a brief overlook to the needs state that access to the main activity/view might be needed. More information at: http://developer.android.com/training/game-controllers/compatibility.html
Improve the documentation of (and maybe even refactor) the native source code for both iOS and Android.
GamepadButton structure as the final W3C Gamepad specification states (http://www.w3.org/TR/gamepad/).