https://github.com/aaronkirkham/vue-gamepad
🎮 A Vue.js plugin to add gamepad support. Bind any element to trigger a callback when a gamepad button is pressed.
https://github.com/aaronkirkham/vue-gamepad
gamepad javascript vue
Last synced: 10 months ago
JSON representation
🎮 A Vue.js plugin to add gamepad support. Bind any element to trigger a callback when a gamepad button is pressed.
- Host: GitHub
- URL: https://github.com/aaronkirkham/vue-gamepad
- Owner: aaronkirkham
- License: mit
- Created: 2018-04-18T19:40:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:36:16.000Z (over 3 years ago)
- Last Synced: 2024-12-06T22:44:17.374Z (over 1 year ago)
- Topics: gamepad, javascript, vue
- Language: JavaScript
- Homepage:
- Size: 830 KB
- Stars: 18
- Watchers: 2
- Forks: 4
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

vue-gamepad
A Vue.js plugin to add gamepad support. Bind any element to trigger a callback when a gamepad button is pressed.
## Installation
#### npm/yarn
```bash
$ npm install vue-gamepad
# or with yarn
$ yarn add vue-gamepad
```
#### CDN
https://unpkg.com/vue-gamepad/dist/vue-gamepad.min.js
## Usage
Tell Vue to use the plugin
```js
import Vue from 'vue';
import VueGamepad from 'vue-gamepad';
Vue.use(VueGamepad);
```
Example usage inside templates:
```html
Press me!
```
## Constructor Options
|Key|Description|Default|Type|
|:---|---|---|---|
|`analogThreshold`|Threshold before analog events are triggered. Low values may cause false positives|`0.5`|`Number`|
|`buttonMapping`|List of strings containing button indices|[Mapping](lib/button-mapping.js#L1)|`Array`|
|`buttonInitialTimeout`|Time (in milliseconds) until the button will start repeating when held down|`200`|`Number`|
|`buttonRepeatTimeout`|Time (in milliseconds) between each button repeat event when held down|`200`|`Number`|
|`injectClasses`|Add classes to elements which have a gamepad binding|`true`|`Boolean`|
## Directives
- `v-gamepad` - Bind an element to a gamepad action which will fire a callback
- `released` modifier - Only fire the callback when the button is released
- `repeat` modifier - Repeatedly fire the callback when the button is held
- ~~`v-gamepad-layer` - TODO~~
- ~~`v-gamepad-json` - Pass a raw object of buttons, actions and callbacks to bind~~
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details