Getxpad
Reads Xbox-style controller state from the graphics library.
Syntax
`
Declare Function Getxpad ( ByVal id As Long, ByRef buttons As Integer = 0, ByRef leftx As Single = 0, ByRef lefty As Single = 0, ByRef rightx As Single = 0, ByRef righty As Single = 0, ByRef lefttrigger As Single = 0, ByRef righttrigger As Single = 0, ByRef dpad As Integer = 0 ) As Long
`
Usage
`
status = Getxpad( id[, buttons[, leftx[, lefty[, rightx[, righty[, lefttrigger[, righttrigger[, dpad]]]]]]]] )
`
Parameters
`id`
The controller number to query. The valid range is platform dependent.
`buttons`
A bit mask of `XPAD_BUTTON_*` values.
`leftx`, `lefty`, `rightx`, `righty`
Analog stick positions in the range `-1.0` to `1.0`.
`lefttrigger`, `righttrigger`
Trigger positions in the range `0.0` to `1.0`.
`dpad`
A bit mask of `XPAD_DPAD_*` values.
Return Value
Returns one of the `XPAD_STATUS_*` constants from `fbgfx.bi`:

- `XPAD_STATUS_MISSING` (0)
- `XPAD_STATUS_CONNECTED` (1)
- `XPAD_STATUS_DISCONNECTED` (2)

Description
`Getxpad` provides a stable Xbox-style controller layout across supported backends. It is separate from `GetJoystick` because modern gamepads have a conventional button, trigger, stick, and d-pad shape that maps poorly to a generic axis list.
The named `XPAD_BUTTON_*`, `XPAD_DPAD_*`, and `XPAD_STATUS_*` constants are declared in `fbgfx.bi` under the `FB` namespace. The function itself is an intrinsic and does not require an include file to call.
Example
See `examples/xpad/first-pad.bas`, `examples/xpad/active-state.bas`, and `examples/xpad/stick-view.bas`.
Dialect Differences

- Not available in the -lang qb dialect unless referenced with the alias `__Getxpad`.

Differences from QB

- New to FreeBASIC.

See also

- `GetJoystick`
- `MultiKey`
- `GetMouse`