Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Axis 9 and 10 for proper Xbox trigger support  (Read 1281 times)

0 Members and 1 Guest are viewing this topic.

RealmRPGer

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Axis 9 and 10 for proper Xbox trigger support
« on: December 05, 2017, 10:27:23 pm »
Based on this article 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?

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1483
    • View Profile
    • Blog
    • Email
Re: Axis 9 and 10 for proper Xbox trigger support
« Reply #1 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. :-)

r4gTime

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Axis 9 and 10 for proper Xbox trigger support
« Reply #2 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

Elias Daler

  • Hero Member
  • *****
  • Posts: 596
    • View Profile
    • Blog
    • Email
Re: Axis 9 and 10 for proper Xbox trigger support
« Reply #3 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.
Tomb Painter, Re:creation dev | eliasdaler.github.io | @EliasDaler | Tomb Painter dev log