Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question No gamepad on Linux

Discussion in 'Input System' started by GlaskowsRetroBrain, Nov 20, 2022.

  1. GlaskowsRetroBrain

    GlaskowsRetroBrain

    Joined:
    Jan 9, 2020
    Posts:
    8
    Hi, I am trying to use a 8bitdo Zero 2 gamepad on Linux Ubuntu 20.04LTS

    I have both tried to use the old input system and the new package v1.3. And while both worked really well on Windows, I cannot make it work on Linux.

    I can see the controller being recognized on the OS level (as a file in the /dev/ folder) and at the user level when I execute jstest-gtk.

    This devices can be used in several "modes", as a xbox, ps, switch, android or generic gamepad or even as a keyboard. Only the keyboard works, which is natural, given it behaves just as a regular bluetooth keyboard.

    I read somewhere that Unity on Linux uses SDL, and I tried configuring the environment variable SDL_GAMECONTROLLERCONFIG with the right values (which can be find at https://github.com/gabomdq/SDL_GameControllerDB/blob/master/gamecontrollerdb.txt), but this didn't helped neither.

    I also tried installing the userspace driver xboxdrv and again nothing.

    It is a very frustrating issue, as I don't develop in Linux, but on Windows and I would like to resolve this without the need to have a Linux dev environment.

    Any help is appreciated. Bests.
     
  2. GlaskowsRetroBrain

    GlaskowsRetroBrain

    Joined:
    Jan 9, 2020
    Posts:
    8
    I can make the controller to work in Linux inside the Unity editor, but when I try it on a Linux box without a desktop environment, the controller is not recognized. I still can execute jstest-gtk in that system and test the controller correctly, but Unity seems not to recognize it.
     
  3. tylerinthezoo

    tylerinthezoo

    Unity Technologies

    Joined:
    Jun 15, 2022
    Posts:
    97
    Hi, could you help to file a bug report and possibly provide a simply setup that you failed to have the controller to work on so that we can better understand the problem. thanks a lot
     
  4. GlaskowsRetroBrain

    GlaskowsRetroBrain

    Joined:
    Jan 9, 2020
    Posts:
    8
    Yes,so far I have been trying to reduce the scope of the bug.

    It happens the app will just work if you run it within Gnome (after setting the correct SDL_GAMECONTROLLERCONFIG environment variable)

    But as I need to run it directly without a window manager, I tried a simpler window manager, x-window-manager to better pinpoint the problem.

    Now it gets more interesting. First, if I just call the x-window-manager and the app, the app won't stop resizing and behave strangely, which doesn't happen if I call another app instead, like xterm.

    This can be fixed if I pass the -fullscreen option to x-window-manager, but the controller still won't work.

    It I call xterm first without the -fullscreen option and I call my app from xterm, the controller works

    If I call xterm fist with the -fullscreen option and I call my app from xterm, the controller won't work

    But if I run sdl-jstest within xterm, the controller works with or without the -fullscreen option. This means that the latest sdl2 can handle the controller, so it is either that Unity uses an old sdl2 version or a bug somewhere else.

    I will try to put all of this details in a bug ticket, but I think is better to share it in the forum as well.

    Btw, when I say I run x-window-manager and then my app, I am doing it by calling startx and letting the .xsession file do the callings.

    or

    I created a minimal project that replicates the behavior. Also, I tried it with Unity 2020.3.33f1 and 2021.3.16f1
     
    Last edited: Jan 13, 2023
    tylerinthezoo likes this.
  5. GlaskowsRetroBrain

    GlaskowsRetroBrain

    Joined:
    Jan 9, 2020
    Posts:
    8
    Also, I would point to my other thread

    In there I discover I need to configure the Input System background behavior to "Ignore Focus", because apparently, without a window manager, the app never gets a focus event.

    In my minimal test project, I can see the gamepad recognized but still not getting events. My bet is that while "Ignore Focus" handles mouse and keyboard events, it is not handling correctly the game controllers subsystem.
     
  6. A_Marraff

    A_Marraff

    Joined:
    Dec 12, 2015
    Posts:
    6
    Having a similar issue trying to use my 8BitDo "Ultimate C" controller with Unity via the wireless dongle. The controller was recognized in the input debugger briefly, but it said "disconnected." I tried rebooting Unity and disconnected/reconnecting the controller, but I can't get it to show back up. Tested on two different Linux distributions on two different devices, same problem. The gamepad is recognized by Linux just fine.

    Edit: After swapping USB ports, the controller shows up as connected in Unity, but the inputs still aren't working. This is using the gamepad's directinput mode. xInput doesn't work at all.
     
    Last edited: May 6, 2024