SFML community forums

General => Feature requests => Topic started by: RealmRPGer on December 05, 2017, 10:27:23 pm

Title: Axis 9 and 10 for proper Xbox trigger support
Post by: RealmRPGer on December 05, 2017, 10:27:23 pm
Based on this article (https://answers.unity.com/questions/27878/triggers-on-the-360-controller-treated-as-one-axis.html) the 360/Xbox One trigger issue can be solved by accessing axes 9 and 10. SFML currently only supports up to eight axes, so this solution cannot be used. Are there any difficulties in adding access to a ninth and tenth axis?
Title: Re: Axis 9 and 10 for proper Xbox trigger support
Post by: Tank on December 07, 2017, 08:23:43 am
It might be as easy as changing this line: https://github.com/SFML/SFML/blob/master/include/SFML/Window/Joystick.hpp#L53

You can try it, recompile SFML and if it works, send in a pull request. :-)
Title: Re: Axis 9 and 10 for proper Xbox trigger support
Post by: r4gTime on January 29, 2021, 05:13:00 pm
May I dig up this topic to ask if anyone knows how to fix it without recompiling ?
As sf::Joystick::Axis is public, would it be possible to directly change the values or overwrite it ?
Thanks for your help
Title: Re: Axis 9 and 10 for proper Xbox trigger support
Post by: Elias Daler on March 04, 2021, 12:52:59 am
SFML only supports eight axes, because you need to implement XInput support to support analog triggers. Changing the enum won't work.

See more info here: https://docs.microsoft.com/en-us/windows/win32/xinput/xinput-and-directinput#using-the-xbox-controller-with-directinput

Quote
The combination of the left and right triggers in DirectInput is by design. Games have always assumed that DirectInput device axes are centered when there is no user interaction with the device. However, the Xbox controller was designed to register minimum value, not center, when the triggers are not being held. Older games would therefore assume user interaction.

The solution was to combine the triggers, setting one trigger to a positive direction and the other to a negative direction, so no user interaction is indicative to DirectInput of the "control" being at center.

In order to test the trigger values separately, you must use XInput.