More robust identification of gamepads

One problem I have with the current input system is there’s only one way to determine what kind of joysticks are currently connected: using Input.GetJoystickNames(). While this is kind of nice, the name of a joystick is often inconsistent across OSes and even driver versions.

For example, I have an Afterglow Xbox 360 controller. Sometimes the name comes up as “Controller (Afterglow Gamepad for Xbox 360)” and sometimes it comes up as “Afterglow Gamepad for Xbox 360 (Controller)”. To make matters worse, it’s completely different on Linux and OSX.

It’d be great to be able to poll more information about a joystick, such as its vendor and model number, or device IDs, or something. Something that will be consistent across OSes, dependent on the hardware itself rather than drivers. Is this something planned in the new input system, or at least something you can do?

We likely can’t query that kind of info in a consistent manner. It’s the driver’s responsibility, and the drivers reporting inconsistent data is the problem to begin with.

The device profile system (which relies on us having our own database full of info about various input devices) is our attempt at working around that, but we use it primarily to ensure consistent mappings. We don’t currently have plans to also use it to supply info about vendor and model number, etc. May I ask what you would use this information for, so that I can better understand the use case and potential solutions?

Well, for example, I have a certain PSX controller adapter that shows up as an empty string in Unity on Windows. It shows up in the Windows control panel as simply “4 axis 16 button joystick”, which must be some kind of generated name. However, Unity on Linux calls it “HID 6666:0667”, which is consistent with the numbers reported by Windows for the Hardware IDs (“HID\VID_6666&PID_0667”). These are obviously placeholder values from some sort of cheap, lazy manufacturer but would be useful nonetheless, certainly more useful than an empty string.

My use case is actually very similar to your device profile system, mapping joystick axes/buttons to human-readable strings like “A Button”, and also setting up default profiles for these joysticks on a per-game basis. GetJoystickNames() is just a bit too limiting to really use effectively. It’d be great to at least be able to query whether a gamepad supports XInput, or ForceFeedback, or some other feature.

So I’m hoping these features can be implemented in the new input system. Providing more information at the disposal of developers is certainly better than providing less!

Use case:

Player has both a gamepad and another device (such as flight sim paddles) plugged in. You’d want to know which is the gamepad and which is the flight peddles (so you can ignore peddle input) but I’ve found (at least in the old input system) that this distinction isn’t easily made, and so certain axis on the flight peddles will register as gamepad movement.

Use case:

Some situations require the mapping between device and player number to be stable across restarts. This is really important when playing a game in public. Think tournaments, trade shows, store kiosks, arcade cabinets, art installations, places where players can’t or won’t swap controllers if they’re controlling the wrong player and can’t rebind controls. The more information available, the better, up to and including an ID for the port it’s connected to (if available).

For this case, a fingerprint UID specific to the individual input device would work just as well. I just need to know that e.g. the pad that I assigned to player 1 the first time is always and forever assigned to player 1 across all space and time.

Unity’s always been frustrating to deal with for this. Built-in enumeration order often flips between sessions.