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
Different results with sdl_numjoysticks
Tinkh


Joined: 15 Mar 2017
Posts: 1
The function sdl_numjoysticks does not return me always the same value (at init time). I explain.

I have two computers : one with DEBIAN6.0 (where I want to use my joysticks) and one with windows (where I work usually). I am connecting to the DEBIAN computer with MobaXterm (XDMCP session).
I made a little test program to print the number of joysticks.

Code:
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL/SDL_joystick.h>

int NbJS,NJS;
void main() {
    if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
    {
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
        exit(0);
    }

    NbJS=SDL_NumJoysticks();
    fprintf(stderr, "%i joysticks were found.\n\n", NbJS );

    for(NJS=0;NJS<NbJS;NJS++)
    {
        SDL_JoystickOpen(NJS);
        fprintf(stderr, "Joystick %d :%s\n",NJS,SDL_JoystickName(NJS));
    }

    SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}

When I was connecting to the DEBIAN computer, it is OK and the function SDL_NumJoysticks() find two Joysticks :

2 joysticks were found.

Joystick 0 :Mad Catz Pro Flight Cessna Rudder Pedals

Joystick 1 :Madcatz Saitek Pro Flight X-55 Rhino Stick
When I was connecting directly in the DEBIAN computer, I do not have the same result :

1 joysticks were found.

Joystick 0 :Madcatz Saitek Pro Flight X-55 Rhino Stick
If I remove this stick, the DEBIAN computer finds correctly Mad Catz Pro Flight Cessna Rudder Pedals.

I used SDL 1.2.14. I can not explain that. If anybody has an explaination ... If I upgrade SDL, does it resolve the problem ? I am not sure to be allowed to do this update.