Device Type Detection

You can cheat this by creating a ProximityPrompt with KeyboardKeyCode = Enum.KeyCode.LeftControl and seeing which image is used in LocalPlayer.PlayerGui.ProximityPrompts.

6 Likes

Currently it is impossible to determine what device a player is using and thus impossible for me to create exceptional UX for my UIs.

Currently MouseButtonDown will fire when a player taps on a GuiButton on a touch device however a Touch device’s mouse behaves very differently from an actual computer mouse

and this makes it impossible to make my UIs usable for Mobile devices and this is crippling my ability to develop games and make them support Mobile devices, in which has the most users.

I use a combination of MouseEnter, MouseLeave and MouseButton1Down to preset data and play animations, being able to accurately determine which device a player is using would allow me to control and create the best user experience possible for my games.

because MouseButton events also fires for Mobile devices when they tap, it is impossible for consistent behavior between different devices and the current workaround that I am working on this determining which device a player is using and hook appropriate events to their input instead of using the same one across all devices.

1 Like

Isn’t the real solution here to ask for improved generic APIs for the issues you mention, so you only need to hook into one set of API, so you don’t need to vary it by platform yourself?

:man_shrugging:

Probably but I don’t really know what the best solution is nor can I wait for Roblox to implement such a change if they ever will, the only method that I can think of right now is determining what device a player is using and hooking the appropriate input events based on their device.

Yes, but in some cases I want to have full control of the player’s experience with different devices, i.e showing a different UI layout for different devices or displaying different information.

This isn’t only about ease of API use but also about giving back control to developers and allowing them to customize behavior and user experience.

The best solution I have right now is this

local PlayerDevice = {}
function PlayerDevice.isComputer(): boolean
	return UserInputService.MouseEnabled and UserInputService.KeyboardEnabled
end

function PlayerDevice.isTouchDevice(): boolean
	return UserInputService.TouchEnabled
end

function PlayerDevice.isXbox():boolean
	return UserInputService.GamepadEnabled
end

function PlayerDevice.isVR(): boolean
	return UserInputService.VREnabled
end

now I know this isn’t the best solution because some computers also have touchscreens and some players will use a mouse and keyboard with their tablet but what else can I possible do at this point?

1 Like

Yeah there’s some serious problems with the code you shared – for example, this one will be true whenever a PC player has a controller plugged in, even if they’re not using it and their current input mode is keyboard. GamepadEnabled is a trap and should not be used in production code.

You basically always want to try and base things off the current input mode and screen size if you can. If there’s something you are prohibited from implementing based on those two things you probably want to file specific feature request on those specific issues.

5 Likes

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