Skip to content

Adds a library of TypeScript which provides simple, lowest-common-denominator gamepad input.

License

Notifications You must be signed in to change notification settings

SUNRUSE/dreck-gamepad-plugin

Repository files navigation

Dreck Gamepad Plugin License Renovate enabled

Adds a library of TypeScript which provides simple, lowest-common-denominator gamepad input.

Features

  • 1 two-axis joystick with click button, with deadzone, constrained to a circle.
  • Four face buttons (north, east, south, west).
  • Two digital shoulder buttons (L, R).
  • One pause button.

Compatibility

Controller Android - Chrome macOS - Chrome macOS - Firefox macOS - Safari Windows - Chrome Windows - Firefox
Keyboard Future Future Future Future Future Future
Joy-Con Impossible Future Impossible Future, partial Future Impossible
PowerA Wired Controller for Nintendo Switch Impossible Future Impossible Impossible Future Future
Wired Xbox 360 Controller Impossible Future Impossible Impossible Supported Supported
DualShock 4 Wireless Controller Unknown Unknown Unknown Unknown Future Future
DualSense Wireless Controller Future Future Future Future Future Future

Installation

Run the following in a Bash shell at the root of your project:

git submodule add https://github.com/sunruse/dreck-gamepad-plugin plugins/gamepad

Example

const gamepadManager = new GamepadManager();

// State will update ONLY when poll() is called.
gamepadManager.poll();

// 0...7.
console.log(gamepadManager.state[0]);
{
  "x": 0.707107,
  "y": 0.707107,
  "click": false,
  "north": false,
  "east": false,
  "west": false,
  "south": false,
  "left": false,
  "right": false,
  "pause": false
}

This will be null if no controller is connected in this slot.

About

Adds a library of TypeScript which provides simple, lowest-common-denominator gamepad input.

Resources

License

Stars

Watchers

Forks