Hi,
I am writing a game for release on PC/Mac through Steam. The game will support both keyboard and gamepad controls. I understand that different controllers map the sticks/buttons to different corresponding axis/buttons referred to by Unity’s Input Manager. That’s fine - I have already designed and written an abstraction layer to deal with that.
From what I’ve read so far, I also understand the following:
-
I can get a list of controllers using Input.GetJoystickNames()
-
That the order of the joysticks reported on this array does not necessarily match the corresponding joystick number in Input Manager i.e. if I press ‘button0’ on the first controller listed by GetJoystickNames() it is not guaranteed that this will be ‘joystick 0 button 0’.
Ideally, what I would like to happen is for the game to be able to detect any connected controllers and default to the first one of these. Why I can’t do this:
-
Input.GetJoystickNames() does not return a list of connected controllers. It will return any controllers listed by Windows in ‘Devices and Printers’ regardless of whether that controller is actually ‘connected’ or not. For example, Unity is still reporting my OUYA controller - despite the fact that it’s not currently switched on.
-
I cannot use Input.GetJoystickNames() to determine which device a particular input (e.g. ‘joystick 0 button 0’) is coming from.
So… what am I missing? How am I supposed to give the game the desired behavior? How are Unity developers supposed to provide decent controller support?
Any help would be appreciated!
Thanks.