https://github.com/vstirbu/gamepadbuttons
Gamepad API polyfill for Cordova/PhoneGap on Android gamepads
https://github.com/vstirbu/gamepadbuttons
Last synced: 5 months ago
JSON representation
Gamepad API polyfill for Cordova/PhoneGap on Android gamepads
- Host: GitHub
- URL: https://github.com/vstirbu/gamepadbuttons
- Owner: vstirbu
- License: mit
- Created: 2012-12-24T11:05:45.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2020-09-30T17:34:35.000Z (about 5 years ago)
- Last Synced: 2025-04-09T14:03:36.161Z (6 months ago)
- Language: Java
- Homepage:
- Size: 24.4 KB
- Stars: 3
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Gamepad buttons plugin for Cordova/PhoneGap
By [Vlad Stirbu](https://github.com/vstirbu).
This plugin allows you to use Android gamepads in Cordova/PhoneGap applications.
## Adding the plugin to your project
Using Cordova [command line interface](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-Line%20Interface):
```bash
cordova plugin add https://github.com/vstirbu/GamepadButtons
```Adjust your `MainActivity` file from:
```java
import org.apache.cordova.CordovaActivity;public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by in config.xml
loadUrl(launchUrl);
}
}
```to:
```java
import com.vladstirbu.cordova.CordovaActivity;public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by in config.xml
loadUrl(launchUrl);
}
}
```## Using the plugin
The javascript API follows the [W3C Gamepad API](https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html), extended with elements from [Mozilla Gamepad API](https://developer.mozilla.org/en-US/docs/API/Gamepad/Using_Gamepad_API).
### Implementation status
#### Methods
* navigator.[getGamepads](https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#idl-def-Navigator)()
#### Events
* window.[gamepadconnected](https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#the-gamepadconnected-event)
* window.[gamepadbutton](https://developer.mozilla.org/en-US/docs/Web/Guide/API/Gamepad?redirectlocale=en-US&redirectslug=API%2FGamepad%2FUsing_Gamepad_API#nslDOMGamepadButtonEvent)#### TODO
Currently, the plugin supports only the device's incorporated gamepad. External gamepads not supported.
The following events have not been implemented:
* [gamepaddisconnected](https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#the-gamepaddisconnected-event) (not needed on the incorporated gamepad)
* [gamepadaxismove](https://developer.mozilla.org/en-US/docs/Web/Guide/API/Gamepad?redirectlocale=en-US&redirectslug=API%2FGamepad%2FUsing_Gamepad_API#nslDOMGamepadAxisMoveEvent) (my development device does not have have analog joysticks)## Device experience
The plugin was tested on the following devices:
* [JXD s5110](http://www.jxd.hk/products.asp?id=611&selectclassid=009006)
* [JXD s5110B](http://www.jxd.hk/game-console/s5110b/)
* [JXD S7800B](http://www.jxd.hk/game-console/s7800b/)## License
The plugin is available under MIT license.