Search Unity

Still Xbox 360 Joypads bug on Windows... unbelievable.

Discussion in 'Editor & General Support' started by ForrestX, Feb 7, 2015.

  1. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    On a note that is related to these fixes, it seems like 4.6.3p2 isn't (always?) using XInput now because triggers are showing up in the DirectInput style both split onto the same axis mode. I'm running Windows 7 Pro x64 with DirectX 11 installed. I'm also still seeing scattered reports of triggers misbehaving with that version of Unity, but haven't been able to replicate it myself yet.
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    Hmm. Bear in mind that it's possible triggers would be showing up both as DI-style same axis and as individual axes...

    I'm still in San Fransisco right now for some post-GDC things, but next week I'll be home and can look further into this stuff if you could help me out with repro information.
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Were you at the Unity booth? I may have met you, but I didn't see a pig wearing a cape. :)
     
  4. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    Yep! Wednesday morning, Thursday afternoon and Friday all day. Yeah I think I may need to invest in a detachable snout or something...
     
    shkar-noori and guavaman like this.
  5. pbhogan

    pbhogan

    Joined:
    Aug 17, 2012
    Posts:
    384
    I did check for multiple axes. Nothing was showing up on any axis except axis 2. Usually the triggers would also show up on axes 8 and 9. Happy to help with any further info you need.

    Ah bummer—I didn't realize you were at the booth Wednesday morning or I'd have said hi and thanks. :)
     
  6. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    57
    I'm working in Unity 5.2.3f1 on Windows 7 right now and I was trying out the 9/10 solution with two 360 controllers plugged in and I found that the left and right triggers on each seemed to be cross talking.

    I have my Inputs set up as Joystick Axis 9th/10th axis and joystick 1/2

    I find that it will pick up some strange combination of both left/right triggers....

    Any advice at all? Am I missing something?
     
  7. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    Do you have the latest XInput DLL installed?
     
  8. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    57
    I have the latest version of DirextX, I thought that it would be included in there?

    I searched my windows folder for XInput and found several versions (this is a fresh install of Windows 7, after allowing windows to update) and I found several versions of XInput (9, 1, 2, an 3).

    Should I try to find a specific version to update with, or is there a redestributable XInput DLL that I need?

    Thanks for the help.
     
  9. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    Oh my bad, it's all installed with Windows these days.

    We first try to load xinput1_3.dll, and if that fails we use xinput9_1_0.dll. You have at least one of those two in your Windows folder, yes?
     
  10. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    57
    They're in sub folders such as System32 and SysWOW64 within the Windows folder.
     
  11. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    57
    Not sure if you received my last response, but I'm wondering if there's anything else I could be doing wrong. I do have the dlls in sub-folders within the Windows folder. Shouldn't that be good enough? Or do I need them directly in the Windows folder?
     
  12. all_iver

    all_iver

    Joined:
    Nov 11, 2013
    Posts:
    159
    I'm suddenly having this issue too. I'm using 3 XBox 360 controllers (1 wired, 2 wireless) and a logitech gamepad. Two of the controllers work ok, but for the other two the triggers do nothing. Unless you press the triggers on both controllers at the same time, and then both work, but one gets stuck on when you release the triggers. I wonder if this is a problem with newer unity versions, or possibly something about my PC's USB configuration has changed? This was never a problem before. Also, everything works fine in the editor - it's in the built version where it gets screwed up. Did you ever find a solution?
     
  13. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    57
    Ah, I actually didn't get this working with unity's built in system. Luckily, I wrap all my input getting code, so I just built a new input module that implements this:
    https://github.com/speps/XInputDotNet
     
  14. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    I was under the impression that most of these issues were fixed several months ago, but I'm experiencing problems when multiple 360 gamepads are plugged in.

    Bug Report #774329.

    Summary:

    If I start Unity with a single Xbox 360 gamepad connected, the triggers are mapped to axis 3 (both triggers) as well as axis 9 (left trigger) and axis 10 (right trigger). This desired behavior remains even if I then connect another 360 gamepad while Unity is still running.

    But if I start Unity with multiple 360 gamepads connected, the triggers are mapped only to axis 3. Axes 9 and 10 are completely ignored. This undesired behavior remains even if I then disconnect extra 360 gamepads while Unity is still running.

    It doesn't seem to change things if I connect or disconnect controllers while Unity is still running. This behavior seems to be determined only by how many 360 gamepads are connected during Unity startup.

    I have tested on Windows 10 in Unity 5.3.3 as well as Unity 3.5.7 (!) and I see the exact same behavior in both, so this has been around for a long time.

    Any response to this, @superpig ?
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Unity uses XInput to map those separate axes 9 and 10 for the triggers because Microsoft's HID driver does not have any way to get separate values for the two separate triggers. Instead, they are combined into a single byte in the HID report, and thus cancel each other out when both are pressed.

    From what I understand (and deduce by observing the behavior), Unity still uses raw input for the other axis and buttons values. Herein lies the problem in my opinion. Unity is trying to combine a raw input device and an XInput device into one joystick. From my research, there is no 100% reliable way to associate a raw input HID device to a particular XInput id number because Windows just doesn't give you this information. XInput gives you no way of determining any raw information about the devices such as device path, handle, or any other such necessary information that would be required to associate the two devices. XInput simply gives you the XInput device type (gamepad) and the XInput device id (0-3). Unity appears to try to pair the XInput device to the Raw Input device based on the order in which the devices appear (of course, correct me if I'm wrong Superpig), which seems to work most of the time, especially with only 1 controller attached, but it does not always work in my testing with multiple devices. This leads to situations where the XInput device may be associated to a different HID device and the loss of those axes, or even potentially the axes activating on the wrong joystick. I've seen these types of issues when you have multiple XInput joysticks attached depending on the Unity joystick id they're ultimately assigned. (If the joystick is assigned to Unity id 5, for example, even with no other joysticks attached, axis 9 and 10 do not work if I recall correctly.)

    Because Unity relies on XInput internally for these axes, it is also subject to the inherent limitations of XInput -- namely, you cannot get information from more than 4 XInput devices. Any devices beyond the limit of 4 cannot use XInput and would therefore be required to use the combined axis value for the triggers. (Raw input has no such 4 device limit.)

    These are my observations on the UnityEngine.Input XInput controller situation on Windows over the last few years. In my opinion, axis 9 and 10 can never be relied upon when using Unity as the input source because of the potential for matching failure depending on the user's controller setup, especially with multiple XInput controllers attached. You are always safe to use the combined axis 3 though.
     
    Last edited: Feb 25, 2016
  16. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Thank you for that detailed explanation @guavaman. But I'm left wondering why I'm experiencing these issues when I have only 3 gamepads connected. Or do my keyboard and mouse also count as XInput devices?

    As you said, using axis 3, both triggers cancel each other out (when both are pressed). I don't consider that "safe" or reliable. That's the appeal of the separate mappings on axes 9 and 10.

    It seems there's just no good solution out there to this problem with Xbox 360 gamepad triggers. :(
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    No, keyboard and mouse don't count. XInput only handles Xbox 360 controllers and compatible, not mouse or keyboard input, or any other game controllers/joysticks that aren't Xbox 360 compatible.

    What Unity id's are your joysticks getting? Like when you call Input.GetAxis("Action"), which id's are being used? I have experienced issues in the past with id's beyond 1-4. Unity does not always assign ids sequentially, especially when plugging in controllers after start. It's possible to have a single joystick plugged in and it be id 5, for example.

    You can use XInput directly instead of UnityEngine.Input and completely solve the issue for Xbox 360 and compatible controllers. XInput.net is an open-source XInput wrapper for C# that you can implement. Or you can use an input system like my Rewired which solves this problem and offers a ton of other features to boot.
     
  18. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    I have two Xbox 360 gamepads and one Xbox One gamepad connected.

    I'm not sure how to get the Unity IDs of the joysticks. Unless you mean Input.GetJoystickNames?

    Thanks. I'll have to look into both of those in more detail soon.
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    You can't actually get the ids, but the way Unity's input system works, you have to have axes set up for each joystick you want to return values. If you want to receive input from joysticks 1-8, you have to have 8 named "axes" set up, each set to receive input from joystick 1, joystick 2, joystick 3, etc. The id of the joystick is that "joystick 1." In versions of Unity beyond 4.5, it should align with the UnityEngine.Input.GetJoystickNames also on Windows. So you could check that. If they're sequential with no gaps in the array, it should correspond to joystick id 1-3.
     
  20. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Thanks for explaining that.

    I unplugged one of my Xbox 360 gamepads to test a report about the triggers not working on a system with one 360 gamepad and one Xbox One gamepad connected.

    Now I have my Xbox One gamepad with an ID of 1 and my 360 gamepad with an ID of 2. The triggers on axis 9 or 10 don't work for either gamepad unless they're pressed on both gamepads simultaneously. >_<

    If I understand correctly, this means that in this scenario Unity is confusing the XInput of one gamepad with the raw input of the other.
     
    Last edited: Feb 26, 2016
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I've not seen that exact issue before but it's plausible given what is going on here with HID <-> XInput device association, which is a highly risky practice at best.

    I didn't catch it in your previous messages, but I see you're using Windows 10. This throws an additional monkey wrench into the works because Microsoft changed the HID driver for the Xbox One gamepad on Windows 10 so it DOES return separate axes for the L/R triggers through the HID driver without the need for XInput. (XInput will still work too though.) The mapping of controller axes for the Xbox One will not match exactly to the 360 on Windows 10, so you may have some issues there also. You may have more limited success by just using 360 pads.
     
  22. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Thanks @guavaman! I appreciate you taking the time to explain these things to me, as well as your suggestions on fixes/workarounds. :)
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    No problem!
     
  24. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    Well, that would explain that one then. We just submitted a bug report for this (822052) and this explains the behaviour we are seeing. The axis are swapped but only update when the correct controller gets a change. Pressing J1LT will set J2Axis9 but only as soon as J2LT is pressed (which will then update J1Axis9)...
     
  25. Deozaan

    Deozaan

    Joined:
    Oct 27, 2010
    Posts:
    707
    Is anyone else here still having issues with triggers being unreliable with multiple Xbox 360 gamepads plugged in? In my tests with Unity 5.4.2f1, I am still having issues where not all gamepads show any value for axes 9 and 10. I finally got a response to my bug report and was told they can't reproduce this behavior in their tests (with only Xbox One gamepads) have been able to reproduce the issue and are working on a resolution. Hooray!

    Here's my test project I used to reproduce the issue, and a gif showing it happen (on gamepads #1 and #3):

    Unity Gamepads.gif
     

    Attached Files:

    Last edited: Oct 25, 2016
  26. HappySloth

    HappySloth

    Joined:
    Feb 27, 2014
    Posts:
    4
    Hello there,
    I have the exact same bug where the triggers of 4 X360 gamepads connected on the same PC running Windows 10 would get "linked" randomly when using axes 9 & 10.
    I use Unity 5.5.0f3 and this bug is present in the editor and in the builds targeting Windows x86.
    Is there any update on an eventual fix for this problem?
     
  27. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    To be honest, if you are targeting Windows, you might as well use XInput directly.
     
  28. HappySloth

    HappySloth

    Joined:
    Feb 27, 2014
    Posts:
    4
    I think this is what I will do for the moment.
    I hoped to be able to port my game to Mac and Linux in the future and if I understand correctly XInput isn't compatible on these systems?
     
  29. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    The amount of time that you would have to spend on making sure Unity works across all three platforms would be huge.

    The best solution that works across windows/mac/linux is Rewired. It is a third party solution but the only one with native input on all 3 platforms. It works great with flight controllers too on all three platforms but see the supported controllers list for a complete list. (http://guavaman.com/projects/rewired/docs/SupportedControllers.html)

    Rewired is currently on sale via Unity's wish list sale.

    https://www.assetstore.unity3d.com/en/#!/content/21676

    Forum thread:
    https://forum.unity3d.com/threads/rewired-advanced-input-for-unity.270693/

    The best part is you can get the trial version of Rewired at least test it out before purchase.
    http://guavaman.com/projects/rewired/trial.html
     
    Last edited: Mar 2, 2017
    Dave-Carlile likes this.
  30. HappySloth

    HappySloth

    Joined:
    Feb 27, 2014
    Posts:
    4
    Thanks for the tip, I'll have a look into this :)
     
  31. Radenium

    Radenium

    Joined:
    Jan 20, 2018
    Posts:
    1
    This is still a thing. I have two Xbox 360 controllers and one works fine. I plugged in a second one and it either has no inputs, wrong inputs (actions that should happen with one button happen on another instead) or it will activate P1 inputs as well. How is this still a thing? I can see how old this thread is and this is still a problem.