- Home /
How to map controls for any controller.
Hello, As the title states i would like to know how to map my games controls to any controller. By this i mean how can i compensate for that fact that on a ps4 controller up and down on the left hand stick is the X Axis while on a xbox controller it is the Y Axis. Is this even possible?
Answer by ArcadeRoyal · Mar 22, 2018 at 11:55 PM
I'm not sure about any possible controller out there, but at the very least for PS4 and XB controllers, the default unity input settings should work pretty well. I am not sure what's causing you to see the X/Y Axis mismatch between the controller types, but that's not how the unity input is set up by default - on both the PS4 and XB controllers, the button with the "X Axis" label is the left-stick horizontal axis, and the "Y Axis" label is the left-stick vertical axis.
This graphic (courtesy Jimmy Vegas - source http://www.jvunity.weebly.com/uploads/4/7/6/0/47606749/controlmap.png) is useful in knowing the button labels to match up with Inputs. The labels correspond very closely between the two controller types.
Just to ensure this was accurate, I tried plugging both an XB and PS4 controller in and using both on a my project, and both responded identically using the default unity Input setup. Is it possible that your input settings of your project have gotten mangled? You can check this by going Edit > Project Settings > Input in unity. I've included an example of what they look like by default, with the horizontal and vertical controller setups expanded for details. I'd double-check your project against that just to make sure it all lines up.
As for other controllers, I'm not sure - I imagine unity's support varies from controller to controller, I doubt there is one single sure-fire way to support every one. PS4 and XB controllers are going to be the vast majority of your install base. If you're going for non-standard controllers, you might check the Asset store? I know for instance there is a package that lets you get input from a Wii remote via bluetooth on there - possibly there are others for the controller you're interested in?
Huh thats odd i specifically remember them not being the same and i searched for the mappings on google and it said that they had different mappings. $$anonymous$$aybe it got changed or i am just massively mistaken. Thank you for your in depth answer.
The Jimmy Vegas mapping image does not appear to be correct for the right stick. Right stick horizontal is 3rd axis and vertical is 6th.
Answer by BlueBananaProductions · Feb 02, 2020 at 10:12 PM
I have an Xbox One controller which seems to have the same mapping as the "Jimmy Vegas" picture above. But the image is not accurate, at least for the PS4. For example, on PS4, X is button 1, not zero, and R2 is 3rd Axis or 7th button. Use this for PS4: https://www.reddit.com/r/Unity3D/comments/1syswe/ps4_controller_map_for_unity/
However I think the bigger issue is that two controllers with similar physical layouts and shared button index number or axis numbers might have conflicting mappings. "X" is button 1 for a PS4 controller, and "A" is button 0 for an Xbox controller, so if you want a game to have X and A do the same thing (because the user might be playing it through Steam, say, with one of the two controllers, and in terms of physically position on the controller these buttons correspond) how do you do it? With Unity's input system it doesn't seem possible, because you'd end up with a configuration where both X and and Square (via PS4 controller, inputs 0 and 1) do the same thing (in game), while also both A and B (on Xbox controller, inputs 0 and 1) also do the same thing.
Best solution I found is to map both separately, like PS4_Action=1
and Xbox_Action=0
. Then use a static Script for "InputSettings" who will provide public property like InputSettings.Action
base on "if you are playing with an PS4 or Xbox Controller". Finally use this property on your code to catch inputs.
Answer by Juandapp · Nov 11, 2021 at 01:31 PM
The mapping of the images given by the user above is accurate if you program for each of those controls, otherwise on Windows at least the one for PS4 is wrong.
Your answer
![](https://koobas.hobune.stream/wayback/20220612155145im_/https://answers.unity.com/themes/thub/images/avi.jpg)