The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Xbox 360 analog triggers
Lazy Foo'


Joined: 21 Sep 2009
Posts: 17
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?
Xbox 360 analog triggers
Edgar Simo
Guest

-----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.


Edgar

On 2010年06月18日 22:38, Lazy Foo' wrote:
Quote:
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

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-----
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: Xbox 360 analog triggers
Lazy Foo'


Joined: 21 Sep 2009
Posts: 17
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 Confused

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?
Nathaniel J Fries


Joined: 30 Mar 2010
Posts: 444
You could always use the XInput API directly (on Windows, and maybe Wine?) in your event loop. It'd be easy enough.

Another option is to just test for those values and don't allow both triggers to be held at once. I don't see anything seriously wrong with that.
Xbox 360 analog triggers
Kenneth Bull
Guest

On 18/06/2010, Nathaniel J Fries wrote:
Quote:
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

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: Xbox 360 analog triggers
Nathaniel J Fries


Joined: 30 Mar 2010
Posts: 444
Kenneth Bull wrote:
On 18/06/2010, Nathaniel J Fries wrote:
Quote:
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

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I expect that'd be more difficult.
Would certainly be more useful on Linux though.
Xbox 360 analog triggers
Edgar Simo
Guest

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

Hello,


On 2010年06月19日 01:19, Lazy Foo' wrote:
Quote:
...but the Joystick is made by Microsoft and the device is made by Microsoft Confused

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

Quote:

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:

http://en.wikipedia.org/wiki/DirectInput#DirectInput_vs_XInput

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-----
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Nathaniel J Fries


Joined: 30 Mar 2010
Posts: 444
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...