PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

GetGamepadState

This function returns an array of InputObject|InputObjects for all available inputs on the given Enum/UserInputType gamepad, representing each input’s last input state.

To find the Enum/UserInputType|UserInputTypes of connected gamepads, use UserInputService/GetConnectedGamepads.

As this function only fires locally, it can only be used in a LocalScript.

See this page for articles on cross-platform development.

See also

  • UserInputService/GamepadConnected
  • UserInputService/GamepadDisconnected
  • UserInputService/GetConnectedGamepads
  • UserInputService/GetNavigationGamepads
  • UserInputService/SetNavigationGamepad
  • UserInputService/IsNavigationGamepad
  • UserInputService/IsGamepadButtonDown
  • UserInputService/GetSupportedGamepadKeyCodes
  • UserInputService/GetGamepadConnected
  • UserInputService/GamepadSupports
  • UserInputService/GamepadEnabled

Parameters

Name Type Default Description

The Enum/UserInputType corresponding with the gamepad in question

Returns

Return Type Summary

An array of InputObject|InputObjects representing the current state of all available inputs for the given gamepad


Code Samples


Mapping and Polling GamepadStates

This example demonstrates how to map a Enum/UserInputType|gamepad’s states to their corresponding Enum|KeyCode|KeyCodes, and then you can always reference them. Since the states are mutable; you don’t have to keep calling GetGamepadState once they are mapped. Then, you can reference the states of the gamepad’s controls using KeyCodes and indices - such as to poll the Thumbstick1 position.