Xbox one controller mapping [SOLVED]

Hello!

I wasn’t exactly sure where to put this so i figured i would add a question and then post and answer for it! I had been searching around and couldn’t find a list of the controller mapping for an xbox one controller, on windows 10, in unity 5. So i went ahead and mapped all the buttons and axis.

Hope this helps some one!

EDIT: Guess i can’t answer my own question (or im just dumb :P) but heres the mapping!

PS: If someone knows a better place to post this let me know and i can post it there or move it!

2 Likes

Thank you very much @tag104367 and @nadhimali for creating the images.

Based on your pictures and the table from here, I combined both information to one image for Windows and macOS and thought it might be worse sharing.

Note for macOS:
The binding is based on this driver (works for Xbox 360 and Xbox One controller).

For any other controller see this very nice thread: Finding Joystick Mapping Inputs with Unity

For more details (InputManagerSettings and use in C# script) see:

I wanted to upload the images as one .pdf file as well but apparently its to large.

Anyway I hope it helps :).

Best regards,

Bredjo

Just to add a reference for people !

This is the correct map according to my tests

I’m on Unity 5.6.1f1 using a wired Afterglow controller, and the right joystick axes are switched from what’s on this diagram (mine gives axis 4 for horizontal and axis 5 for vertical).

Apart from Trigger everything works. Any Ideas?

The front triggers are 9th and 10th axis on some controllers and are shared as a single 3rd axis on others.
So if you have a shared 3rd axis for the two front triggers it is only good to control one thing. One trigger creates a positive input and the other a negative input.

Hi there I’m still having trouble with my triggers not working, everything else seems to work fine except the triggers. Any ideas?

@tag104367

On my Xbox One controller (4N7-00002) the axes of the right analog stick are switched: Vertical is 5 and horiontal is 4 (so like in Bredjo’s image). Btw, with this model LT is indeed the 9th axis and RT the 10th axis (Type: Joystick Axis, Axis: 10th Axis (Joysticks), Joy Num: Get Motion from all Joysticks). I would recommend using some kind of time check, otherwise it’s way too sensitive (it’ll trigger every frame):

if(Input.GetAxis("RT")>0 && (Time.time-lastPressRT)>betweenPresses) { //"betweenPresses"=0.3f (->1 press every 0.3 seconds)
    //Do stuff
    lastPressRT = Time.time;
}

A list of the controller mapping for an xbox one controller, on windows 10, in unity 5. Too much cached data can cause various problems, and the error code 0x80072ee7 might not be the exception.

Triggers use 9th axis. You can use it as an axis or a button, axis is float from -1 to 1, button is a bool.

My (getaxis) example in the InputManager, and an example of how to use it in code:

alt text

alt text

FYI - Gamepad riggers are working with new Input System (Gamepad Support | Input System | 1.0.2) running 2019.4.11f1 on a Mac using a Xbox controller (original Microsoft, 3rd party controller will not connect to Mac using Apple’s built in driver). Example visualizer scene worked for all axis and buttons.

However, with old Input Manager (required by many Unity Assets), trigger axis are not working, per above.

Mapping is also different than above in old Input Manager on Mac using Apple’s driver:

// left stick
float axisX = Input.GetAxis("Joystick Axis X");
if (axisX < -axisDead || axisX > axisDead) Debug.Log("Joystick Axis X = " + axisX);
float axisY = Input.GetAxis("Joystick Axis Y");
if (axisY < -axisDead || axisY > axisDead) Debug.Log("Joystick Axis Y = " + axisY);

// right stick
float axis3 = Input.GetAxis("Joystick Axis 3");
if (axis3 < -axisDead || axis3 > axisDead) Debug.Log("Joystick Axis 3 = " + axis3);
float axis4 = Input.GetAxis("Joystick Axis 4");
if (axis4 < -axisDead || axis4 > axisDead) Debug.Log("Joystick Axis 4 = " + axis4);

// dpad
float axis5 = Input.GetAxis("Joystick Axis 5");
if (axis5 < -axisDead || axis5 > axisDead) {
  float axis6 = Input.GetAxis("Joystick Axis 6");
  if (axis5 ==  1 && axis6 ==  1) Debug.Log("DPad Right");
  if (axis5 == -1 && axis6 ==  1) Debug.Log("DPad Down");
  if (axis5 ==  1 && axis6 == -1) Debug.Log("DPad Up");
  if (axis5 == -1 && axis6 == -1) Debug.Log("DPad Left");
}

// trigger axis not found

// button A
if (Input.GetButtonDown("Joystick Button 1")) Debug.Log("Joystick Button 1 clicked");
// button B
if (Input.GetButtonDown("Joystick Button 2")) Debug.Log("Joystick Button 2 clicked");
// button unused
if (Input.GetButtonDown("Joystick Button 3")) Debug.Log("Joystick Button 3 clicked");
// button X
if (Input.GetButtonDown("Joystick Button 4")) Debug.Log("Joystick Button 4 clicked");
// button Y
if (Input.GetButtonDown("Joystick Button 5")) Debug.Log("Joystick Button 5 clicked");
// button left bumper
if (Input.GetButtonDown("Joystick Button 7")) Debug.Log("Joystick Button 7 clicked");
// button right bumper
if (Input.GetButtonDown("Joystick Button 8")) Debug.Log("Joystick Button 8 clicked");

// button start
if (Input.GetButtonDown("Joystick Button 12")) Debug.Log("Joystick Button 12 clicked");

Any name for the Home button?

Hello, my game controls are perfect on Windows 10 but they don’t work at all on XBOX (UWP BUILD)
How can I solve this problem? My game was already approved and on the Xbox store, I had to hide it.

Is this mapping the same for vanilla X-Box and X-Box 360 controllers?

For me all buttons work except 9th and 10th axis. I had to use 3rd axis for both triggers, Left trigger set to inverted in the input manager. Maybe 9th and 10 axis work in Unity’s new input system.

Awesome resources! Thanks to everyone who posted

Sorry for the Necro but I has a “hard time” finding the answer for the Left & Right Triggers so here’s the answer.


Unity side

  • You set the name
  • You let Positive Button empty
  • Type => Joystick Axis
  • Axis => 10th axis (Joysticks) (if you want RT for a xbox controller)

Code side

Since their values are between 0 and 1 so you have to use the GetAxisRaw()

if (Input.GetAxisRaw() > 0.5f) //for
example

thanks for everyone!

just like this!

My older brother is trying to make a game and he wants to add controller compatibility.
What does the Right Trigger input look like in a input axis in the input manager?
Show an image like this:

The axis is 10th because people say that’s the right trigger’s axis.

@ExplodingCreeperMakesGames

@Jerem_ , gave a working example at least for Xbox one controllers

"Unity side

You set the name

You let Positive Button empty

Type => Joystick Axis

Axis => 10th axis (Joysticks) (if you want RT for a xbox controller)

Code side

Since their values are between 0 and 1 so you have to use the GetAxisRaw()

if (Input.GetAxisRaw() > 0.5f) //for example"