[AD] Unknown joystick axis problem under Windows

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hello,

I'm unsure if this mail is legitimally to be posted on the
[AD] list, please tell me if isn't the case.
My report may not lead to an actual bug, but I think Allegro
may want to provide a workaround against what I'm pointing to
below.

--

Context:
In my application I have an inputs configuration feature,
where the user can do any keyboard/mouse/joystick move to
select the input source for an action.

To implement it, I'm scanning all possible inputs sources.
In the case of joysticks, I'm scanning each of them and
checking if one stick axis is not in centered position.

--

Problem:
The problem is that Allegro reports two sticks axis that
are never in center position. I don't even know what those
sticks are, and they do not correspond to anything I can
manipulate with my joysticks.

I added the following snippet of code at the very end of
examples\exjoy.c:

   {
       JOYSTICK_INFO *joystick = &joy[0];
       int i, j;
       for (i = 0; i < joystick->num_sticks; i++)
       {
           JOYSTICK_STICK_INFO *stick = &joystick->stick[i];
           printf("Stick %d (flags = %04x)\n", i, stick->flags);
           for (j = 0; j < stick->num_axis; j++)
           {
               JOYSTICK_AXIS_INFO *axis = &stick->axis[j];
printf(" - Axis %d (pos = %d, d1 = %d, d2 = %d)\n", j, axis->pos, axis->d1, axis->d2);
           }
       }
   }

It enumerates all sticks and their axis, along with axis data.
I tested it with two USB joysticks and the output are below.
(Configuration: Allegro 4.1.9, DirectX 9.1, Windows XP.)

Thrustmaster Firestorm Dual Analog 2:

Stick 0 (flags = 0023)
 - Axis 0 (pos = 0, d1 = 0, d2 = 0)
 - Axis 1 (pos = 0, d1 = 0, d2 = 0)
Stick 1 (flags = 0043)
 - Axis 0 (pos = 128, d1 = 0, d2 = 0)
Stick 2 (flags = 0043)                  // this one is set
 - Axis 0 (pos = 0, d1 = -1, d2 = 0)
Stick 3 (flags = 0043)                  // and this one also
 - Axis 0 (pos = 0, d1 = -1, d2 = 0)
Stick 4 (flags = 0021)
 - Axis 0 (pos = 0, d1 = 0, d2 = 0)
 - Axis 1 (pos = 0, d1 = 0, d2 = 0)

Standard (old) Playstation gamepad connected thru a unnamed
Playstation->USB adapter:

Stick 0 (flags = 0023)
 - Axis 0 (pos = 0, d1 = 0, d2 = 0)
 - Axis 1 (pos = 0, d1 = 0, d2 = 0)
 - Axis 2 (pos = 0, d1 = 0, d2 = 0)
Stick 1 (flags = 0043)
 - Axis 0 (pos = 128, d1 = 0, d2 = 0)
Stick 2 (flags = 0043)                  // this one is set
 - Axis 0 (pos = 0, d1 = -1, d2 = 0)
Stick 3 (flags = 0043)                  // and this one also
 - Axis 0 (pos = 0, d1 = -1, d2 = 0)
Stick 4 (flags = 0021)
 - Axis 0 (pos = 0, d1 = 0, d2 = 0)
 - Axis 1 (pos = 0, d1 = 0, d2 = 0)

As a reminder, here is a flags values chart:
        0x21 = signed, digital
        0x23 = signed, digital & analogue
        0x43 = unsigned, digital & analogue
No calibration flags is set. Calibration has been done by
the code already present in exjoy.c.

I'm aware that it *might* be a problem originating from DirectInput
or the joystick driver. But I think it is a problem for the user.

Although most "simple" code probably only use joy[0].stick[0], it
is legit for an application to let the user select the sticks/axis
to use by polling it and looking at what is being pressed.

A workaround -on the programmer side- would be consider an axis as
"valid" when its value has changed at least once. Of course, this is
tricky.

Does someone familiar enough with Allegro DirectInput layer has an
idea about this problem? Can anybody reproduce my modified exjoy.c
inputs? Is the problem already known?

Thanks,
Omar Cornut





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/