Search Unity

Xbox Controller issue on HoloLens

Discussion in 'VR' started by lpavanat, Dec 6, 2018.

  1. lpavanat

    lpavanat

    Joined:
    Dec 6, 2018
    Posts:
    3
    Hey guys,

    I am having a really awkward problem with the xbox wireless controller on the HoloLens for a while now, and I have not heard of other people with the same problem. Running on 2018.2.18f1, without extra plugins, just the native Unity solution.

    The axes from the trigger input do not always return the correct value. Many times, the input will return as fully pressed (value 1), and get stuck on this number for a while (can be 1s, can be >10m). This happens for both triggers, including the shared axis, although usually the right trigger seems to be the most frequent one. Sometimes the problem fixes by removing batteries on the controller and connecting again, but others the problem will still persist until I restart the application.

    I have also noticed that the shared axis does not always shows the correct equivalent value of the sum of both triggers (also gets stuck). I have been trying to find a pattern for this problem for quite a while now, and I haven't been able to find a behavior that necessarily causes the problem, although I it seems to be more frequently when I move the controller around (perhaps a bluetooth issue? or could be a random issue and just luck).

    I was never able to reproduce the problem inside the Unity Editor on Windows, using the same controller and bluetooth connection. I have tried 2 different controllers and 2 different HoloLens running different versions of OS. I have tried using .NET and IL2CPP backends.

    I have reported this to Unity (#1104486) but have not heard back yet. Has anyone experienced anything similar and found a solution?
     
  2. timke

    timke

    Joined:
    Nov 30, 2017
    Posts:
    408
    Hi,

    This is an area I own. I implemented a complete rewrite of UWP's Gamepad handling in the 2018.2 timeframe to fix Left/Right triggers not reporting on independent axes (Microsoft's fault). However, this is the first I've heard about this issue.

    UWP has a completely different implementation for HID and Gamepad devices compared with the Editor and WindowsStandalone (again thanks to Microsoft), and so it's not uncommon for UWP issues like this to go unnoticed; thank you for reporting it.

    I checked the status of the bug, and it's still waiting for QA to repro before sending it to the proper engineering team. Right now 2018.3 bug have higher priority, which may be why it's taking time. However, since it'll eventually come to me I'll go ahead and investigate it.

    A few follow-up questions:
    - What exactly were the HoloLens OS versions you tried?
    - Does this bug repro in 2018.3?
    - Does it repro when running the UWP app on Desktop?
     
  3. lpavanat

    lpavanat

    Joined:
    Dec 6, 2018
    Posts:
    3
    Hi,

    Thanks for helping me!

    - What exactly were the HoloLens OS versions you tried?
    I am currently running 10.0.17134.345, but I have been having this problem since I started using Unity 2018.2 in June, with the April 2018 update on HoloLens.

    Before that, I was using the previous OS version (I don't really know the exact version) with that "Xbox Controller Input for HoloLens" asset from the store, and the problem did not occur (although the asset broke after the April 2018 update).

    - Does this bug repro in 2018.3?
    Yes, it does. But, as I said, it is quite random. Sometimes I will never get the problem, and others the problem will happen all the time. I noticed this problem because the app I am working on requires users to walk and move the joystick around a lot, and that is when the problem started showing up. If I just use the app while sat in my chair it will not happen (this bugged me for a long time, because I simply could not reproduce the problem).

    - Does it repro when running the UWP app on Desktop?
    No, I could not reproduce it.

    When the problem happens, usually the right trigger and shared trigger get stuck at 1. However, if I press the left trigger all the way, the shared trigger changes to -1 (directly from 1). Another thing I did not mention is that sometimes I press one of the triggers all the way, and unity registers much less (like 0.7 or so, instead of 1). This does not bother me, but might be related.
     
  4. timke

    timke

    Joined:
    Nov 30, 2017
    Posts:
    408
    Thanks for the additional information.

    From your description I'm certain this is a Bluetooth connectivity issue, and I (vaguely) remember there being issues along this line with some older Xbox controllers. So, I recommend you update the firmware on your controllers and see if that fixes the problem:

    https://support.xbox.com/en-US/xbox-one/accessories/update-controller-for-stereo-headset-adapter

    That doesn't mean there isn't a Unity bug here, as I was able to repro the problem by forcibly disconnecting the controller (yanking the battery out) while the trigger was depressed; the trigger value sometimes becomes stuck on the last reading. I'll work on a fix for this issue.

    If updating the controller firmware doesn't resolve the problem, please let me know and I'll look into it some more. Otherwise, this is a low priority fix.
     
  5. lpavanat

    lpavanat

    Joined:
    Dec 6, 2018
    Posts:
    3
    Just checked. The controller was already up-to-date.
    I forgot to mention, I am using the Xbox Wireless Controller running firmware 3.1.1221.0.

    Is there a way to force a reconnection / clear the input once the problem happens?
    A manual solution like that could work on my case. I tried the Input.ResetInputAxes(), but that just seems to clear the input for a frame, and it then goes back to the stuck value.

    Thanks.
     
  6. timke

    timke

    Joined:
    Nov 30, 2017
    Posts:
    408
    I did some more investigating today, and I think I've identified the bug: in UWP when the controller is disconnected the "port" number (index into JoystickPos array) is removed from the mapping but the values within the array are not cleared out, causing any non-zero values to "stick". Also, I found this bug will repro in the Editor if you manually disconnect the controller while an Axis is engaged. So the bug has been around for quite some time, it's just typically not an issue.

    For me, calling Input.ResetInputAxis() every frame also didn't work in the Editor (haven't figured out why yet), but it did seem to somewhat work when running the UWP app on Desktop. The problem is it takes a second or two after pulling out the battery before Windows sends the "disconnected" event, leaving the value stuck during this time. Though once the event does fire the value is cleared by ResetInputAxis().

    I will work on fixing this bug, but there something still wonky with your controller or HoloLens device. So, I suggest contacting Microsoft support or reporting this problem on the HoloLens forums on MSDN.

    Finally, if you're feeling adventurous there's another possible work-around: check out using the "New Input System": https://forum.unity.com/threads/input-system-update.508660/. It's still in "beta" but it may be good enough for your purposes and should handle this scenario much better than old Input.