I’m currently developing a project that only supports PC input. I was considering adding support for Xbox, but I realized that implementing proper support for both Xbox and PlayStation controllers could be quite complicated.
My question is: if an Xbox or PS5 user connects a keyboard and mouse to their console, will the controls function the same way as on a PC? In other words, would I not need to implement any additional changes for keyboard and mouse input on consoles?
I believe that it would be passed as regular keyboard input. This is documented here, most notably the input preference enum:
“Player is using an Xbox or PlayStation with a bluetooth keyboard & mouse connected and has most recently interacted with the keyboard or mouse. KeyboardAndMouse”
In short, yes. Input events processed by Roblox are decoupled from the HID (keyboard, mouse, controller, touchscreen, etc.) that triggered them via representation as an InputObject.
A few general guidelines to consider:
DO NOT USE ContextActionService. It is (or soon will be) deprecated in favor of the Input Action System (IAS) that @ig1oo1 mentioned.
Be aware, UserInputService boolean properties such as KeyboardEnabled, GamepadEnabled, TouchEnabled, etc. are not necessarily the input that the player is actively using. It is essential to track which input type is currently being using by a client either via LastInputTypeChanged or PreferredInput as @sac_ie mentioned. And this value may change throughout the session (ex. A player connects a controller to a PC some time after joining).
If you plan on supporting mobile devices, please consider modifying the default value of StarterGui.ScreenOrientation. The default value is Sensor, however, for most games, this should be set to LandscapeSensor.
To avoid making more work for yourself, design UI to support any input device - in particular, leave room for the default touch controls.