Controller not working on Debian but working on Fedora

HI, I have a strange problem as said in the title.
First jstest-gtk show my controller and i can calibrate it.
The problem was first the detection. I have to print all the event and replace the Global value from an imediate value

case SDL_CONTROLLERDEVICEADDED:
case 1541:
    fprintf(stdout,"Controller #%d plugged\n",event.cdevice.which);
    addController(event.cdevice.which);

now It print “Controller #0 plugged” when i plug my controller. This is Odd as in Fedora I didn’t have the “case 1541”

now the main problem is the controller is not supported by interface when it is in fedora with the same code.
Here is the code to test controllers:

SDL_Event event;
while(SDL_PollEvent(&event))
{
    //fprintf(stderr,"%d\n",event.type);
    switch(event.type)
    {
        default:
        break;
        case SDL_CONTROLLERDEVICEADDED:
        case 1541:
            fprintf(stdout,"Controller #%d plugged\n",event.cdevice.which);
            addController(event.cdevice.which);
            break;
        case SDL_CONTROLLERDEVICEREMOVED:
        case 1542:
            fprintf(stdout,"Controller #%d unplugged\n",event.cdevice.which);
            removeController(event.cdevice.which);
            break;
    }
}   

Now the function addController()

static void addController(int id)
{
    if(joystick == NULL)
    {
        fprintf(stderr,"%d = %d\n",id,SDL_IsGameController( id ));
        if( SDL_IsGameController( id ) ) 
        {
            SDL_GameController *pad = SDL_GameControllerOpen( id );

            if( pad ) 
            {
                joystick = SDL_GameControllerGetJoystick( pad );
                //int instanceID = SDL_JoystickInstanceID( joystick );
            }
            else
            {
                fprintf(stderr,"gamecontroller not set pad = %p\n",pad);
            }
        }
        else
        {
            fprintf(stderr,"Controller #%d not recognized\n",id);
        }
    }
    else
    {
        fprintf(stdout,"Only one joystick for this game\n");
    }

return;
}

So when I run my program and plug my controller here is the output:

Controller #0 plugged
0 = 0
Controller #0 not recognized
Controller #1 plugged
1 = 0
Controller #1 not recognized

As you can see two controllers are detected, I unplugged every USB devices to be sure my BT keyboard and mouse or usbstick or whatever are not seen as controller and only plugged my controller,
and finally the detection is OK but not supported device.

It doesn’t make any sense for me to work on one system and not on an another one with the same code. I probably installed something wrong or forgot to install something.

Thanks for reading me

I checked and 1541 is SDL_JOYDEVICEADDED, and 1542 is SDL_JOYDEVICEREMOVED - I would switch the integers to the symbolic constant. Also, for SDL_JOYDEVICEADDED/ SDL_JOYDEVICEREMOVED, you should be accessing event.jdevice not event.cdevice.

However, I don’t think that is the actual problem. Maybe your Debian system has an older version of SDL2 that doesn’t support your controller? What model is the controller?

You could try calling https://wiki.libsdl.org/SDL_GameControllerAddMappingsFromFile
with this community maintained mapping database: https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

OK, I separeted the case SDL_JOYDEVICEADDED and SDL_CONTROLLERDEVICEADDED.

So, I just bougth lzdtech online : ZD-V008
and tail -f /var/log/syslog show me this when i plug it:

May 30 09:49:44 debian kernel: [153009.578218] input: Microsoft X-Box 360 pad as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1.2/2-1.1.2:1.0/input/input23
May 30 09:49:44 debian kernel: [153009.578550] usbcore: registered new interface driver xpad
May 30 09:49:44 debian gdm-Xorg-:0[912]: (II) config/udev: Adding input device Microsoft X-Box 360 pad (/dev/input/event22)
May 30 09:49:44 debian gdm-Xorg-:0[912]: (II) No input driver specified, ignoring this device.
May 30 09:49:44 debian gdm-Xorg-:0[912]: (II) This device may have been added with another device file.
May 30 09:49:44 debian gdm-Xorg-:0[912]: (II) config/udev: Adding input device Microsoft X-Box 360 pad (/dev/input/js0)
May 30 09:49:44 debian gdm-Xorg-:0[912]: (II) No input driver specified, ignoring this device.
May 30 09:49:44 debian gdm-Xorg-:0[912]: (II) This device may have been added with another device file

As you can see looks like it is recognize as a X-box 360 pad.
I add the mapping but still not recognize.

What Linux kernel version is this? My understanding is SDL needed a fix for kernel 4.11.

–ryan.

uname -a :

Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30)