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

[Bug] Gamepad Triggers interfere with Left Analog X Axis

Discussion in 'Input System' started by Zethros, Jul 28, 2016.

  1. Zethros

    Zethros

    Joined:
    Jan 11, 2013
    Posts:
    12
    Report Date: July 27th, 2016
    Prototype Version Date: April 6th, 2016
    Unity Version: 5.3.5f1 (Personal)

    Affected Gamepads:
    • Logitech F510 (XInput)
      • Also happens in D-Input, however, instead of Left Any Trigger, it is the Right Analog Stick.
    • Playstation 3 Controller

    How does it intefere?
    Pressing the Left Either Trigger resets the Left Analog's X Axis to 0. Moving the Left Analog's X axis enough (very small amount, equavilent float value of about 0.15) will refresh the axis and make it retrieve the real value. This interference does not happen with the second/right analog stick.

    What leads do you have as to why?
    Logitech F510's Left and Right Triggers work together on a third Axis (much like an Xbox Controller, I believe). For one reason or another, I think the prototype has the third axis interacting with the X Axis for this controller. At runtime, if I open the Input Manager and switch "Analog3_Joy1"'s axis from "3rd Axis" to something nonexistant on this controller, such as "24th axis", the interference no longer occurs.


    I will update this post/thread as I find more information. With the prototype resetting the Input Manager back to its preferred defaults, I will have to dive into the code to have a full idea of what exactly is causing the problem and how I can override it as a work around until the bug is resolved.

    ********************************
    EDIT - Same day - 11:45 PM
    ********************************
    Created a Work around

    The following edits to the following files DISABLES both triggers (L2/R2). Luckly for my game, I won't need them and this work around may help other developers in the meantime...
    Code (CSharp):
    1. // JoystickInputToEvents.cs
    2. private void SendAxisEvents()
    3. {
    4.     int first = 1;
    5.     int last = 10;
    6.     for (int device = 0; device < joystickCount; device++)
    7.     {
    8.         for (int i = 0; i <= last - first; i++)
    9.         {
    10.             // v **new** v
    11.             if (i == 2) continue;
    12.             // ^ **new** ^
    13.             var value = Input.GetAxis("Analog" + (i + first) + "_Joy" + (device + 1));
    14.             SendEvent(device, i, value);
    15.         }
    16.     }
    17. }
    Code (CSharp):
    1. //InputManagerAssetGenerator.cs
    2. for (int device = 1; device <= JoystickInputToEvents.joystickCount; device++)
    3. {
    4.     for (int analog = 1; analog <= JoystickInputToEvents.axisCount; analog++)
    5.     {
    6.         // v **new** v
    7.         if (analog == 3) continue;
    8.         // ^ **new** ^
    9.         axisPresets.Add(new AxisPreset(device, analog));
    10.     }
    11. }
     
    Last edited: Jul 28, 2016
  2. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    I can confirm this is happening with 360 controllers as well. Super not ideal in the prototype that I'm currently working on. Are there any plans to release newer versions of the prototype input system we're all currently playing around with?
     
  3. Zethros

    Zethros

    Joined:
    Jan 11, 2013
    Posts:
    12
    More than likely "yes", however, no one knows when.
     
  4. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    470
    I just ran into this, sucks as the system does everything else I need fine.

    Is there going to be an update about status of the new input system? I have a bad feeling this whole project may get scrapped and redone like the GUI was.
     
  5. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    Yeah I am in a similar place. Aside from this one bug I feel like I would be comfortable releasing smaller personal projects written against this. This is pretty much t he only show stopper I've found in there so far!
     
  6. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    For the prototype we only created device profiles for Xbox 360 controllers on Mac and Windows. No other gamepads are supported in the prototype, as stated in the FAQ.

    If you also have problems with Xbox 360 controllers then that's more puzzling (except if it's on Linux which we don't have a device profile for). It might be a problem inherent in the old input system that the prototype is built on top of.

    Status of the new input system is that we're still working on it. There's a large amount of work to do, and we're only two guys in Input Team, so things take time. Note that the final released input system will not be fully compatible with the prototype, since we're refactoring and improving a lot of things, but it will be very similar overall.

    Rune
     
  7. darthbator

    darthbator

    Joined:
    Jan 21, 2012
    Posts:
    169
    I am using a standard 360 controller under windows 10 on the current release build of Unity 5.4 and I am experiencing this issue.
     
  8. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    470
    Thanks for the update Rune, its good to hear things are still happening.

    For the record, I'm also using 5.4, windows 10 and a wireless 360 controller (not sure if that would make a difference).

    Cheers.
     
  9. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    For those problems mentioned I would suggest using the workaround by Zethros a few posts above if it works for you. We're currently focused on developing the proper new input system that includes a new backend. The prototype have certain limitations and bugs caused by the fact that it's still based on the old backend. Things can only be fixed properly with the proper new system which is why we're focusing our efforts on that.
     
    Xepherys and Shizola like this.
  10. russeli

    russeli

    Joined:
    Feb 4, 2014
    Posts:
    1
    Posting this fix incase someone is interested in one that leaves the triggers working.

    When either trigger was pressed, the old input system was producing events where controlIndex is 2, but Xbox360WinProfile is lacking a mapping for that controlIndex. When input events are processed, JoystickProfile's Remap method goes through it's mappings array checking what each controlIndex is mapped to. If the targetIndex is -1(unmapped), the Remap method leaves the event untouched. The problem was that all unmapped controls had a default targetIndex of 0, which actually belongs to Left Analog's X Axis.

    We solved this by assigning a default value of -1 to all JoystickControlMappings' targetIndex field in the JoystickProfile's SetMappingsCount method.

    Code (CSharp):
    1. //JoystickProfile.cs
    2. public void SetMappingsCount(int sourceControlCount, int tarcontrolCount)
    3. {
    4.     mappings = new JoystickControlMapping[sourceControlCount];
    5.     for(int i = 0; i < sourceControlCount; ++i)
    6.     {
    7.         mappings[i].targetIndex = -1;
    8.     }
    9.     nameOverrides = new string[tarcontrolCount];
    10. }
     
    Last edited: May 10, 2017
    Shizola likes this.