SDL Joystick troubles

Hi all,

Ok, I have an SDL program that I’m trying to get working with joystick input.

I’m developing on Windows XP, using cygwin + mingw. The program uses opengl
and I’ve installed the directx libraries and headers. Running configure, SDL
says it finds the directx libraries. Any way to verify that directx is being
used for the joystick input?

The target platform is an older Windows 98 system. It has directx 8.1
installed.

The joystick is a custom built joystick (basically a modified Star Wars yoke
using this hack http://arcadecontrols.com/arcade_jude.shtml). I am using the
joystick port.

Selecting the game controller in Windows 98, I can calibrate the joystick and
it works fine in the Windows 98 calibration test window.

Running the testjoystick.c program that comes with SDL, the joystick is not
centered, but is in the lower left.

The strange thing is that if I move the joystick to the lower right, the
program begins to stutter. If I go all the way to the lower right, it
actually locks up the program. I experience the same thing in the SDL program
I wrote using an entirely differnt joystick routine (events vs the joystick
apies).

I’ve been looking online and I can find a joystick tutorial here and there,
but I can’t find anything covering the issues I’ve been having.

If someone could point me in the right direction, offer advice, maybe a test
program, point to a website, article…anything, I’d greatly appreciate it.–
Mark Jenison

Stoned koala bears drooled eucalyptus spit in awe as Mark Jenison said:

The strange thing is that if I move the joystick to the lower right, the
program begins to stutter. If I go all the way to the lower right, it
actually locks up the program. I experience the same thing in the SDL program
I wrote using an entirely differnt joystick routine (events vs the joystick
apies).

As I understand joysticks, they’re just a variable resistor through
which a capacitor behind the gameport is slowly charged. I think a
typical joystick driver will poll the game port to determine when the
voltage on that capacitor reaches a threshold, the time taken defines
the resistance. If your resistance is too high, it will take a long
time and the game can lock up in the polling loop.

Maybe. Or maybe I’m misremembering, but if I were you I’d check the
resistance on your pots and connections.–
William Brodie-Tyrrell

Carpe Diem - fish of the day.

<@William_Brodie-Tyrre>
http://www.brodie-tyrrell.org/

Mark Jenison <jenison enteract.com> writes:

Hi all,

Ok, I have an SDL program that I’m trying to get working with joystick input.

I’m developing on Windows XP, using cygwin + mingw. The program uses opengl
and I’ve installed the directx libraries and headers. Running configure, SDL
says it finds the directx libraries. Any way to verify that directx is being
used for the joystick input?

The target platform is an older Windows 98 system. It has directx 8.1
installed.

The joystick is a custom built joystick (basically a modified Star Wars yoke
using this hack http://arcadecontrols.com/arcade_jude.shtml). I am using the
joystick port.

Selecting the game controller in Windows 98, I can calibrate the joystick and
it works fine in the Windows 98 calibration test window.

Running the testjoystick.c program that comes with SDL, the joystick is not
centered, but is in the lower left.

The strange thing is that if I move the joystick to the lower right, the
program begins to stutter. If I go all the way to the lower right, it
actually locks up the program. I experience the same thing in the SDL program
I wrote using an entirely differnt joystick routine (events vs the joystick
apies).

I’ve been looking online and I can find a joystick tutorial here and there,
but I can’t find anything covering the issues I’ve been having.

If someone could point me in the right direction, offer advice, maybe a test
program, point to a website, article…anything, I’d greatly appreciate it.

Follow up to this problem:

Turns out that infinite events were being created when the joystick was moved to
the extreme lower right, thus the code would never leave the event loop,
essentially locking up the program (both the testjoystick program and my code).

Reducing the ohm range helped somewhat, but never removed the problem if the
controller was moved to the extreme.

The solution was to disable joystick events and put explicit calls to get the
axis outside of the event loop.

One thing the SDL developers might consider is making the disabling of events
more granular. For example, disable the joystick axis events, but continue
allowsing joystick button events.

Also, I verified that SDL was taking the Windows 98 joystick configuration data
into account, as depending on how I configured it in the Win 98 calibration
screen would effect how it displayed in the testjoystick program.

However, what would appear centered in the Win 98 joystick calibration test
would come out offcenter (always lower left) in the testjoystick program.

I was able to get the cursor near center in the testjoystick program if I
cheated a bit during the Win 98 joystick calibration, but as you can imagine,
this is a less than ideal solution.–
Mark Jenison