0.7.0 • Published 8 months ago

gamepad-events v0.7.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

GamePadManager ⇐ EventEmitter

A helper to manage gamepad inputs.

Kind: global class
Extends: EventEmitter
See: https://github.com/primus/eventemitter3 eventemitter3

new GamePadManager(config)

Constructor.

ParamTypeDescription
configObjectThe configuration object.
config.buttonThresholdNumberThe threshold to trigger button events. Used for analog buttons / triggers with variable values and not binary ones.
config.axisThresholdNumberThe threshold to trigger axis events.
config.longpressThresholdNumberThe threshold to trigger longpress.
config.repeatThresholdNumberThe threshold to trigger repeat.
config.repeatRateNumberThe time between repeat events.

gamePadManager.update()

Update the gamepad manager, this handles button/axis events, as well as updating the internal state and setting up the delta.

Kind: instance method of GamePadManager

gamePadManager.isDown(target, player) ⇒ Boolean

Check if a button is pressed or held.

Kind: instance method of GamePadManager
Returns: Boolean - IsDown If the button is pressed or held.

ParamTypeDefaultDescription
targetStringThe button to check if is down.
playerNumber-1The gamepad to check, if -1, all are checked.

gamePadManager.getStick(target, player) ⇒ Object

Get the state of a stick.

Kind: instance method of GamePadManager
Returns: Object - The x,y state of the stick.

ParamTypeDefaultDescription
targetStringThe stick name.
playerNumber-1The index of the player to get.

gamePadManager.on(event, listener, context) ⇒ EventEmitter

Add an event listener. These are namespaced as well, so you can do down:axis_0 to get the specific axis event.

Kind: instance method of GamePadManager

ParamTypeDescription
eventstringThe name of the event.
listenerfunctionThe name of the event.
contextobjectThe context to be used as 'this' in the listener.

gamePadManager.once(event, listener, context) ⇒ EventEmitter

Add an event listener. These are namespaced as well, so you can do down:axis_0 to get the specific axis event.

Kind: instance method of GamePadManager

ParamTypeDescription
eventstringThe name of the event.
listenerfunctionThe name of the event.
contextobjectThe context to be used as 'this' in the listener.

gamePadManager.off(event, listener) ⇒ EventEmitter

Remove an event listener. These are namespaced as well, so you can do down:axis_0 to get the specific axis event.

Kind: instance method of GamePadManager

ParamTypeDescription
eventstringThe name of the event.
listenerfunctionThe name of the event.

gamePadManager.removeAllListeners(event) ⇒ EventEmitter

Remove all listeners from an event. These are namespaced as well, so you can do down:axis_0 to get the specific axis event.

Kind: instance method of GamePadManager

ParamTypeDescription
eventstringThe name of the event.
0.7.0

8 months ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago