GamepadSupports
This function returns whether the given Enum/UserInputType
gamepad supports a button corresponding with the given Enum//KeyCode
. This function is used to determine valid gamepad inputs.
To determine which Enum/UserInputType
gamepads are connected, use UserInputService/GetConnectedGamepads
.
As UserInputService
is client-side only, this function 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/GamepadEnabled
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
The |
||
|
The |
Returns
Return Type | Summary |
---|---|
Whether the given gamepad supports a button corresponding with the given |
Code Samples
Binding Functions to Gamepad Controls
This example binds the Enum/KeyCode|ButtonX
key to action if it is supported by controller (Enum/UserInputType|Gamepad1
). If bound, pressing the X Button invokes the action() function, which prints “Action”.
local UserInputService = game:GetService("UserInputService") local ContextActionService = game:GetService("ContextActionService") local controller = Enum.UserInputType.Gamepad1 local buttonX = Enum.KeyCode.ButtonX local function isSupported(gamepad, keycode) return UserInputService:GamepadSupports(gamepad, keycode) end local function action() print("Action") end if isSupported(controller, buttonX) then ContextActionService:BindAction("sample action", action, false, buttonX) end