First things first, I’d like to apologize for this huge necrobump.
However, I do feel this is a much needed feature, and it’s already in Roblox, but it is locked to RobloxSecurity (for a reason I do not know, other than it might be due to privacy concerns, but you can’t get much info from knowing the platform.)
Not only would allowing access to the PlatformEnum enable better input controls, but it would also allow for much, much easier creation of interfaces, scripts, settings, etc. for specific platforms. I.e., you could make an OSX-styled menu for Mac users, while using say, an Xbox-styled menu for Xbox users, or as Clone said, the disabling of certain things Client-Side.
This would be very beneficial and would allow the use of much cleaner code, and wouldn’t have to be hacky in nature.
They were asked about this at RDC and they said this is something they’d never add. UserInputService provides all the information you’d need for user input. The only downside to not having the exact device type is analytics, which they were asked about and were iffy about.
Sooo what if someone is on PS4 (in the future if an when Roblox goes onto PS4,) how would you differentiate between a PS4 and an Xbox One? Since both platforms would be running under “10FootDisplay” or whatever, and both use gamepad input.
Imo, it’s kinda silly they’re not allowing developers access to the PlatformEnum.
They would add new KeyCode enumerator values for the shape buttons on playstation controllers, and they would either add a dedicated method to check the current controller layout + events for when it changes, or you have to use GetSupportedGamepadKeyCodes, GamepadConnected, GamepadDisconnected to determine which input labels to show to the user. All the functionality to accommodate for this is already present apart from the actual Circle/Triangle/Square/CrossButton enumerator values.
Writing platform-dependent code is really old-fashioned. Abstraction is your friend. It’s much better to write code per input mode that you can dynamically switch between such that the user can enjoy a reactive game that isn’t hinged on assumptions about their device.
That seems fine for compatibility’s sake, the point of my paragraph being that the problem described in the post above that is just implementation details that aren’t actually as hard to pull off (without having a device type API) as the poster made it seem.
As creator of this thread, I’m going to mark this post as solved.
Anytime this has been suggested, the same response has been: No. For the foreseeable future, this will not be a feature. It seems like Roblox is strongly opposing this. This makes sense, as devices are continuously changing and many devices take the form of others (e.g. a small touchscreen laptop vs. a large tablet w/ a mouse and keyboard hooked up).
As a Roblox developer, it is currently annoying for onboarding developers & me sometimes to figure out what platform players are on.
Having all the ways to determine what platform it is under one method :GetPlatform() instead of using
GuiService:IsTenFootInterface
UserInputService.TouchEnabled
UserInputService.KeyboardEnabled
UserInputService.AccelerometerEnabled
UserInputService.GyroscopeEnabled
UserInputService.GamepadEnabled
I think MACS don’t have a mouse2 or a ctrl button? This causes users to request an option to crouch with C and aim down sights with Q. I could have this turned on automatically if I detect them on a mac.
Also, a new developer might be confused on how to figure out how to check if they are on xbox, because its under GUIService away from everything else.
Why is it disabled? I don’t think it’s super privacy breaking if I know they are on a MAC or PC, Android or iPhone. If roblox can see these, why can’t I?
This is fair ^ Doesn’t mean a solution can’t be found though
Just for reference for people who may not know, this is a recent version of how to get the platform. (Includes the recent-ish change with touchscreens) It’s pretty silly how many services and weird checks we have to use. & good point from mightybaseplate about the mac controls
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
function getplatform()
if (GuiService:IsTenFootInterface()) then
return "Console"
elseif (UserInputService.TouchEnabled and not UserInputService.MouseEnabled) then
--touchscreen computers now have touchenabled so make sure to check for lack of mouse too
--also, not all phones/tablets have accelerometer and/or gyroscope
local DeviceSize = workspace.CurrentCamera.ViewportSize;
if ( DeviceSize.Y > 600 ) then
return "Mobile (tablet)"
else
return "Mobile (phone)"
end
else
return "Desktop"
end
end
to allows developers to detect OS, platform and/or device. What makes Roblox so special in this regard? As someone else said, this is “bubble wrapping” the API for safety.
Analytics are important. Different users behave differently, and operating system is just one more segment by which a player-base can be measured. This isn’t a matter of privacy either, since this kind of information tells you absolutely nothing useful about someone. Plus, it can be sniffed anyway.
The fact that there’s a metric crapton of different devices with different capabilities is actually an argument in favor such a feature to be exposed. More OSes/platforms/devices etc means more work for the people doing it the wrong way (detecting platform and setting up input). Abstraction via available peripherals is obviously the way to go, nobody’s arguing that. We have that feature already.
I don’t buy for a second the “there’s bad use cases” argument because if we really restricted features based on how they could be misused we’d have no features at all. Frankly, I think it’s insulting because it send the message that all Roblox developers are too naive to use the feature correctly when this is most certainly not the case.
The feature already exists. Literally the lowest amount of effort it would take to make this feature available to everyone. We’ve probably wasted more time talking about this than it would take to actually let people use this.
There’s really no security risk involved with allowing developers know what platform someone is on. Not only is the feature useful for analytics, but it’s also quite useful when coding in platform-specific functions, such as the previously mentioned Mac problem.
Another important use of this could be user interfaces.
With this, you can make a separate mobile interface, separate pc interface, etc.
This would allow developers to optimize the screen real estate in a much better way.
You can make the buttons on mobile bigger. (Scale and UI constraints won’t cut it.)
You can make buttons etc. that would normally on pc take up part of the screen, completely fill the mobile screen. You can simplify menus too etc.
I should also mention that for this, the device detection shouldn’t need much more than ‘Desktop’, ‘Console’ and ‘Mobile’. (Maybe tablet?)
I’ve seen games like MeepCity optimize their UI for phone for example. The only way to do such a thing as of right now is to use those hacky methods as described above.
In other words, it would enable developers to make responsive UI without any hassle.
The strawman argument of “Just use UserInputService” is nullified when talking about multi-platform games, such as FPS games.
You don’t want console players going against PC players in a first person shooter.
Plus, it’s practically impossible to funnel players into specific servers for that specific device - a PC user could cheat into an Xbox - only lobby by using a gamepad. TenFootInterface also seems problematic because what happens if they’re playing Roblox on a PC that’s connected to a TV?
You also run into the issue with the possibility of Roblox going on PlayStation - UIS isn’t going to cut it.
I encourage you to think about the reasons behind this. It is true that some input devices provide a competitive advantage over others, e.g. keyboard/mouse is typically better than a gamepad. However, there is not a 1:1 connection between platforms and input devices. As of late last year, Xbox One players can use a keyboard/mouse with their console (I believe Roblox is looking into adding support for this). Similarly, PC players can use a gamepad. Many industry games are starting to do input based matchmaking for this reason.
So any argument that says “I want to segregate my players based on platform because of a competitive input type advantage” seems like a suboptimal solution. Instead, segregate your players based on input type.
Alright, yeah. I see your points regarding why platform detection could be bad.
However, how would we detect a user’s platform so they get the correct buttons to show up? I.e. if Playstation 4 is ever added to the Roblox ecosystem. At that point, there would need to be some kind of specific device detection in place. Or possibly even direct-driver detection so you could get PS4 buttons on PC, or N64 buttons on PC if for some reason you’re playing with an N64 controller.
Not really, they would probably just add another input mode for the different controller layout, or perhaps some new keycodes, or both, or something entirely different that lets you distinguish between those controller layouts. You would not want the device check because then you’re excluding people who use the PS4/other controller through another device.
Currently, it’s only available on Xbox, and you can use GuiService:IsTenFootInterface() to detect if the user is on a console (and thus Xbox). If it were ever available on another console, I’m sure an API would be added to distinguish between the two.
I am making this claim due to one of the requirements for Xbox compatibility being this:
If on a platform like PS4, I imagine the same guideline would apply; therefore, I see it being reasonable to add some API to distinguish between the two.
However, that’s not the case currently.
At the moment, you can also use UserInputService:GetLastInputType() and UserInputService.LastInputTypeChanged() to distinguish if the user is using a gamepad or keyboard/mouse. From there, you can dynamically switch your UI to either show Xbox controls or keyboard/mouse controls. Same goes for Touch controls. But you can use IsTenFootInterface() to shortcut this and assume to always show Xbox controls.
Note: It is way more user-friendly to use the LastInputType method as opposed to simply checking if a gamepad is connected, because a user might have a connected gamepad but still be using keyboard/mouse.
I find coding for UIS to be really confusing. When I was coding my interface for Redshift Arena to be compatible with Xbox controls, the buttons wouldn’t show up on Xbox, but would show up on PC if you were using a gamepad.
Also, wouldn’t driver-detection for input devices be better? Or could that open up security problems?
As stated previously before, a user could plugin in an N64 controller, PS4 Controller, XBX Controller, or even a NES controller and have the proper buttons show up for that device, if the developer supports it.
Of course, I’m not entirely sure if this is even possible for Roblox to add, but it would still be a cool feature, and could be done if Roblox added in a list of all possible gamepads into an API, among other input devices.
That probably means you are messing with GamepadEnabled which you should never use for input changing/setup, or you were not correctly updating the input mode whenever it changes. You should detect the last input type using UserInputService.LastInputTypeChanged and UserInputService:GetLastInputType(). Your game will be most reactive when you can literally switch input mode at any time, no matter what device you are on or what input mode was initially selected.
Probably best to let the engineers figure that one out. As developers we’d just want an API member that lets us distinguish between layouts.
I’d like to create a companion app for my game based in the same Universe as my game… Without actually being forced to make a companion app for my game… Or a new universe… for my game. See if I were able to discern between a mobile user, a pc user, and an xbox user… I could simply disable most of the need for rendering, and simply show a UI that lets players do things like be able to manage their inventory, repair their ships, or travel to a destination in x amount of time. All from the comfort of their phone while on the go. And when they actually get on the game on their PC. They would be able to actually see that the changes they made on the companion app actually made a difference.
But at this point I’d have to implement it within an entirely different universe, which means that accessing the main games datastore would be out of the question. And since Universe Scripts seem to look past Universe to Universe communication. I’d literally have to implement an external server just to get this functionality. Which could easily be obtained by simply knowing what type of device the user is on. Or I could do conditionals based on assumptions and hope no one falls in the in between.
All of this, simply because I don’t need to know the device type. At this point making a companion app albeit probably against the TOS is easier. Doesn’t make sense in my opinion.