Checking if user is actually using their Gamepad?

Normally I would use GamepadEnabled do detect if a user is on console. I recently saw somewhere that this shouldn’t be used, as players can obviously have controllers with PC (like myself) but some people leave their controllers plugged into their PC’s. Instead using GetLastInputType to determine whether the user is actually using their gamepad, or if it is just plugged in and the user intends to use keyboard and mouse.

So the question is, is it worth using GetLastInputType over GamepadEnabled or is it very rare that users would have a controller plugged in and not use it?

Using something like this:

renderStepped = runService.RenderStepped:Connect(function()
	local playerGui = player.PlayerGui
	if not playerGui then return end
	
	local insideDistance = (insideDoor.Teleport.CFrame.p - character.HumanoidRootPart.CFrame.p).magnitude
	local outsideDistance = (outsideDoor.Teleport.CFrame.p - character.HumanoidRootPart.CFrame.p).magnitude

	local lastInput = userInputService:GetLastInputType()
	
	if insideDistance <= settings.Distance or outsideDistance <= settings.Distance then
		local enterClone = playerGui:FindFirstChild('Enter')
		if enterClone then return end
		
		local enterClone = enter:Clone()
		if not enterClone then return end
		
		print(lastInput)
 
		if lastInput == Enum.UserInputType.Gamepad1 then
			enter.ControlPC.Visible = false
		else
			enter.ControlPC.Visible = true
		end
		
		enterClone.Parent = playerGui
	else
		local enterClone = playerGui:FindFirstChild('Enter')
		if not enterClone then return end
		
		enterClone:Destroy()
	end
end)

For some reason, when the UI first shows up, the PC icon is invisible, then every other time after that it is visible.

7 Likes

i would use the GetLastInputType solution, Despite that it would be quite rare a controller is permanently plugged into, it’s definitively a possibility, which mean they may be confused and think the game is broken while it’s actually not !

Obviously, you’ll have to remember that young people do not really looks into your game whenever it’s their fault or not, a broken game is a game they can’t play, do your utmost possible to make the player comfortable.

3 Likes

Yes, do this.

Connect to LastInputTypeChanged and then change all of the UI elements accordingly so that people can seamlessly switch between input modes.

Yes, most definitely worth it. Most players who use a controller on PC have it plugged in even if they’re not using it, and your game would incorrectly show gamepad prompts / rumble the controller on their desk in those situations which is a really bad user experience.

1 Like

I’m one of those people who leave the controller plugged in. Very annoying in games that don’t seem to react to the fact I’m using my keyboard and mouse. Please use GetLastInputType

6 Likes