Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Controller Inputs

Discussion in 'Editor & General Support' started by drJones, May 28, 2007.

  1. drJones

    drJones

    Joined:
    Oct 19, 2005
    Posts:
    1,351
    i've got a 360 controller now have been testing the buttons - i can get all but 2 to work - the larger (lower) triggers or shoulder buttons. what i've figured out so far:

    joystick buttons:

    00 =
    01 =
    02 =
    03 =
    04 =
    05 = hat up
    06 = hat down
    07 = hat left
    08 = hat right
    09 = start
    10 = back
    11 = left analog click
    12 = right analog click
    13 = shoulder top left
    14 = shoulder top right
    15 = xbox
    16 = a
    17 = b
    18 = x
    19 = y

    i also don't understand why i have five open slots at the beginning but only two missing buttons - none of these slots get any response from the triggers (or anything).

    for reference i have the axes for the analogs set up as follows (this works fine):

    move horizontal = X axis
    move vertical = Y axis
    look horizontal = 3rd axis
    look vertical = 4th axis

    anybody have any experience with this?
     
  2. drJones

    drJones

    Joined:
    Oct 19, 2005
    Posts:
    1,351
    bump - anyone?
     
  3. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    But aren't those analog like the thumb-sticks? If so then they might not be treated as "buttons" and not appear in this list. As to why there are open slots, maybe they initially imagined an even larger set of buttons early on (and collapsing to use the lower spaces might have broken content already in the works)? I just don't know what those empties would be as I don't have any direct experience here, sorry...

    Hope that helps, or at least makes this a less lonely thread. :p
     
  4. drJones

    drJones

    Joined:
    Oct 19, 2005
    Posts:
    1,351
    hmm, that does make sense but i just ran through them all (joystick axes) nothing seems to work. evrything else works great - just can't get these two(important) triggers going...

    ; )
     
  5. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    I just sent you a reply to our PMs on this issue. The weird thing is I can get the triggers to work on the 5th and 6th axes, but my mappings for the buttons are slightly different than the ones you listed. Could this be a driver issue. I'm still on version 0.02 of Colin Munro's 360 driver since I really haven't experimented with with the 360 controller inside Unity in a while (I use it all the time for emulators though and it works great).

    Let us know if you get the triggers working (and on what axes)... I had no problem mapping them to 5 and 6. Maybe I'll go through all the buttons and axes right now and post a list to see just how different our configurations actually are.

    Ethan

    [Edit- Quick and dirty rundown of my 360 buttons]

    Button 0 - nothing
    Button 1 - nothing
    Button 2 - DPad Up
    Button 3 - DPad Down
    Button 4 - DPad Left
    Button 5 - DPad Right
    Button 6 - Start
    Button 7 - Back
    Button 8 - Left Analog Stick Press
    Button 9 - Right Analog Stick Press
    Button 10 - Left Shoulder Button
    Button 11 - Right Shoulder Button
    Button 12 - XBox Button
    Button 13 - A
    Button 14 - B
    Button 15 - X
    Button 16 - Y
    Button 17 - nothing
    Button 18 - nothing
    Button 19 - nothing

    Analog Stick Axes Same as drJones

    5th Axis - Left Trigger
    6th Axis - Right Trigger
     
  6. drJones

    drJones

    Joined:
    Oct 19, 2005
    Posts:
    1,351
    hmm - no luck here (i just retried all the axes with the gravity-dead-sesitivity settings you sent). i think you're right it might be a driver issue as i'm using the latest .05 - i'll play with it some more though.

    thanks antenna ; )
     
  7. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Well after playing around with the 360 controller again today in an FPS setting with Unity I must say that it would be great to standardize the inputs of this controller so we could safely make it a solid option for Unity games. Does OTEE have any more input into how the 360 controller coud work as a standard controller without any of these problems?
     
  8. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    A solid and consistent set of drivers? Documentation as to what folks should expect out of the controller? Sorry but I'll admit once again that I'm not very experienced with using the 360 controller on a Mac/PC but from the "outside" it seems as if it's not well put together just yet... Please feel free to direct me to any links for info that you have as I'd definitely like to read up on this a bit more (doing some searching on my own as well but anything you have handy would help speed my efforts :) ).
     
  9. drJones

    drJones

    Joined:
    Oct 19, 2005
    Posts:
    1,351
    you've probably seen this already but here's the site where the driver is located hig:

    http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/OsxDriver

    i was thinking of just sending a message to him but the thing is it works fine in the driver control panel (the triggers register in the built in tester) - so it would seem to me its unity that is having the issue. i'll continue testing it when i get the time.

    you're right though - the driver is still young at this point (the mapping has changed at least once already) so its hard to say.
     
  10. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    Yep, I've seen that link, thanks for making sure though. The problem here is that it will be very hard for us to do much of anything when this is 3rd party unofficial driver sets that are changing (often?). Don't get me wrong, I like the direction you're going with this and it's worthy of discussion, but it's just that I'm a bit hesitant when it comes to spending any of our time/energy as we have so much other work to do.

    If/when we have some spare bandwidth I hope we can take a look at this a bit closer, until then I fear you're entering the land of the unknown without us. Be brave! :p
     
  11. sbuchbinder

    sbuchbinder

    Joined:
    Apr 4, 2008
    Posts:
    53
    Not sure I'll be much help, but I've done some XNA programming and the difference between the axis of the thumbsticks as opposed to the triggers is that the thumbsticks go from -1 to 1. the triggers just go from 0 to 1.

    Again, not sure if it helps...just offering some info...
     
  12. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    Hi,

    I realize there's a bunch out there on this topic, but I'm still having trouble getting any axis controls to work. Buttons work fine, but the axis doesn't seem to see it.

    Code (csharp):
    1. var cubeSpeed : int;
    2.  
    3. function Update ()
    4. {
    5.   var x = Input.GetAxis("Horizontal") * Time.deltaTime * cubeSpeed;
    6.   var z = Input.GetAxis("Vertical")*Time.deltaTime * cubeSpeed;
    7.   transform.Translate(x, 0 , z);
    And in the input manager I've set the Horizontal to:
    Type joystick Axis
    Axis 7th axis(joysticks)

    Any help would be appreciated. Thank you. :)
     
  13. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    @ProfCWalker:

    1. Welcome to the forums! :D

    2. When posting code, use the "Code" button, or manually wrap your code in code tags ([ code ]...[ /code ], without the spaces) for better formatting (I've edited your post as an example).

    3. I'm not sure your question really warrants tacking on to the end of someone else's thread. You'll likely do better by posting in your own thread and starting something anew.

    Your code in general looks ok, does it work when using the arrow keys and/or WASD? How are you verifying that things are "working" versus not? What do you set cubeSpeed to in the inspector? I see that you're not properly closing your Update function with a trailing }, is that a copy/paste error or is this all due to that and you're not noticing the script/compile error?
     
  14. bloobat

    bloobat

    Joined:
    Jun 15, 2009
    Posts:
    63
    Wait.. so Unity can make Xbox360 games for the 360? Just wondering (I know it's not completly related to the subject but I had to ask).
     
  15. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    No, Unity cannot yet support the creation of XBox titles (neither retail nor XBLA). This is a discussion about using controllers with desktop computers, and one controller folks like to use is a XBox 360 controller by installing the required drivers.
     
  16. bloobat

    bloobat

    Joined:
    Jun 15, 2009
    Posts:
    63
    Ohh ok. Thanks for the info! :p But do you know when exactly it will be allowed on xbox consoles?
     
  17. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    Thank you for the quick reply.

    1. Yep, it was just a code snippet I pasted in.

    2. Thank you for the Code cleanup on the previous post.

    3. WASD works with it.

    My initial 'checking' for the 360 controller was testing it at: http://www.rotorheadgame.com/unity/joytest.html. Everything worked in terms of response.

    My cubeSpeed was just a var multiplied by Time.deltaTime and assigned to objects transform, which works with the keys.

    If you think starting a new thread would work better, I would be happy to do it. :)

    Thank you!
     
  18. HiggyB

    HiggyB

    Unity Product Evangelist

    Joined:
    Dec 8, 2006
    Posts:
    6,183
    No. This has been asked a number of times here on the forums so search around for prior threads. We haven't announced anything so there's just no information to share at this time. Let's get back on topic please. :)


    Odd, perhaps you can check with whoever made that demo? Sorry but I'm just not adept at X360 controller issues and was hoping to catch some low hanging fruit here (like cubeSpeed of zero or a script error). :p

    For now we'll roll with it here. :)


    Anyone out there with first-hand X360 controller experience, please chime in!
     
  19. bloobat

    bloobat

    Joined:
    Jun 15, 2009
    Posts:
    63
    Oh yeah ok. Sorry about that. :oops:
     
  20. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    Just wanted to let you know I got it working. I'll post a complete packet and write up on this shortly for those that need assistance.

    Thanks
     
  21. clarky

    clarky

    Joined:
    Apr 3, 2009
    Posts:
    4
    Hi All, just came across this thread while trying to figure out getting the 360 controller to work with unity. ProfCWalker, your last post "Just wanted to let you know I got it working. I'll post a complete packet and write up on this shortly for those that need assistance." I'm wondering if you managed to complete the packet? and or if you would be willing to share your solution.

    Thanks
     
  22. mainman

    mainman

    Joined:
    Mar 24, 2009
    Posts:
    2
    I came also at this post by 'googlin' but it seems there isn't an answer for a correct 360 controller configuration. :roll:
    plz notice me if there is any...
     
  23. profcwalker

    profcwalker

    Joined:
    May 3, 2009
    Posts:
    243
    Hi,

    Here's a simplified working example for you. Let me know if you have any issues with it.

    Thank you,
    Walker
     

    Attached Files:

  24. mainman

    mainman

    Joined:
    Mar 24, 2009
    Posts:
    2
    At first glance it seems to work. Thanx for uploading the source!
     
  25. clarky

    clarky

    Joined:
    Apr 3, 2009
    Posts:
    4
    Thanks for the source code I've not had time to evaluate yet but really appreciate the help I will let you know how I get on with it. :p
     
  26. lakehaze

    lakehaze

    Joined:
    Mar 7, 2011
    Posts:
    24
    Thanks so much Mr Walker for that example scene file. It will do wonders for my trouble shooting, I'm sure.
    Unfortunately, nothing happens for me in that scene.

    I'm running Win7 32bit, using a wired xbox360 controller that works fine in Magicka, LiveForSpeed, and LevelR. I haven't messed with any drivers, just plugNplay as far as I can tell.

    I have restarted the machine with the controller plugged in. I am focusing the game window on playback. I can't think of anything else I could be doing wrong. I see your player cube in his little corral and the script is activated, but nothing responds to any controller input.

    Is there something else I'm supposed to do to configure that scene file?
    Thanks again :)
     
    Last edited: Aug 16, 2011
  27. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Since this post is 4 years old, the project was probably built during the Unity 1.x days. Although the Input Manager hasn't changed much since then, I wouldn't expect a project built that long ago to work with 3.x. You might want to start from scratch. I don't have an x360 controller otherwise I could give it a test for you. All my joysticks are Logitech's which so far have worked well (as long as only one is plugged in).
     
  28. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Speaking of the Dpad, i am working with the Antares Universe and I need to get the Dpad and triggers working... but there seems to be no way to get them working (using the drivers from Microsoft)... and i used Professor walkers packet and it works :), but now for my own project, nothing is happening :(
     
  29. ASMach

    ASMach

    Joined:
    Nov 26, 2011
    Posts:
    43
    In case anyone finds this useful, these are the inputs for an XBOX 360 USB controller on Mac OS X 10.7 Lion, in Unity 3.4.2


    00 = ?
    01 = A
    02 = B
    03 = X
    04 = Y
    05 = LB
    06 = RB
    07 = Left Stick Button
    08 = Right Stick Button
    09 = Start
    10 = Back
    11 = Xbox
    12 = D-Pad Up
    13 = D-Pad Down
    14 = D-Pad Left
    15 = D-Pad Right
    16 = A
    17 = B
    18 = X
    19 = Y

    Analog Sticks + Triggers:

    X/Y-Axis Controller = Left Stick
    X/Y-Rotation Controller = Right Stick
    Z-Axis Controller = LT
    Z-Rotation Controller = RT

    If anyone has any idea what button 00 is, please post it.
     
  30. NCarter

    NCarter

    Joined:
    Sep 3, 2005
    Posts:
    686
    Let's resurrect this ancient thread one more time!

    I just bought an Xbox 360 controller and tried running it with version 0.11 of the Tattiebogle driver, OSX 10.6.8 and Unity 3.5. I got this mapping:

    Code (csharp):
    1. X Axis      Left stick X
    2. Y Axis      Left stick Y
    3. 3rd Axis    Right stick X
    4. 4th Axis    Right stick Y
    5. 5th Axis    Left trigger
    6. 6th Axis    Right trigger
    7. Button 0    Unknown
    8. Button 1    Unknown
    9. Button 2    Unknown
    10. Button 3    Unknown
    11. Button 4    Unknown
    12. Button 5    Dpad up
    13. Button 6    Dpad down
    14. Button 7    Dpad left
    15. Button 8    Dpad right
    16. Button 9    Start
    17. Button 10   Back
    18. Button 11   Press left stick
    19. Button 12   Press right stick
    20. Button 13   Right shoulder
    21. Button 14   Left shoulder
    22. Button 15   Xbox button
    23. Button 16   A
    24. Button 17   B
    25. Button 18   X
    26. Button 19   Y
    ...which is completely different to any of the mappings listed above! Not sure what to make of that. It seems to me that there's no way you can rely on a particular mapping working for any given user of your game.

    It also points to the need for a better way of handling and configuring input in Unity....
     
  31. KyleHatch85

    KyleHatch85

    Joined:
    Dec 13, 2011
    Posts:
    99
    I was having to map a controller for work and was getting annoyed with things not being up to date for 3.5 so i wrote this. It's a test application to help map the controller. The actual only change i noticed from Unity 3.4.2 was the 4th and 5th axis seem to be swapped.

    If there are any issues just let me know.

    You should just have to unzip the assets and project settings folder into a blank project.

    Enjoy!

    View attachment $Input Test Improved.zip
     
  32. Sock Puppet

    Sock Puppet

    Joined:
    Jan 9, 2011
    Posts:
    77
    NCarter - I totally agree the Input system in Unity is in desperate need of a rethink.

    KyleHatch - I tried out the test file. It doesn't match the layout of my xbox360 controller (I don't think it was meant to) but it proves NCarter's point.

    [Warning - rant ahead...]

    At the moment the only way (that I know) of detecting what devices are connected is Input.GetJoyStickNames() which just returns an empty string in some cases. (I've file a bug report).

    This means I can't even rely on the hacks I've come up with to fix weird issues such as the triggers registering different values before they are first pressed.

    There needs to be a reliable method of detecting both the device and the driver being used. Then at least you can create profiles for the different combinations and be able to tell your customers what setups are supported. Or Unity themselves need to provide a list of devices and drivers they support and what the expected output from the device should be.

    Input is so important in games and nothing makes me put one down faster that when it's poorly implemented.

    I've mentioned this before but there needs to be a OOP way of accessing inputs that doesn't rely on strings. That would also help to abstract input from game logic making cross platform development easier. There's a couple of Input managers on the asset store but all fall short for me because of this limitation.

    My gold standard for input is Portal2. You can seamlessly switch between devices and it just works. It also changes the gui icons to match the device you are using. This is what I aspire to in my own games but the input implementation in Unity is making it very hard work.

    If anyone has any suggestions in case i'm approaching any of this wrong or how I might get lower level access to input devices that for both Mac and PC I would be much appreciated. I'd rather support a few devices very well than a whole bunch in a hodge-podge manner.

    [..and relax]
     
  33. paverson

    paverson

    Joined:
    Jul 17, 2012
    Posts:
    11
    Just coming into this conversation, but (for us visual folk) hopefully this will help. This is using Tattie Bogle.
     
  34. drecuk

    drecuk

    Joined:
    Jul 19, 2012
    Posts:
    1
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    After 2 years of suffering with these and other oversights and after giving up all hope that anyone was even paying attention to this long lost corner of code, it looks like there might be a light at the end of the tunnel. Unity 4.x (not initial release, but "an early version") is supposed to FINALLY make some improvements to the Input system. See CreativeChris's post here. The only reason I paid for the Unity 4 preorder upgrade was the faint hope that they might someday remember about Input. It looks like that gamble may have been worth it after all. (Keeping fingers crossed.)
     
    Last edited: Oct 9, 2012
  36. Merrik44

    Merrik44

    Joined:
    May 8, 2013
    Posts:
    38
    I made a little package that contains an InputManager.asset with all the axis set up and a wrapper that makes accessing them simple and intuitive. Hopefully it will save some time and headaches.
    You can download it here.

    Example:

    Code (csharp):
    1. Gamepad.GetButtonDown(Gamepad.Button.A, Gamepad.Index.One);
    2. Gamepad.GetAxis(Gamepad.Axis.LeftStick, Gamepad.Index.Two);
    3. Gamepad.GetTrigger(Gamepad.Trigger.Left, Gamepad.Index.One);
    4. Gamepad.GetState(Gamepad.Index.Four);
     
    Last edited: Jul 14, 2013
  37. Neonalig

    Neonalig

    Joined:
    Jun 25, 2016
    Posts:
    1
    According to the ETC Internal Unity3d Wiki:
    http://wiki.etc.cmu.edu/unity3d/index.php/Joystick/Controller
    Microsoft Xbox 360 Controller
    Buttons (Key or Mouse Button)

    joystick button 0 = A
    joystick button 1 = B
    joystick button 2 = X
    joystick button 3 = Y
    joystick button 4 = L
    joystick button 5 = R
    joystick button 6 = Back
    joystick button 7 = Home
    joystick button 8 = Left analog press
    joystick button 9 = Right analog press

    Axis (Joystick Axis)
    X axis = Left analog X
    Y axis = Left analog Y
    3rd axis = LT/RT
    4th axis = Right analog X
    5th axis = Right analog Y
    6th axis = Dpad X
    7th axis = Dpad Y
     
    Last edited: Aug 2, 2017
  38. JacksonTheXtremeGamer

    JacksonTheXtremeGamer

    Joined:
    Jun 15, 2019
    Posts:
    108
    I'm using an Xbox One controller. Here are my buttons:
    0 = A
    1 = B
    2 = Y
    3 = X
    4 = LB
    5 = RB
    6 = SELECT
    7 = START
    8 = LEFT STICK PRESS
    9 = RIGHT STICK PRESS

    10 to 16 do nothing, at least not yet. But I want to move the camera with the right stick. Any inputs for that?
     
  39. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,816