Invalid Enum KeyCode Error due to :GetSupportedGamepadKeyCodes() on Mobile

Background:

Recently Sonic Speed Simulator released a gamepad support update to improve overall experience for players on console and for those who prefer to use gamepads even on other platforms.
However, a very strange bug was reported by mobile players using gamepads.

The Bug:

We use UserInputService:GetSupportedGamepadKeyCodes() to confirm whether the player can actually use the keycodes (and we dynamically show or hide keycode hints) but on mobile, the method errors:

Reproduction Steps:

  1. Open the reproduction file OR make your own place and use UserInputService:GetSupportedGamepadKeyCodes() when a gamepad is connected
  2. Publish the place
  3. Connect a gamepad to a mobile device
  4. Open the place on the Roblox app on your mobile device
  5. Try to move using the gamepad
  6. Open Dev console and see the error

NOTE 1: Interchanging steps 3 and 4 does not seem to affect the outcome.
NOTE 2: The bug seems to occur very frequently but not at all times.
NOTE 3: UserInputService.GamepadEnabled is true

Reproduction File:

InvalidEnumError.rbxl (54.1 KB)

Hardware used:

  1. I used an XBox Controller for testing.
  2. The issue occurs on both. Android and iOS mobile devices.

Expected behavior

The method should return an array of supported gamepad keycodes OR an empty array if the gamepad is not connected.

4 Likes

Hey @OptimizedFunction,

Thanks for the report! We looked into this and couldn’t reproduce the error on different mobile platforms / gamepads over several tries with the provided file. Are you still able to reproduce the issue?

Hello @runitbackrolfo ,

Yes, I am able to reliably reproduce the bug.
The code I used in the reproduction place:

local UIS: UserInputService = game:GetService("UserInputService")

local function printSupportedGamepadKeyCodes(gamepadNum: Enum.UserInputType)
	print("Is Gamepad enabled?", UIS.GamepadEnabled)
	
	local supportedKeyCodes: {Enum.KeyCode} = UIS:GetSupportedGamepadKeyCodes(gamepadNum)
	print("Supported keycodes for the gamepad are:", unpack(supportedKeyCodes))
end

UIS.GamepadConnected:Connect(printSupportedGamepadKeyCodes)
printSupportedGamepadKeyCodes(Enum.UserInputType.Gamepad1) -- in case your gamepad was connected already ^_^

The result on my mobile device (Samsung S24 Ultra, with an XBox One Controller connected via Bluetooth):

You can directly test this in a published place of mine if you so wish: Bug testing 1 - Roblox
I have set Place Copying to enabled for this place in case you want to grab a copy for any reason, however the .rbxl file in the OP is the same.

1 Like

Hi @OptimizedFunction,

We’ve rolled out a fix for this issue on Android devices using gamepads. Let us know if you encounter any issues!

1 Like