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 onlyaxisLeftX:Float

Left joystick horizontal value, between -1.0 and 1.0 inclusive.

read onlyaxisLeftY:Float

Left joystick vertical value, between -1.0 and 1.0 inclusive.

read onlyaxisRightX:Float

Right joystick horizontal value, between -1.0 and 1.0 inclusive.

read onlyaxisRightY:Float

Right joystick vertical value, between -1.0 and 1.0 inclusive.

read onlyaxisLeftTrigger:Float

Left trigger value, between -1.0 and 1.0 inclusive.

read onlyaxisRightTrigger:Float

Right trigger value, between -1.0 and 1.0 inclusive.

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 onlybuttonLeftBumper:Bool

Whether the left bumper button is pressed.

read onlybuttonRightBumper:Bool

Whether the right bumper button is pressed.

read onlybuttonBack:Bool

Whether the back button is pressed.

read onlybuttonStart:Bool

Whether the start button is pressed.

read onlybuttonGuide:Bool

Whether the guide button is pressed.

read onlybuttonLeftThumb:Bool

Whether the left thumb button is pressed.

read onlybuttonRightThumb:Bool

Whether the right thumb button is pressed.

read onlybuttonUp:Bool

Whether the dpad up button is pressed.

read onlybuttonRight:Bool

Whether the dpad right button is pressed.

read onlybuttonDown:Bool

Whether the dpad down button is pressed.

read onlybuttonLeft:Bool

Whether the dpad left button is pressed.

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 onlyid:Int

The id of the gamepad, it is the index of the GLFW.gamepads array.

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.