Members
CONTROLLER_TYPES :Object
Controller Types
- Object
| Name | Type | Description |
|---|---|---|
XBOX | string | Xbox family of controllers |
PLAYSTATION | string | PlayStation family of controllers |
SWITCH | string | Nintendo Switch controllers |
STANDARD | string | Generic or standard controllers |
- Source
controllerMappings :Object.<string, {buttonMap: Object.<number, string>, axisMap: Object.<number, string>}>
Controller Mappings Maps controller types to their respective button and axis mappings.
- Object.<string, {buttonMap: Object.<number, string>, axisMap: Object.<number, string>}>
- Source
exactGamepadMappings :Object.<number, {name: string, gamepad_api_ids: Array.<string>, type: string}>
Exact Gamepad Mappings This object maps specific gamepad API IDs to controller types and names.
- Object.<number, {name: string, gamepad_api_ids: Array.<string>, type: string}>
- Source
exactIdLookup :Object.<string, {name: string, gamepad_api_ids: Array.<string>, type: string}>
Exact ID Lookup This object maps gamepad API IDs to their respective controller mappings.
- Object.<string, {name: string, gamepad_api_ids: Array.<string>, type: string}>
- Source
Methods
detectControllerType(gamepadId) → {string}
Detect the controller type based on the gamepad ID
| Name | Type | Description |
|---|---|---|
gamepadId | string | | The ID of the gamepad as given by the Gamepad API |
- Source
The type of controller (XBOX, PLAYSTATION, SWITCH, STANDARD)
- Type:
- string
getAxisName(controllerType, axisIndex) → {string}
Get axis name for given controller type and axis index
| Name | Type | Description |
|---|---|---|
controllerType | string | The type of controller (XBOX, PLAYSTATION, SWITCH, STANDARD) |
axisIndex | number | The index of the axis |
- Source
The name of the axis (e.g., 'Left Stick X', 'Right Stick Y', etc.)
- Type:
- string
getButtonImagePath(controllerType, buttonIndex, basePathopt, buttonColoropt, buttonTypeopt) → {string|null}
Get the image path for a specific button on a controller
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
controllerType | string | The type of controller (XBOX, PLAYSTATION, SWITCH) | ||
buttonIndex | number | The index of the button | ||
basePath | string | <optional> | '/assets/img/gamepads/' | The base path for the images |
buttonColor | string | <optional> | 'White' | The color of the button ('Black' or 'White') |
buttonType | string | <optional> | 'Outline' | The type of button ('Outline', 'Solid', 'Full Solid') |
- Source
The path to the button image or null if not found
- Type:
- string |
null
getButtonName(controllerType, buttonIndex) → {string}
Get button name for given controller type and button index
| Name | Type | Description |
|---|---|---|
controllerType | string | The type of controller (XBOX, PLAYSTATION, SWITCH, STANDARD) |
buttonIndex | number | The index of the button |
- Source
The name of the button (e.g., 'A', 'B', 'X', etc.)
- Type:
- string
getConnectedGamepads() → {Array.<Gamepad>}
Get all connected gamepads
- Source
Array of connected gamepad objects
- Type:
- Array.<Gamepad>
getGamepadInfo(gamepadId) → {Object}
Get gamepad information based on the gamepad ID
| Name | Type | Description |
|---|---|---|
gamepadId | string | | The ID of the gamepad as given by the Gamepad API |
- Source
Controller type and name information
- Type:
- Object
getVibrationCapabilities(gamepad) → {Object}
Get vibration capabilities of the gamepad
| Name | Type | Description |
|---|---|---|
gamepad | Gamepad | | The gamepad object from the Gamepad API |
- Source
Vibration capabilities information
- Type:
- Object
isSupported() → {boolean}
Check if the Gamepad API is supported in the current browser
- Source
True if supported, false otherwise
- Type:
- boolean
isVibrationSupported(gamepad) → {boolean}
Check if vibration is supported on the gamepad
| Name | Type | Description |
|---|---|---|
gamepad | Gamepad | | The gamepad object from the Gamepad API |
- Source
True if vibration is supported, false otherwise
- Type:
- boolean
stopVibration(gamepad) → {Promise.<(GamepadHapticsResult|Error)>}
Stop vibration on the gamepad
| Name | Type | Description |
|---|---|---|
gamepad | Gamepad | | The gamepad object from the Gamepad API |
- Source
Promise that resolves when vibration stops
- Type:
- Promise.<(GamepadHapticsResult|Error)>
vibrate(gamepad, optionsopt) → {Promise.<(GamepadHapticsResult|Error)>}
Vibrate the gamepad
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gamepad | Gamepad | | The gamepad object from the Gamepad API | |||||||||||||||||||||||||||
options | Object | <optional> | {} | Options for vibration Properties
|
- Source
Promise that resolves when vibration completes
- Type:
- Promise.<(GamepadHapticsResult|Error)>