A gamepad.
To get a gamepad obtain it from GLFW.gamepads
or GLFW.getConnectedGamepad
.
Using the gamepad if it is not Gamepad.connected
will throw a GamepadNotConnectedException
exception.
Using the gamepad after the GLFW object was destroyed with GLFW.destroy
will throw a UseAfterDestroyException
exception.
Variables
read onlybuttonA:Bool
Whether the A button (XBox layout) is pressed. The playstation alias is Gamepad.buttonCross
.
read onlybuttonB:Bool
Whether the B button (XBox layout) is pressed. The playstation alias is Gamepad.buttonCircle
.
read onlybuttonX:Bool
Whether the X button (XBox layout) is pressed. The playstation alias is Gamepad.buttonSquare
.
read onlybuttonY:Bool
Whether the Y button (XBox layout) is pressed. The playstation alias is Gamepad.buttonTriangle
.
read onlybuttonCross:Bool
Whether the cross button (Playstation layout) is pressed. The xbox version is Gamepad.buttonA
.
read onlybuttonCircle:Bool
Whether the circle button (Playstation layout) is pressed. The xbox version is Gamepad.buttonB
.
read onlybuttonSquare:Bool
Whether the square button (Playstation layout) is pressed. The xbox version is Gamepad.buttonX
.
read onlybuttonTriangle:Bool
Whether the triangle button (Playstation layout) is pressed. The xbox version is Gamepad.buttonYs
.
read onlyconnected:Bool
Whether the gamepad is connected.
Thread safety: This variable must only be used from the main thread.
Throws:
PlatformErrorException | |
---|---|
null | UseAfterDestroyException |
read onlyguid:String
The SDL compatible GUID of the connected gamepad.
The GUID uses the format introduced in SDL 2.0.5. This GUID tries to uniquely identify the make and model of a joystick but does not identify a specific unit, e.g. all wired Xbox 360 controllers will have the same GUID on that platform.
The GUID for a unit may vary between platforms depending on what hardware information the platform specific APIs provide.
Thread safety: This function must only be called from the main thread.
Throws:
GamepadNotConnectedException | |
---|---|
PlatformErrorException | |
null | UseAfterDestroyException |
read onlyhasMapping:Bool
Whether the connected gamepad has a mapping.
If the gamepad has no mapping the buttons and axes may be incorrectly mapped to the variables.
You can patch the mapping database with GLFW.updateGamepadMappings
using the gamepad Gamepad.guid
.
Thread safety: This function must only be called from the main thread.
Throws:
GamepadNotConnectedException | |
---|---|
null | UseAfterDestroyException |
read onlyname:String
The name of the connected gamepad.
Thread safety: This function must only be called from the main thread.
Throws:
GamepadNotConnectedException | |
---|---|
PlatformErrorException | |
null | UseAfterDestroyException |
onStatusChange:Array<(connected:Bool) ‑> Void>
The callbacks to be called when the gamepad is connected or disconnected from the system.
Disconnecting then reconnecting the same physical gamepad is not guaranteed to map to the same Gamepad
object.
Arguments:
connected
True if the gamepad was connected, false if disconnected.
To add a callback push a function to this array.