Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Using more than 4 XBox Gamepads

Discussion in 'Input System' started by MatveiKharlamov, Feb 1, 2023.

  1. MatveiKharlamov

    MatveiKharlamov

    Joined:
    Nov 6, 2022
    Posts:
    3
    As far as I understand, the 4 gamepad is natural limitation of XInput, API that Unity uses for handling XBox Input.

    I know this is doable since it's done in paid asset called ReWired. But is it possible to implement using InputSystem?

    As far as I understand, there are several ways to handle this: either force the engine to use DirectInput even for XBox controllers, or replace the XInput library Unity uses with something like OpenXInput, which does not have the 4 controller limitation. But how exactly do I proceed about it, I have found very little information online.

    If it's not possible, what ways do I have to work around this issue with what XInput gives me?
     
    Last edited: Feb 1, 2023
  2. MatveiKharlamov

    MatveiKharlamov

    Joined:
    Nov 6, 2022
    Posts:
    3
    After testing with InputSystem and InputManager, I have noticed that they both have a limit of 4 gamepads, however, they are getting different gamepads. InputManager gets 1, 2, 3 and 4, while InputSystem gets 1, 2, 4 and 5. This means I can get input from another system where one fails, but this does not look like a good solution to the issue, I'll be honest. Besides, I don't control this behaviour and in this scenario still neither of them cover Gamepad 6.
     
  3. rdjadu

    rdjadu

    Joined:
    May 9, 2022
    Posts:
    103
    This is coming from a restriction of the XInput API. It has a hardcoded limit of 4 controllers.

    The platform backend should be using the newer Windows gaming APIs instead, which don't have this limit, but AFAIK this hasn't happened yet.
     
  4. MatveiKharlamov

    MatveiKharlamov

    Joined:
    Nov 6, 2022
    Posts:
    3
    I understand that, and I mentioned the problem in the original post. However, I've found alternative XInput dlls that do not have this restriction (https://github.com/Nemirtingas/OpenXinput) but I am not sure how can I go about making InputSystem use those.

    Also, if Rewired can force XBox controllers to go through DirectInput, why is it impossible for Input System? I am fine with DirectInput restrictions, such as lack of rumble or limited axis and button amount.