Xbox 360 analog triggers

I am currently trying to add support for Xbox 360 controllers in my game. The problem is that the triggers are analog and show up as a single axis.

If I pull down the right trigger, it sets the axis to -32,000. If I pull down the left trigger, it sets the axis to 32,000. If I have both triggers pulled or both triggers released, the axis value gets reported as 0. Is there way to poll each trigger individually?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

SDL just shows you how your operating system handles the device. That’s
up to the driver. Mind you I believe I recall this issue with the xbox
controller on linux. I believe on windows this only happens with
directinput (what SDL uses) and not xinput, but not entirely sure.

Anyway, to sum it up it’s not SDL at fault, it’s the joystick driver
exposing the hardware wrong.

EdgarOn 2010?06?18? 22:38, Lazy Foo’ wrote:

I am currently trying to add support for Xbox 360 controllers in my game. The problem is that the triggers are analog and show up as a single axis.

If I pull down the right trigger, it sets the axis to -32,000. If I pull down the left trigger, it sets the axis to 32,000. If I have both triggers pulled or both triggers released, the axis value gets reported as 0. Is there way to poll each trigger individually?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkwb3zYACgkQolm4VNX3QTyAgACdHqu8hE+fAgyrxlQzUI5ZaoD8
UD8AoIvTLb+RTV7d+lZJjgYytxGelShh
=Sgfd
-----END PGP SIGNATURE-----

Edgar Simo wrote:

Anyway, to sum it up it’s not SDL at fault, it’s the joystick driver
exposing the hardware wrong.

…but the Joystick is made by Microsoft and the device is made by Microsoft :?

Is there anyway to, I don’t know, select XInput in SDL 1.2.14 through SDL_envvars? Is there any plans to enable this functionality in SDL 1.3?

You could always use the XInput API directly (on Windows, and maybe Wine?) in your event loop. It’d be easy enough.------------------------
EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/

Could try using USB HID directly too…
(you’ll probably want to look at the Windows DDK documentation for
that. Might be easier on Linux)On 18/06/2010, Nathaniel J Fries wrote:

You could always use the XInput API directly (on Windows, and maybe Wine?)
in your event loop. It’d be easy enough.

Kenneth Bull wrote:> On 18/06/2010, Nathaniel J Fries <@Nathaniel_J_Fries> wrote:

You could always use the XInput API directly (on Windows, and maybe Wine?)
in your event loop. It’d be easy enough.

Could try using USB HID directly too…
(you’ll probably want to look at the Windows DDK documentation for
that. Might be easier on Linux)


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I expect that’d be more difficult.
Would certainly be more useful on Linux though.


EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

…but the Joystick is made by Microsoft and the device is made by Microsoft :?

That doesn’t mean they can’t screw up.

Is there anyway to, I don’t know, select XInput in SDL 1.2.14 through SDL_envvars? Is there any plans to enable this functionality in SDL 1.3?

No. You should ask their support to fix it although they’ll probably
just say “use xinput”. IIRC Xinput also only allows “certified microsoft
joysticks”, so if SDL used Xinput you might not get most joysticks, only
xbox 360 or xboxb ones.

If you still really want to “fix it” and instead of writing a driver you
want to add Xinput support to SDL, go ahead. However I do not think it’s
the best idea. Xinput basically seems like a way to try to force the
market to change by locking developers to xinput.

You might want to take a look at:

Which concludes with:

“As of 2010[update] XInput is for Xbox 360 controllers, while
DirectInput is for any controller.”

Edgar
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkwcf1AACgkQolm4VNX3QTxXNgCfYxfrkST1u/YI5Pg39X+QLLwb
x5oAn2VOhJM+zzAXj3Z3sCmxIKA55OBB
=iiiW
-----END PGP SIGNATURE-----On 2010?06?19? 01:19, Lazy Foo’ wrote:

Wow, that was way more than needed. And modifying SDL source is definitely not required either.
I could probably whip something up on my next day off. But that won’t be for a week…------------------------
EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/