noordstar / elm-gamepad / Gamepad

The Gamepad module exposes a type that lets you classify gamepads.

Common gamepad


type alias Gamepad =
Internal.Gamepad

The Gamepad type represents a player's game controller. Every gamepad type is a separate device that is handled by a different player.

decoder : Json.Decode.Decoder (List Gamepad)

This decoder directly takes a JSON value and decodes it into a list of gamepads.

connected : Gamepad -> Basics.Bool

Whether the gamepad is currently connected.

Debugging values

This library aims to offer you all the functions you need. If it somehow doesn't, however, you may use the following functions to find what you need.

buttons : Gamepad -> List Internal.Button.Button

Gets all available buttons on the controller as one list of buttons.

joysticks : Gamepad -> List Internal.Joystick.Joystick

Gets all available joysticks on the controller as one list of joysticks.

getButton : Basics.Int -> Gamepad -> Internal.Button.Button

Get a given button at a specific location in the array of buttons.

If the button doesn't exist, the function returns a fake button that is never pressed.

getJoystick : Basics.Int -> Gamepad -> Internal.Joystick.Joystick

Get a given joystick at a specific location in the array of joysticks.

If the joystick doesn't exist, the function returns a fake joystick that is never pressed.