Using Enum.GamepadType

How do I use Enum.Gamepad type?

Theres no information about it on the Documentation other then values.

I’ve tried this but it prints idek every time (I’m using an Xbox One controller)

local gamepad = Enum.UserInputType.Gamepad1

if gamepad == Enum.GamepadType.XboxOne then
	print("The gamepad is an Xbox One controller.")
elseif gamepad == Enum.GamepadType.PS4 then
	print("The gamepad is a PlayStation 4 controller.")
elseif gamepad == Enum.GamepadType.PS5 then
	print("The gamepad is a PlayStation 5 controller.")
elseif gamepad == Enum.GamepadType.Unknown then
	print("Unknown gamepad type.")
else
	print("idek")
end

I don’t think Roblox allows people to use that Enum, or it just doesn’t work in general. To figure out if a player is using a PlayStation remote or a Xbox remote, I use the following API:


I share my implementation (code) here:

A little late to this but could you just explain in simple terms what you did?

local userInputService = game:GetService("UserInputService")
local buttonA = Enum.KeyCode.ButtonA -- 'A' button on xbox controllers ('X' on PlaySation)

local str = userInputService:GetStringForKeyCode(buttonA)
local isXbox = str == "ButtonA" -- if 'str' is ButtonA, then this will evaluate to true, otherwise, it'll be false
-- if the result of 'str' is ButtonA, then the user is on Xbox
-- if the result of 'str' is ButtonCross, then the user is on PlayStation

if isXbox then
   print("playing on xbox")
else
   print("playing on PlayStation")
end
2 Likes

Thanks. Thats what I assumed you were doing.

I only have access to an XBox controller at the moment, so do you know if there’s anyway to test if this really works? Any apps that create a fake gamepad?

In studio, you can switch the emulation test to “PS4” and Studio will behave as if you were running on a PS4:

image

(Emulation)

2 Likes

Worked. Thank you.

these are characters

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.