Joystick numbering and joystick 5th axis

Hi,
I started working with SDL about two weeks ago, so I am still new to all
of this. I am not an experienced programmer either. I work with joysticks
and gamepads. For now, I am just learning how to get their status and how
to use several of them at the same time. I’m under Windows, C++ code and I
have the 1.2.7 SDL library version. I end up with three major problems.

  1. Most joysticks I tried have 4 axis, and everything is perfec with them.
    However, I tried the Logitech WingMan Cordless Gamepad, which has 5 axis.
    The SDL library identifies perfectly the gamepad: name, 5 axis, 11 buttons,
    1 hatswitch, etc. But, when I read the axis status, it works for the four
    first ones, but the fifth one always returns -32767, without connection with
    the real position of the axis. My code to retrieve the position is the
    following. This function considers that the initialisation has been made
    previously. Is there something I can do to get the 5th axis position
    correctly?

/*********************************************************************

  • FUNCTION: getAxisStateBrut

  • INPUT: AxisNumber = Number of the interrogated axis

  • OUTPUT: Integer indicating the axis position

  •   If AxisNumber is out of range, the function returns 0.
    
  • PROCESS: - Update joystick status

  •   - Read axis state
    
  • NOTE: Axis numbers start with 1 (not 0)
    *********************************************************************/
    int UnJoystick::getAxisStateBrut(int axisNumber)
    {
    int positionBrut;

    if((axisNumber <= numberOfAxis) & (axisNumber > 0) & initialisation)
    {
    SDL_PumpEvents();
    positionBrut = SDL_JoystickGetAxis(js, axisNumber-1);
    //js is a class variable of type SDL_Joystick

      return positionBrut;
    

    }
    else
    return 0;
    }

  1. As I said before, I want to work with several joysticks. Right now, I
    have five of them plugged into my computer. I made different combinasion to
    try to find out the logic of the SDL numbering, but I have not found it yet.
    Does anyone have any clue how to predict which number will be associated
    with which joystick? I’d rather not have to test the joysticks order each
    time I have a new combinasion.

  2. The third one is my worst problem. Sometimes, the code transcript above
    returns 0 or -1 even if the joystick is at an extreme position. When this
    happens, I receive a message in my debugger:
    "DINPUT: SetCooperativeLevel: You really shouldn’t pass hwnd = 0; device
    calibration may be dodgy"
    This is really annoying because I receive false data and an error with a
    librairy I don’t directly use myself (SDL uses it). I don’t have a clue
    what to do about it. If you do, please answer me and you’ll be my hero!

Note: I know I could use the “event process”, but I really need to use the
"polling process". Thank you!

Karine

Hi,
? I started working with SDL about two weeks ago, so I am still new to
all of this.? I am not an experienced programmer either.? I work with
joysticks and gamepads.? For now, I am just learning how to get their
status and how to use several of them at the same time.? I’m under
Windows, C++ code and I have the 1.2.7 SDL library version.? I end up
with three major problems.?

  1. Most joysticks I tried have 4 axis, and everything is perfec with
    them.? However, I tried the Logitech WingMan Cordless Gamepad, which
    has 5 axis.? The SDL library identifies perfectly the gamepad: name, 5
    axis, 11 buttons, 1 hatswitch, etc. But, when I read the axis status,
    it works for the four first ones, but the fifth one always returns
    -32767, without connection with the real position of the axis.? My
    code to retrieve the position is the following.? This function
    considers that the initialisation has been made previously.? Is there
    something I can do to get the 5th axis position correctly?

…snip…

Don’t write a program or post code that just prints out joystick
information. Such a program comes with the SDL source code. Use that.

I didn’t look at your code, and you are admittedly a novice, I’d still
however be very surprised, given the other circumstances you’ve stated,
if the program that comes with SDL is any different.

Not specifically with SDL, but I’ve heard many many problems with
WingMan game pads. First of all make sure you have the most up-to-date
drivers for this joystick. Then if you still have the problem, try the
test program that comes with SDL.

The invocation of the SDL joystick test program (named appropriately
enough, testjoystick) is as follows:

plug in your gamepad
run testjoystick from the command prompt
it will enumerate all available joysticks for you
next invoke testjoystick with one parameter: the numerical index of
your gamepad
press a bunch of shit on your gamepad!

Now someone may very well come along with more knowledge than me and
say something short and sweet like “this gamepad doesn’t work with
SDL,” in which case I guess I’ve just wasted my time. But I wish you
luck getting your gamepad to work.

Also you might want to check google. I often bitch people out for not
doing this before emailing the list…On Sep 21, 2004, at 11:07 AM, Dionne, Karine wrote:

Thanks for the advice. It is very nice that you took some time to answer my
very basic questions. You were right about the SDL “testjoystick.exe”, it
does not recognise the 5th axis more than my own code. I also verified that
I had the most up-to-date drivers for the gamepad, but it did not change a
thing. At least, it was a good try.

I have to mentioned that I “googled” a lot about the problems I
encountered, and almost every related answer brought me back to this mailing
list. Unfortunately, in the past, there were only questions with no answers
about the matter. So, I’ll keep looking and trying!