The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL can't handle multiple joystick modesl
Neil


Joined: 05 Nov 2014
Posts: 3
Location: UK
Hi,

I am trying to use multiple control pad models with SDL 1.2 under Linux with the joydev kernel module.

Although the control pads are detected by Linux and have entries under /dev/input/js*, SDL only sees one control pad from the same manufacturer at a time. For example, if I connect two control pads from manufacturer A, both are detected by SDL. If plug in a control pad from manufacturer A SDL will correctly detect the control pad. If I then connect one from B and re-run my test application, SDL only detects manufacturer B.

I should add that all the control pads work fine with the Linux jstest utility and also with other applications, e.g. RetroArch.

Here is my test code:

Code:

#include <SDL.h>
#include <stdio.h>

int main(){
        if (SDL_Init(SDL_INIT_JOYSTICK) < 0) {
                fprintf(stderr, "SDL_Init error: %s\n", SDL_GetError());
                return 1;
        }

        printf("%i joysticks were found.\n\n", SDL_NumJoysticks() );
        printf("The names of the joysticks are:\n");

        int i = 0;

        for( i=0; i < SDL_NumJoysticks(); i++ )
        {
                printf("    %s\n", SDL_JoystickName(i));
        }

        return 0;
}


Is this a bug or am I doing something wrong?

As PyGame uses SDL 1.2, this also affects any PyGame programs as well.

Thanks in advance for any help,

Neil.
Neil


Joined: 05 Nov 2014
Posts: 3
Location: UK
I should also add that I see the same behaviour under SDL 2 and also under Fedora 20 (x86_64) and Arch Linux (arm).
Neil


Joined: 05 Nov 2014
Posts: 3
Location: UK
Hi all,

I think I have found the cause: SDL prefers devices under /dev/input/event rather than /dev/input/js*.

Thanks to this bug report: https://bugs.launchpad.net/ubuntu/+source/libsdl1.2/+bug/410187

In case this should be affecting anyone else, I have found that unloading the "evdev" kernel module was a quick fix for me.

Cheers,

Neil.