Skip to content

A Cordova plugin to handle the HTML5 gamepad API for iOS and Android

Notifications You must be signed in to change notification settings

judax/cordova-plugin-gamepad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#cordova-plugin-gamepad

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 gamepadconnected and 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.

##How to use it

###Setup your Cordova project and install the plugin

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).

  1. Install the Cordova CLI: https://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html

  2. Create a Cordova project and add the desired platforms (remember that this plugin works for iOS and Android for now only): https://cordova.apache.org/docs/en/3.0.0/guide_cli_index.md.html

  3. Install the plugin with the following command line:

    cordova plugin add com.judax.cordova.plugin.gamepad

###Modifications in your application

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];

##Future improvements

##Additional references

About

A Cordova plugin to handle the HTML5 gamepad API for iOS and Android

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published