Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vdegenne/esm-gamecontroller.js
https://github.com/vdegenne/esm-gamecontroller.js
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/vdegenne/esm-gamecontroller.js
- Owner: vdegenne
- Created: 2023-06-01T17:56:32.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-03-16T09:22:44.000Z (10 months ago)
- Last Synced: 2024-03-16T10:56:12.396Z (10 months ago)
- Language: TypeScript
- Size: 120 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# 🎮 esm-gamecontroller.js
A esm port of [gamecontroller.js](https://github.com/alvaromontoro/gamecontroller.js).
All credit goes to:
- [@alvaromontoro](https://github.com/alvaromontoro): Original author of `gamecontroller.js`
- [@JumpLink](https://github.com/JumpLink): Author of the pull request [Migrate to Typescript #31](https://github.com/alvaromontoro/gamecontroller.js/pull/31) which is supposed to provide declaration types for the library.However the original author doesn't seem to be active anymore, so I took JumpLink TS version and made a build step to convert it to ESM which is recommended if you want to include the source in your final build anyway.
On top of that I wrote some mappings so it's easier to find a button and use them in functions, e.g.
```typescript
import {XBoxButton} from 'esm-gamecontroller.js';gamepad.on(XBoxButton.START, () => {
// ... pause the game or continue
})
```## Installation
```
npm add -D esm-gamecontroller.js
```## Usage
```typescript
import gameControl, { GCGamepad } from 'esm-gamecontroller.js';gameControl.on('connect', (gamepad: GCGamepad) => {
// May the types lead you young padawan...
})
```