Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » DirectInput joystick bug

This thread is locked; no one can reply to it. rss feed Print
DirectInput joystick bug
gnolam
Member #2,030
March 2002
avatar

While toying around with Allegro's joystick routines with JOY_TYPE_AUTODETECT under Windows, I discovered that I couldn't actually utilize all the axes/sliders on my joystick (a Saitek X-36) - to be specific, Allegro didn't report Rotary #2.

After digging around in the sources, I thought I had found the cause of it:

/* From joystick.h */

#define MAX_JOYSTICKS            8
#define MAX_JOYSTICK_AXIS        3
#define MAX_JOYSTICK_STICKS      5
#define MAX_JOYSTICK_BUTTONS     32

Since my joystick was being reported as having 5 sticks, I thought I was running into the hardcoded limit and changed MAX_JOYSTICK_STICKS to a higher value, but to no avail. So I did some more testing, and discovered that the problem is with JOY_TYPE_DIRECTX (the default) and not with JOY_TYPE_WIN32.

With JOY_TYPE_DIRECTX the joystick gets this layout:

Stick 0:
   Axis 0: X Axis
   Axis 1: Y Axis
Stick 1:
   Axis 0: Rudder
Stick 2:
   Axis 0: Throttle
Stick 3:
   Axis 0: Rotary #1
Stick 4:
   Axis 0: Main POV hat X
   Axis 1: Main POV hat Y

+ 26 buttons

Rotary #2 (identical to Rotary #1) is nowhere to be seen.

And with JOY_TYPE_WIN32:

Stick 0:
   Axis 0: X Axis
   Axis 1: Y Axis
   Axis 2: Throttle
Stick 1:
   Axis 0: Rudder
Stick 2:
   Axis 0: Rotary #1
Stick 3:
   Axis 0: Rotary #2
Stick 4:
   Axis 0: Main POV hat X
   Axis 1: Main POV hat Y

+ 26 buttons

Since I figure most people probably haven't tested Allegro's joystick input with more complex joysticks, I feel I may have run into an obscure Allegro bug here...
Any devs or people who can stand looking at DirectX code who can look into this? :)

In any case: is there a reason for MAX_JOYSTICK_STICKS to be set at 5?

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Chris Katko
Member #1,881
January 2002
avatar

I'd recommend posting to the developers list or asking someone here to do so.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Evert
Member #794
November 2000
avatar

Don't worry, I've seen it, and I'm sure Peter and Elias will see it too if they haven't already.
Personally, I'm not in a position where I can do much about this though - I don't use Windows very often and my gamepad doesn't work in Windows anyway (at least, I haven't tried to get it to work yet, too little incentive to do so).

Quote:

is there a reason for MAX_JOYSTICK_STICKS to be set at 5?

I think not. This, I think, is completely arbitrary.

Peter Wang
Member #23
April 2000

Sorry for the delay. I think the problem is in object_enum_callback() in src/win/wjoydx.c. I suspect the missing axis falls under GUID_RxAxis or GUID_RyAxis which is not being tested for there.

Go to: