PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

GamepadEnabled

UserInputService

bool

This property describes whether the device being used by a user has an available gamepad.

local userInputService = game:GetService("UserInputService")

if userInputService.GamepadEnabled then
	print("Gamepad enabled")
else
	print("Gamepad not enabled")
end

If gamepads are available, you can use UserInputService/GetConnectedGamepads to retrieve a list of connected gamepads and UserInputService/GetNavigationGamepads to retrieve a list of connected gamepads that also controlnavigation GUIs.

As UserInputService is client-side only, this property 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/GetGamepadState
  • UserInputService/GetGamepadConnected
  • UserInputService/GamepadSupports


Code Samples


How to Use the Right Gamepad for Input

The following code sample is used in the default gamepad script, so if you are using the default controls you do not need to worry about this. If you are creating a custom script for handling gamepad controls, this is a good template for retrieving which Enum/UserInputType|gamepad enum you should use as the primary gamepad controller.

This code looks for the lowest numbered UserInputService/GetNavigationGamepad|navigation gamepad, and if no navigation gamepad is found, finds the lowest numbered UserInputService/GetConnectedGamepad|connected gamepad. If there is no connected gamepad, we default to gamepad1. This ensures at least some gamepad will be able to do controls.