Gamepad virtual cursor briefly appears when a gamepad is not active/connected

I started using the GamepadService:EnableGamepadCursor() and GamepadService:DisableGamepadCursor() APIs in my game recently. I’ve observed that, even when there is no gamepad connected, less active, the virtual cursor appears on my screen after enabling it via the API. It stays there until I move my mouse-it then disappears.

This happens in both Studio and live experiences.

Expected behavior

I expect the gamepad cursor to only show when the gamepad is the active input type. It should not be on the developer to enable and disable it based on input type, because it’s the gamepad cursor! We enable it and disable it based on UI state.

Thanks for the report, I can add a fix for this.

1 Like

Please let me know when it is live so I can re-enable it. Thanks for the swift response!

Can you please provide a repro place describing how you use these APIs. Thanks

Yes, here’s a local script you can run in a baseplate as a reproduction:

--!strict

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

local gamepadsConnected = UserInputService:GetConnectedGamepads()
print(`{#gamepadsConnected} gamepads connected`)

local enabled = false

function toggle()
	enabled = not enabled
	print(if enabled then "Enabled" else "Disabled")
	
	if enabled then
		GamepadService:EnableGamepadCursor(nil)
	else
		GamepadService:DisableGamepadCursor()
	end
end

UserInputService.InputEnded:Connect(function(inputObject, gp)
	if gp or inputObject.KeyCode ~= Enum.KeyCode.E then return end
	
	toggle()
end)

Here’s a video showing me using that script:

Quick aside:
After looking at decompiled CoreScripts, though I’m unable to track down the issue, I’ve noticed that the virtual cursor appears to be hardcoded for Gamepad1, leading me to believe this gamepad cursor will only work for the first connected controller. This seems like an oversight.

I’ll still go ahead and fix this bug, but I am wondering why you’d enable virtual cursor from user input that isn’t gamepad? I would think your script should only enable virtual cursor if a gamepad keycode was pressed.

I don’t do that in my game-I only did it based off keyboard input in my example so that the problem could be reproducible easily.

The issue exists regardless of the trigger of the API.

In reality, I have state that indicates whether a modal is open on a user’s screen-such as a shop. I enable and disable the gamepad cursor based on that state. If the user does not have a gamepad connected, the cursor still briefly shows.

Hi a fix went out for this, can you confirm this issue is no longer happening. Thanks

It appears to be resolved. Thanks