SFML community forums

Help => Window => Topic started by: jammasterj007 on June 21, 2013, 10:05:05 am

Title: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: jammasterj007 on June 21, 2013, 10:05:05 am
Hey guys, I was just wondering if there is a way to receive the input for only one analog trigger as opposed to the shared Z value. I need to be able to tell when the user is pulling one/both/neither of the triggers.

Thanks,

James
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: Laurent on June 21, 2013, 10:20:14 am
The behaviour of the joystick is controlled by the driver, there's probably nothing I can do.

You should test with your OS joystick utility, and if the behaviour is the same, then I definitely can't do anything ;)
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: jammasterj007 on June 21, 2013, 04:38:54 pm
Hey Laurent, thanks for the quick reply and for making SFML in general :)

I've been doing a little more research and the problem seems to be tied to DirectInput. Apparently XInput allows the triggers to be treated as separate axes. Is there any way for me to force my application (or windows) to use XInput instead?
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: Laurent on June 21, 2013, 05:34:19 pm
No, SFML uses the multimedia library (winmm), not Xinput.
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: NoobsArePeople2 on June 29, 2013, 03:03:19 am
It looks like SDL2 supports both DirectX (XInput) and WinMM (link (http://hg.libsdl.org/SDL/file/33c15a2ec5e7/src/joystick/windows)) so it should be possible to implement in SFML. I imagine it's a fair bit of work though.
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: Laurent on June 29, 2013, 08:43:31 am
If I remember correctly (and according to the wikipedia page), XInput is basically only for XBox 360 controllers.
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: NoobsArePeople2 on June 29, 2013, 06:47:53 pm
That sounds about right.

I realize adding support for one specific gamepad probably isn't the highest priority but it would be really nice to have 360 gamepad support. I suspect 360 pads are one of the more popular gamepads on Windows as they're readily available and they just work on Windows.

That said, lack of XInput support is far from a deal breaker for me though. It's more a "nice to have".
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: Laurent on June 29, 2013, 06:59:07 pm
Quote
it would be really nice to have 360 gamepad support
To make it clear for other readers: XBox controllers are supported, it's just that triggers are merged into a single axis instead of being two separate axes.
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: G. on June 29, 2013, 09:22:56 pm
Yeah but it makes it pretty much impossible to have usual controls for racing games (with brakes and acceleration on the triggers) or 3rd person shooter (get in firing position with left trigger and fire with right trigger). :(
And the 360 gamepad is one of the most common IMO.
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: NoobsArePeople2 on June 29, 2013, 10:54:16 pm
To make it clear for other readers: XBox controllers are supported, it's just that triggers are merged into a single axis instead of being two separate axes.

You are right of course. Aside from the triggers 360 pads work just fine. I should have written:

Quote
it would be nice to have full 360 gamepad support.
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: Groogy on June 30, 2013, 09:22:26 am
Just curious, how is it with PS3 controller? Anybody tested that?
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: Mario on June 30, 2013, 11:27:09 pm
PS3 controllers won't work out of the box. They show up as a game controller but they don't actually work without third party drivers (at least on Windows). On Android they work out of the box, never tried one under Linux or Mac OS. Besides that, I'd say they should work just like any other gamepad.
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: NoobsArePeople2 on June 30, 2013, 11:55:03 pm
Just curious, how is it with PS3 controller? Anybody tested that?

I've done some testing with the PS3 pad on Windows (specifically Windows 8 ) and Mac OS (specifically 10.7). Haven't had a chance to do anything on Linux yet.

Windows

On Windows the PS3 pad won't "just work". To get the pad to work you need the MotionInJoy driver. The driver allows you to use the PS3 controller as a DX (assuming this is DirectInput) device and emulate the 360 controller (XInput).

Using the DX the triggers (L2 and R2) share a single axis but they also report digital button presses the same as pressing the X button. I noticed that the right analog stick only reports the correct values along its x-axis in this configuration. I'm getting values along y but they are not what I would expect.

In XInput mode the PS3 pads functions identically to the 360 pad -- everything works great except L2 and R2 share an axis.

All of the above is using the default configurations provided by MotionInJoy. In DX mode there are quite a few configuration options (you can customize the tilt controls offered by the SixAxis for example) and I was able to get L2 and R2 to report on different axes and resolve the issue with the right analog stick.

If you're determined I think you can make the PS3 pad fully functional with SFML on Windows in DX mode but it would hardly be "plug and play": you have to use a third-party driver that has annoying ads and you have to root around in said driver's unintuitive interface changing a bunch of settings.

To be clear this is a driver issue so I don't think there is much that can be done on the SFML end to remedy it.

Mac OS

Mac OS (since 10.6 I think) supports the PS3 pad out of the box via Bluetooth. This video explains how to pair the pad with OSX:

 (http://www.youtube.com/watch?v=Gbc7hcmpcBw)

By default all the buttons work but L2 and R2 report as digital button presses not analog axes. I haven't spent much time playing around with the PS3 pad on the Mac so I'm not sure if you can configure it or not.
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: thePyro_13 on July 07, 2013, 03:29:52 pm
If I remember correctly (and according to the wikipedia page), XInput is basically only for XBox 360 controllers.

It's encouraged by Microsoft for all controllers(though hasn't been adopted) and games(some newer games seem to support Xinput controllers much better than DirectInput ones). It seems like some of the newer Logitech controllers use both Xinput and DirectInput(with some kind of physical switch to change between them).

I was doing a bit of reading into this and found this on MSDN(http://msdn.microsoft.com/en-us/library/windows/desktop/hh405052(v=vs.85).aspx). It looks like the Flight stick mapping does separate the triggers into two axis(Z and Rz). This might lead to a workable solution for full 360 controller support on Windows.
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: nydoc on December 13, 2013, 04:23:47 am
You can convert xinput to directinput and vice-versa with the following programs:

x360ce For Windows: https://code.google.com/p/x360ce/
x360ce Wine: http://www.reddit.com/r/linux_gaming/comments/1k1xe9/using_any_gamepad_to_simulate_xbox360_controller/ccdosx4

x360csai.exe wired and wireless controllers: http://archive.jonnys-place.com/index.php?topic=10495.0
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: beterhans on March 01, 2017, 04:34:15 am
You can convert xinput to directinput and vice-versa with the following programs:

x360ce For Windows: https://code.google.com/p/x360ce/
x360ce Wine: http://www.reddit.com/r/linux_gaming/comments/1k1xe9/using_any_gamepad_to_simulate_xbox360_controller/ccdosx4

x360csai.exe wired and wireless controllers: http://archive.jonnys-place.com/index.php?topic=10495.0

Hi can you share how to convert xinput to directinput for x360ce?
the x360ce is designed for direct input => x input
I don't see any option can do reverse.

I have same problem with xbox 360 controller.
the trigger become 1 axis
and it won't work with racing game. (you can't press throttle and brake at same time, they cancel out)
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: ZeroZ30o on March 20, 2017, 03:09:42 pm
Normally the values you receive should be between -100 and 100.
If you want to separate them, consider -100 to 0 to be one trigger, and 0 to 100 to be the other.
This is the case in the PS4 controller, but I don't know if it's the same on X360.
Title: Re: Xbox 360 Controller Triggers Share Axis (Any way to isolate?)
Post by: beterhans on March 22, 2017, 12:58:56 am
OK I made an App can do this
check it out

https://www.youtube.com/watch?v=UERyvjPWFsQ