Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niklashigi/gamepad-info
Retrieve information about a gamepad
https://github.com/niklashigi/gamepad-info
gamepad gamepad-api npm-package parser
Last synced: about 22 hours ago
JSON representation
Retrieve information about a gamepad
- Host: GitHub
- URL: https://github.com/niklashigi/gamepad-info
- Owner: niklashigi
- License: mit
- Created: 2018-01-17T21:05:56.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-12-29T15:29:45.000Z (almost 5 years ago)
- Last Synced: 2024-11-13T05:35:26.741Z (7 days ago)
- Topics: gamepad, gamepad-api, npm-package, parser
- Language: JavaScript
- Size: 146 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gamepad-info
> Retrieve information about a gamepad
[![build status][build-badge]][build-link]
[![npm][npm-badge]][npm-link]## Installation
```
$ npm install gamepad-info
```## Example
```js
const getGamepadInfo = require('gamepad-info')const gamepad = navigator.getGamepads()[0]
const gamepadName = getGamepadInfo(gamepad).name
console.log(`Your gamepad is called "${gamepadName}".`)
```## API
### getGamepadInfo(input)
Takes in a [`Gamepad` instance][gamepad-instance] or a [`gamepad.id` string][gamepad-id-string] and returns an object like this:
```js
{ name: 'Xbox 360 Wireless Receiver',
vendorId: '045e',
vendor: 'microsoft',
productId: '0719' }
```* `name` is the user-friendly name of the gamepad.
* `vendorId` is the vendor's [USB vendor ID][usb-vendor-id].
* `vendor` is the vendor's name and only available for [some vendors](vendors.js).
* `productId` is the ID of the product and might vary between browsers.## License
MIT © [Niklas Higi](https://shroudedcode.com)
[gamepad-instance]: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad
[gamepad-id-string]: https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/id
[usb-vendor-id]: https://en.wikipedia.org/wiki/USB_Implementers_Forum#Obtaining_a_vendor_ID[build-badge]: https://img.shields.io/travis/shroudedcode/gamepad-info.svg?style=flat-square
[build-link]: https://travis-ci.org/shroudedcode/gamepad-info[npm-badge]: https://img.shields.io/npm/v/gamepad-info.svg?style=flat-square
[npm-link]: https://www.npmjs.com/package/gamepad-info