How to detect analog vs. digital joysticks in SDL?

Can someone point me to some code or a tutorial on how to do this? I
need to treat analog and digital input differently, but that’s very
hard when I don’t know what the incoming data actually is.

I’ve thought about several approaches, but none seem to work. It’s not
enough to just look at the axis values themselves, since they’re valid
in both modes. For example, if I see a value of -32767, that could
mean digital input/negative axis, or minimum analog input. Similarly,
a 0 could mean middle value for analog, and off for digital.

Ideally, I’d like to associate a boolean with a joystick axis that says
it’s either digital or analog. Anybody have any advice on this??

Thanks,
Steve

Do you have to know immediately? If it’s sufficient to be sure after the
joystick has been used for a few moments, you could assume an axis to be
digital until you get an “in between” value. As long as you don’t encounter a
player who always moves his analog axes to their extreme values with lighting
speed, I expect that should work.

Marian.On Thursday 08 December 2005 12:58, Stephen Anthony wrote:

Ideally, I’d like to associate a boolean with a joystick axis that says
it’s either digital or analog. Anybody have any advice on this??


http://marianschedenig.no-ip.org/

Hofstadter’s law: “It always takes longer than you think, even when you take
account of Hofstadter’s law”.

Le Thu, 8 Dec 2005 08:28:39 -0330
Stephen Anthony a ?crit:

Can someone point me to some code or a tutorial on how to do this? I
need to treat analog and digital input differently, but that’s very
hard when I don’t know what the incoming data actually is.

Digital joysticks are viewed as HATs from SDL’s point of view, just read
the doc associated to it.

Some drivers report some digital joysticks as analog, and report maximum
value for analog, if correctly calibrated.

However, you can treat any analog joystick as digital, if the value is
big enough (like max/2) for example for a direction::

analog / digital
0 to 16383 -> 0
16384 to 32767 -> 1–
Patrice Mandin
WWW: http://pmandin.atari.org/
Programmeur Linux, Atari
Sp?cialit?: D?veloppement, jeux