EventEmitter
GamePadManager ⇐ A helper to manage gamepad inputs.
Kind: global class
Extends: EventEmitter
See: https://github.com/primus/eventemitter3 eventemitter3
-
GamePadManager ⇐
EventEmitter
- new GamePadManager([config])
- .update()
-
.isDown(target, player) ⇒
Boolean
-
.getStick(target, player) ⇒
Object
-
.on(event, listener, context) ⇒
EventEmitter
-
.once(event, listener, context) ⇒
EventEmitter
-
.off(event, listener) ⇒
EventEmitter
-
.removeAllListeners(event) ⇒
EventEmitter
new GamePadManager([config])
Constructor.
Param | Type | Description |
---|---|---|
[config] | Object |
The configuration object. |
[config.buttonThreshold] | Number |
The threshold to trigger button events. Used for analog buttons / triggers with variable values and not binary ones. |
[config.axisThreshold] | Number |
The threshold to trigger axis events. |
[config.longpressThreshold] | Number |
The threshold to trigger longpress. |
[config.repeatThreshold] | Number |
The threshold to trigger repeat. |
[config.repeatRate] | Number |
The 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
Boolean
gamePadManager.isDown(target, player) ⇒ Check if a button is pressed or held.
Kind: instance method of GamePadManager
Returns: Boolean
- IsDown If the button is pressed or held.
Param | Type | Default | Description |
---|---|---|---|
target | String |
The button to check if is down. | |
player | Number |
-1 |
The gamepad to check, if -1, all are checked. |
Object
gamePadManager.getStick(target, player) ⇒ Get the state of a stick.
Kind: instance method of GamePadManager
Returns: Object
- The x,y state of the stick.
Param | Type | Default | Description |
---|---|---|---|
target | String |
The stick name. | |
player | Number |
-1 |
The index of the player to get. |
EventEmitter
gamePadManager.on(event, listener, context) ⇒ 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
Param | Type | Description |
---|---|---|
event | string |
The name of the event. |
listener | function |
The name of the event. |
context | object |
The context to be used as 'this' in the listener. |
EventEmitter
gamePadManager.once(event, listener, context) ⇒ 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
Param | Type | Description |
---|---|---|
event | string |
The name of the event. |
listener | function |
The name of the event. |
context | object |
The context to be used as 'this' in the listener. |
EventEmitter
gamePadManager.off(event, listener) ⇒ 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
Param | Type | Description |
---|---|---|
event | string |
The name of the event. |
listener | function |
The name of the event. |
EventEmitter
gamePadManager.removeAllListeners(event) ⇒ 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
Param | Type | Description |
---|---|---|
event | string |
The name of the event. |