Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the process to set a DirectInput device's axis mode more conservative #1634

Merged
merged 1 commit into from
Jun 18, 2020

Conversation

binary1248
Copy link
Member

This patch changes the DirectInput device initialization process to only attempt setting the device's axis mode if the device reports having axes and its axis mode is not already set to absolute. This should help when dealing with broken device drivers that report being game controllers and not fully supporting game controller functionality such as was reported here.

In order to test whether the negative case handling is improved, find someone with such a broken device driver. 😁

… it is supported. Only attempt setting a DirectInput device's axis mode if the device reports having axes and its axis mode is not already set to absolute. If the axis mode still can't be set to absolute, blacklist the device so that any future attempts will abort early. This should help when dealing with broken device drivers that report being game controllers and not fully supporting game controller functionality.
@binary1248 binary1248 force-pushed the bugfix/directinput_axis_mode branch from c3e3328 to 9e45898 Compare January 5, 2020 21:50
@binary1248
Copy link
Member Author

Added support for buffered DirectInput data and a device blacklist to abort attempting to initialize the same device in the future.

@retr0foxx
Copy link

How do i fix this ;(

@eXpl0it3r eXpl0it3r added this to the 2.6 milestone Jun 18, 2020
@eXpl0it3r eXpl0it3r merged commit 3557c46 into master Jun 18, 2020
@eXpl0it3r eXpl0it3r deleted the bugfix/directinput_axis_mode branch June 18, 2020 16:12
@PfAndrey
Copy link

PfAndrey commented Aug 2, 2020

@eXpl0it3r
Y-axis of my gamepad doesn't work after this merge (for the previous commit it worked well).

sf::Joystick::getAxisPosition(0, sf::Joystick::Axis::PovY) always returns 0 for me.

OS: 10.0.18363
Gamepad: defender game racer turbo rs3

@eXpl0it3r
Copy link
Member

@binary1248 can you explain this effect?

@binary1248
Copy link
Member Author

If I had to guess, I'd say this check fails:
https://github.com/SFML/SFML/pull/1634/files#diff-f7c9ce23dfc6bdad82ec2a0e246d1b05R764

If we can't set the axis mode to absolute although the device reports having axes the entire device is blacklisted. This verification was not done before, we just assumed that it always worked out somehow. Now that it is done we get a whole family of devices/drivers that misbehave or at least don't behave in a way that we can reason about. If we can't guarantee that the device's axis mode is set to absolute, we also can't guarantee that the values reported by our Joystick API are usable, thus this check. If the axis mode was always absolute for said device but it never reported it correctly, then... well... 🤷‍♂️

Like I said, this is only an educated guess. I don't have the hardware in question, so I can't put this hypothesis to the test. One would have to step through the Joystick code with said controller attached to see what happens and report their findings here. If it is an oversight or something trivial to fix then I have nothing against fixing the code again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants