Search Unity

Bug PS4 controller detected twice on 2022.2

Discussion in 'Input System' started by Ferrhoe, May 16, 2023.

  1. Ferrhoe

    Ferrhoe

    Joined:
    Jan 7, 2014
    Posts:
    15
    Hey everyone.
    I'm posting here because I'm running out of ideas.

    I'm working on a local coop game (PC), up to 3 players, and I support different type of gamepads (xbox variants, ps4, ps5, switch).

    Everything was working fine for years.
    I could use whatever type of pad, detecting the type properly, etc.
    But for convenience in the last couple of months (because I'm also using my PS4 pads with my PS4), I was mostly testing with xbox pads only.

    Recently, I retried with a PS4 pad, and here is the issue: the PS4 pad is well detected in Unity, but is also detected as an xbox controller.

    Basically if I have a xbox pad connected and a PS4 pad connected, Gamepad.all is giving me 3 gamepads, instead of 2.



    • The thing is that I don't have ds4windows or ds4tools installed (which I know could cause this problem).
    • My PS4 pad is connected via USB (not bluetooth, and I don't have the adapter anyway).
    • Windows is not detecting any virtual pad (I have 2 pads only in the device list).
    • And an old version of my project running on 2020.2.3f1 doesn't have this issue.
      Gamepad.all is giving me the correct amount of pads.
    I know it was working on 2022.x.x at some point, but can't figure out which version, since I retried with my PS4 pad just recently.
    The only thing I know is that it was at least happening on 2022.2.5f1, and updating to latest (2022.2.19f1) doesn't fix any issue.


    If anyone have any idea, I would gladly appreciate the support.
    Thank you so much in advance, and have a wonderful day.
     
    Last edited: May 16, 2023
  2. unormal

    unormal

    Joined:
    Jan 10, 2012
    Posts:
    65
    Might be the steam controller overlay getting in the middle.
     
  3. Ferrhoe

    Ferrhoe

    Joined:
    Jan 7, 2014
    Posts:
    15
    Hey thanks for your answer.

    I've think of that, but steam is not started and I haven't installed the steam API in my project

    Do you think it can happen anyway?
     
  4. unormal

    unormal

    Joined:
    Jan 10, 2012
    Posts:
    65
    It definitely has global effects. Try excluding the controller type in the big picture settings. Im not 100% sure this is your problem but its worth checking.
     
  5. Ferrhoe

    Ferrhoe

    Joined:
    Jan 7, 2014
    Posts:
    15
    Did an update for the xbox game bar itself but still the same.
    No solution so far :/
     
    Last edited: Jun 26, 2023
  6. Ferrhoe

    Ferrhoe

    Joined:
    Jan 7, 2014
    Posts:
    15
  7. deshalb

    deshalb

    Joined:
    Feb 22, 2013
    Posts:
    12
    Yes, as mentioned above i Do have the same Problem, but with a switch pro Controller. I also have an older Projekt where everything was working fine.
    I would also appreciate a solution...
     
  8. Ferrhoe

    Ferrhoe

    Joined:
    Jan 7, 2014
    Posts:
    15
    I've tested by creating a project from scratch, just using Input System and displaying gamepad.all via debug.log.
    It's also happening, so it confirmed that it's coming from a change in the editor / package at least.

    I've reported a bug.
    We'll see.
     
  9. james_work

    james_work

    Joined:
    Oct 2, 2020
    Posts:
    10
    Are you able to provide a link to the bug tracker? We are having the same issue as well.
     
  10. Ferrhoe

    Ferrhoe

    Joined:
    Jan 7, 2014
    Posts:
    15
    It's asking not to share the link publicly in the reporting portal for now.
    But I can give you an update once I have one or if they create a Jira ticket, I'll share the link for sure!
     
  11. unormal

    unormal

    Joined:
    Jan 10, 2012
    Posts:
    65
    Seems to also be showing up ocassionally for Caves of Qud in our beta rollout of the input manager, fwiw.
     
  12. james_work

    james_work

    Joined:
    Oct 2, 2020
    Posts:
    10
    No problem, in that case I'll keep an eye on this thread so just an update here will suffice. Thanks.
     
  13. Ferrhoe

    Ferrhoe

    Joined:
    Jan 7, 2014
    Posts:
    15
    QA is looking at it.
    So far the tester can't repro, but I don't know which version he is using (waiting for that info).

    I've provided repro by video and tested on another computer, and I can repro 100% on my side.
    I'll keep you posted.
     
    james_work likes this.
  14. zledas

    zledas

    Joined:
    Nov 3, 2010
    Posts:
    23
    Thanks for keeping us updated. As already mentioned in this thread, some of us have this (or similar) problem with Switch Pro controller. As an ugly workaround I used this "method of detecting" this and disabling duplicate:

    Code (CSharp):
    1. // We execute this code on `playerInput.onControlsChanged`
    2. if (gamepad is UnityEngine.InputSystem.Switch.SwitchProControllerHID) {
    3.     foreach (var item in Gamepad.all) {
    4.        if ((item is UnityEngine.InputSystem.XInput.XInputController) && (Math.Abs(item.lastUpdateTime - gamepad.lastUpdateTime) < 0.1)) {
    5.             Debug.Log($"Switch Pro controller detected and a copy of XInput was active at almost the same time. Disabling XInput device. `{gamepad}`; `{item}`");
    6.             InputSystem.DisableDevice(item);
    7.         }
    8.     }
    9. }
    I shared this on the other thread some days ago, but realised it might be useful for other people here as well.
     
  15. Ferrhoe

    Ferrhoe

    Joined:
    Jan 7, 2014
    Posts:
    15
    Thanks for the info.
    I tried something similar myself, but sometimes, I got the "xinput version" of my PS4 pad being detected just before the real PS4 pad.

    Kind of random.
    So I couldn't rely on update time unfortunately.
     
  16. zledas

    zledas

    Joined:
    Nov 3, 2010
    Posts:
    23
    Hm, I think this is the case for our case as well – xinput is "detected" first, BUT, at least in our case, the inputs switch from one to another and back all the time, so at some point (usually very soon) this code "catches" them as the same.
     
  17. Ferrhoe

    Ferrhoe

    Joined:
    Jan 7, 2014
    Posts:
    15
    Got another answer from the QA


    Hi,

    Thanks for getting in touch, we actually know about this issue internally, but sadly since the issue is internal and not public, we cannot provide you with the issue tracker link.

    Please reach out to me if I can answer any questions or be of further help.



    They closed my ticket as duplicate.
    So I guess we wait.
     
    deshalb likes this.
  18. deshalb

    deshalb

    Joined:
    Feb 22, 2013
    Posts:
    12
    Thanks for the Update. Its a shame that we dont have any hint as to when a fix might be provided. I guess we have to keep the input-System in Our projects uptodate until suddenly the Bug is fixed :/
     
  19. Ferrhoe

    Ferrhoe

    Joined:
    Jan 7, 2014
    Posts:
    15
    Pretty much yeah :/
     
  20. F4t1h

    F4t1h

    Joined:
    Nov 12, 2017
    Posts:
    14
    Heaving the same issue since upgrading from 2021 LTS to 2022 LTS.

    Very frustrating. It took me 3 hours to find out that the issue is not on my side. There are 2 issues though:
    • A/B X/Y swap
    • having two instances of controllers from one physical device - each triggering input
    Just "watched" this thread to get latest infos. Please keep us updated if anyone knows more. I´ll wait until than with you guys and probably will use "zledas" solution.

     
  21. robinhood14501

    robinhood14501

    Joined:
    Jul 22, 2021
    Posts:
    17
    I've been having the same issue with a Switch Pro Controller. This is an ugly workaround that worked for me:

    1. Move the Input System Package from the ProjectName/Library/PackageCache to ProjectName/Packages
    (so that we can edit the code)

    2. Go to the SwitchProControllerHID class, and add this line to the end of the OnAdded(); function

    InputSystem.RemoveDevice(this); upload_2023-9-6_23-7-4.png


    This may be an ugly workaround, but its working for me right now, and I bet this would work for the PS4 controllers as well. Hopefully we can find a better solution.
     
  22. Ferrhoe

    Ferrhoe

    Joined:
    Jan 7, 2014
    Posts:
    15
    To give you an update:

    - I tried to rollback to previous InputSystem (until 1.0) but it didn't change anything.
    So I rule out InputSystem to be the culprit, and focused on the Editor itself.

    - Upgrading my editor solved the issue.
    Went from 2022.2.3f1 to 2023.2.3f1 and I don't see duplicated pads now.

    I know it's not ideal, but if it can help someone...
    Hoping your project are compatibles.

    <3
     
  23. Woomek

    Woomek

    Joined:
    Aug 22, 2019
    Posts:
    13
    neviovalsa likes this.