API Docs for: v0.1.0
Show:

Gamepad Class

Extends Input

Controls input from gamepads

Constructor

Gamepad

()

Methods

emit

(
  • type
  • data
)
Mixed chainable

Emits an event which will run all registered listeners for the event type

Parameters:

  • type String

    The event name to emit

  • data Mixed

    Any data you want passed along with the event

Returns:

Mixed:

Returns itself.

off

(
  • type
  • listener
)
Mixed chainable

Removes a listener function for an event type

Parameters:

  • type String

    The event name to emit

  • listener Function

    The function to remove

Returns:

Mixed:

Returns itself.

on

(
  • type
  • listener
)
Mixed chainable

Registers a listener function to be run on an event occurance

Parameters:

  • type String

    The event name to listen for

  • listener Function

    The function to execute when the event happens

Returns:

Mixed:

Returns itself.

once

(
  • type
  • listener
)
Mixed chainable

Registers a one-time callback for an event

Parameters:

  • type String

    The event name to listen for

  • listener Function

    the callback to call when the event occurs

Returns:

Mixed:

Returns itself.

onGamepadDisconnect

(
  • event
)
private

Called when a gamepad connects (FF Only)

Parameters:

  • event GamepadConnectEvent

onGamepadDisconnect

(
  • event
)
private

Called when a gamepad disconnects (FF Only)

Parameters:

  • event GamepadDisconnectEvent

pollGamepads

()

Polls for newly connected gamepads (Chrome Only)

pollStatus

()

Polls the gamepad object for status updates and emits events when they occur

startPolling

()

Stats polling for new gamepads and status updates

stopPolling

()

Stops polling for new gamepads and status updates

update

()

Called each frame to update polling mechanisms

Properties

buttons

GamepadButtons

Holds the button handler for gamepad button events

game

Game

Inherited from Input: src\input\Input.js:16

The game instance this input belongs to

pads

Array

The currently activated gamepads list

prevTimestamps

Array private

Timestamp tracking for state changes

sticks

GamepadSticks

Holds the stick handler for gamepad stick events

ticking

Boolean

Tracks if we are polling for status/connections