Monday, March 26, 2018

unity - Unity3D Joystick Buttons Xbox360 & PS3 have Inconsistent Button Inputs?



I've been browsing through Google and researching button inputs in Unity, and I came across this page. When looking at it I noticed that the B button on the Xbox360 controller is set to Button 1, but Button 1 on the PS3 controller is set to X.
On a side-note, I noticed that BlazBlue: Continuum Shift EXTEND on Steam also has this issue when it comes to button inputs as an Xbox360 Controller inputs exactly as shown and a PS3 controller uses Square for Confirm and X for Cancel.
Does this inconsistency in buttons exist and how can I fix this problem so that A=X, B=O, X=Square, and Y=Triangle for my Windows-distributed game if it does? I guess a more appropriate question would be what the button mappings are for PS3 and Xbox360 formatted controllers?



Answer



Yes, PS3 controllers are a different configuration than the Xbox controllers. XBox maps to XInput while PS3 is proprietary.


If you treat Button 1 on all joysticks as the fire button, then yes it will be inconsistent. The problem gets even worse if you assume the axis's are the same.


Fortunately, you can map them however you want in Unity's Input Manager. Just don't rely on the ordering of buttons. Map the controllers to actions and then you don't need to worry about if the controllers match or not.


On the downside, if you want to support many different controllers that may have varying configurations, then you may be limited by using the input manager. This isn't a problem though until you have 80 mappings or more than 17 different controller devices to support.


Fortunately, most aftermarket controllers are DirectX compatible, meaning they will conform to the xbox configuration.


In the unlikely event you need to support lots of different devices, you might want to look at Unity Custom Input Manager. It's free, and even if you don't need to support so many devices, it's worth investigating. It lets you do some things that the builtin Input Manager won't. Like modifying the mappings at runtime (EG, let the player customize the mappings in-game).



No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...