mirror of
https://github.com/OleSTEEP/cordova-plugin-gamepad.git
synced 2026-11-21 23:03:35 +03:00
Gamepad API polyfill for Cordova/PhoneGap on Android gamepads
- Java 57%
- JavaScript 43%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src/android | ||
| test | ||
| www | ||
| .gitignore | ||
| LICENSE.md | ||
| package.json | ||
| plugin.xml | ||
| README.md | ||
Gamepad buttons plugin for Cordova/PhoneGap
By Vlad Stirbu.
This plugin allows you to use Android gamepads in Cordova/PhoneGap applications.
Adding the plugin to your project
Using Cordova command line interface:
cordova plugin add https://github.com/vstirbu/GamepadButtons
Adjust your MainActivity file from:
import org.apache.cordova.CordovaActivity;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
to:
import com.vladstirbu.cordova.CordovaActivity;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
Using the plugin
The javascript API follows the W3C Gamepad API, extended with elements from Mozilla Gamepad API.
Implementation status
Methods
- navigator.getGamepads()
Events
- window.gamepadconnected
- window.gamepadbutton
TODO
Currently, the plugin supports only the device's incorporated gamepad. External gamepads not supported.
The following events have not been implemented:
- gamepaddisconnected (not needed on the incorporated gamepad)
- gamepadaxismove (my development device does not have have analog joysticks)
Device experience
The plugin was tested on the following devices:
License
The plugin is available under MIT license.