Controller
Static Member Summary
Static Public Members | ||
public static |
The range at which the analog is considered to be dropped -0.09 - 0.09 |
|
public static |
Analog thumb sticks |
|
public static |
|
|
public static |
The range at which axis changes are detected |
|
public static |
BUTTONS_MAP: * A button map that maps common button names to the indexes the computer knows them as |
|
public static |
|
|
public static |
GAMEPAD_IDS: * |
|
public static |
Value to indicate a pressed button |
|
public static |
A small remapped version of the controllers button_map with PS4 alternatives |
|
public static |
The value at which holding a trigger (LT OR RT) will consider it being pressed |
|
public static |
Value to indicate a button is not pressed |
|
public static |
The base analogs position when it is not in use |
Constructor Summary
Public Constructor | ||
public |
constructor(pGamepad: Gamepad) Creates a new controller instance and passes the gamepad it will be created with |
Member Summary
Public Members | ||
public |
Object of stored callbacks that will call when the axis is changed |
|
public |
Configuration of which buttons / analogs map to which indexes |
|
public |
gamepad: * |
|
public |
The index of the controller. |
|
public |
Info about the controller |
|
public |
|
|
public |
|
|
public |
Object of stored callback that will call when a button is pressed |
|
public |
Object full of the currently held down buttons |
|
public |
Object of stored callback that will call when a button is released |
|
public |
Whether the right analog is currently being held |
|
public |
The right analogs position |
|
public |
The timestamp of the gamepad. |
|
public |
type: * |
Method Summary
Public Methods | ||
public |
getPressed(): * Gets the current buttons pressed down on the gamepad. |
|
public |
Returns the type the controller is. |
|
public |
handleAxisInput(pAxis: number, pValue: number, pRepeat: boolean) Handles the input on the analogs. |
|
public |
handleButtonInput(pButton: number, pValue: number, pRepeat: boolean, pPressed: boolean) Handles the input on the buttons. |
|
public |
handleDropAnalog(pAnalog: string) Handles the event for when a analog is dropped. |
|
public |
handleGrabAnalog(pAnalog: string) Handles the event for when a analog is grabbed. |
|
public |
isButtonPressed(pButtonName: string): boolean Checks whether a button is pressed down or not |
|
public |
Whether the left analog is being held |
|
public |
Whether the right analog is being held |
|
public |
off(pEvent: Event['event']): Controller Removes a callback from the specified event. |
|
public |
on(pEvent: Event['event'], pCallback: Event['callback']): Controller Attaches a callback to the specified event. |
|
public |
The pulse() method of the GamepadHapticActuator interface makes the hardware pulse at a certain intensity for a specified duration. |
|
public |
updateState(-: Gamepad, -: Controller) Update the state of this controller with the latest polled information |
|
public |
vibrate(pVibrationType: string, pStartDelay: number, pWeakMagnitude: number, pStrongMagnitude: number) Vibrate the controller (experimental) |
Static Public Members
public static ANALOG_RELEASE_RANGE: number source
The range at which the analog is considered to be dropped -0.09 - 0.09
public static AXES_REVERSED_MAP: * source
public static BUTTONS_MAP: * source
A button map that maps common button names to the indexes the computer knows them as
public static BUTTONS_REVERSE_MAP: * source
public static GAMEPAD_IDS: * source
public static PS4_REMAPPED: object source
A small remapped version of the controllers button_map with PS4 alternatives
public static TRIGGER_PRESSED_VALUE: * source
The value at which holding a trigger (LT OR RT) will consider it being pressed
Public Constructors
public constructor(pGamepad: Gamepad) source
Creates a new controller instance and passes the gamepad it will be created with
Params:
Name | Type | Attribute | Description |
pGamepad | Gamepad | A gamepad object |
Public Members
public axisHandlers: Object source
Object of stored callbacks that will call when the axis is changed
public gamepad: * source
public leftAnalogHeld: * source
public leftAnalogPos: * source
public pressHandlers: Object source
Object of stored callback that will call when a button is pressed
public releaseHandlers: Object source
Object of stored callback that will call when a button is released
public type: * source
Public Methods
public handleAxisInput(pAxis: number, pValue: number, pRepeat: boolean) source
Handles the input on the analogs.
public handleButtonInput(pButton: number, pValue: number, pRepeat: boolean, pPressed: boolean) source
Handles the input on the buttons.
Params:
Name | Type | Attribute | Description |
pButton | number | The button index that was pressed |
|
pValue | number | The value of the button (0 for unpressed, 1 for pressed) 0-1 for buttons that have a range |
|
pRepeat | boolean | Whether this button is still being held from a previous frame |
|
pPressed | boolean | Whether this button is being pressed in this current frame. |
public handleDropAnalog(pAnalog: string) source
Handles the event for when a analog is dropped.
Params:
Name | Type | Attribute | Description |
pAnalog | string | Analog that was dropped |
public handleGrabAnalog(pAnalog: string) source
Handles the event for when a analog is grabbed.
Params:
Name | Type | Attribute | Description |
pAnalog | string | Analog that was grabbed |
public isButtonPressed(pButtonName: string): boolean source
Checks whether a button is pressed down or not
Params:
Name | Type | Attribute | Description |
pButtonName | string | The button to check if its pressed |
public off(pEvent: Event['event']): Controller source
Removes a callback from the specified event.
Params:
Name | Type | Attribute | Description |
pEvent | Event['event'] | The event to remove the callback from |
public on(pEvent: Event['event'], pCallback: Event['callback']): Controller source
Attaches a callback to the specified event.
Params:
Name | Type | Attribute | Description |
pEvent | Event['event'] | The event to attach the callback to |
|
pCallback | Event['callback'] | The function to be called when the event is triggered |
public pulse(pValue: number, pDuration: number) source
The pulse() method of the GamepadHapticActuator interface makes the hardware pulse at a certain intensity for a specified duration. (From MDN)
Params:
Name | Type | Attribute | Description |
pValue | number | A double representing the intensity of the pulse. This can vary depending on the hardware type, but generally takes a value between 0.0 (no intensity) and 1.0 (full intensity). |
|
pDuration | number | A double representing the duration of the pulse, in milliseconds. |
public updateState(-: Gamepad, -: Controller) source
Update the state of this controller with the latest polled information
Params:
Name | Type | Attribute | Description |
- | Gamepad | The gamepad with the new updated state |
|
- | Controller | The gamepad controller instance |
public vibrate(pVibrationType: string, pStartDelay: number, pWeakMagnitude: number, pStrongMagnitude: number) source
Vibrate the controller (experimental)
dual-rumble: Dual-rumble describes a haptic configuration with an eccentric rotating mass vibration motor in each handle of a standard gamepad. In this configuration, either motor is capable of vibrating the whole gamepad. The two masses are unequal so that the effects of each can be combined to create more complex haptic effects.
Params:
Name | Type | Attribute | Description |
pVibrationType | string | The type of rumble. "dual-rumble", or "vibration" |
|
pStartDelay | number | The start delay before the vibration occurs in ms |
|
pWeakMagnitude | number | The magnitude of the weak actuator (between 0 and 1). |
|
pStrongMagnitude | number | The magnitude of the strong actuator (between 0 and 1). |