Skip to content

luser/gamepadmapping.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

gamepadmapping.js is a JavaScript library for use with the Gamepad API. Unfortunately there's very little consistency between how different game controllers expose their buttons and axes, so it's hard to allow users to use the controllers they have without a tedious manual configuration step. The API does define a standard mapping and browser vendors do ship with mappings for some devices to map to the standard mapping, but it seems unlikely that there will ever be 100% coverage of devices in the wild, and users using new devices with slightly outdated browsers are still out of luck.

This library intends to help lessen the problem by providing easy access to a database of known controller mappings and remapping controllers that it knows about to the standard mapping.

Usage

This library provides two methods, exposed on window:

  • getGamepads(): Returns an Array of connected gamepads, as from navigator.getGamepads(), but with controls mapped to the standard mapping if possible.
  • remapGamepad(gamepad): Given a Gamepad object, remap it to the standard mapping if possible. If not possible the input gamepad will be returned.

About

A JavaScript library for the Gamepad API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published