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

Issues with L/R trigger with generic HID gamepad and Windows DInput #12249

Open
Tails86 opened this issue Feb 10, 2025 · 3 comments
Open

Issues with L/R trigger with generic HID gamepad and Windows DInput #12249

Tails86 opened this issue Feb 10, 2025 · 3 comments
Milestone

Comments

@Tails86
Copy link

Tails86 commented Feb 10, 2025

OS: Windows

I have my own HID gamepad device that I'm trying to link up with SDL. I'm trying to get to the bottom of this intermittent issue: OrangeFox86/DreamPort#112
TLDR: On first press of either trigger, the input value will jump to 50%, and the full range will be 50-100% instead of the desired 0-100% - only sometimes happens on Windows systems, but if it starts happening, it seems to persist from run to run.

I've determined that it's some kind of bug in DInput since the values coming out of IDirectInputDevice8_GetDeviceData() have a lower bound of 0 when this occurs i.e. the value of evtbuf[i].dwData @ https://github.com/libsdl-org/SDL/blob/main/src/joystick/windows/SDL_dinputjoystick.c#L1095. It's only a problem on Windows - we haven't seen this on Linux or MacOS. My device is sending values within the full range described in the HID descriptor. The online gamepad tester always provides correct results for the triggers.

For some reason, I have found that calling SDL_JoystickGetDeviceInstanceID() just after the joystick is enumerated and opened with SDL_JoystickOpen somehow kicks DInput to start giving correct values.

  • I'm wondering if there is some sort of workaround that could be built into SDL if I can determine "why" this workaround works.
  • Has anything like this been reported before?
@slouken
Copy link
Collaborator

slouken commented Feb 10, 2025

This might actually be fixed f6126e9, does that help?

@slouken slouken added this to the 3.x milestone Feb 10, 2025
@Tails86
Copy link
Author

Tails86 commented Feb 10, 2025

Oh snap! I'll try this fix in a few hours. Thanks!

@Tails86
Copy link
Author

Tails86 commented Feb 11, 2025

ah, it's going to take me a while to wrap my head around SDL3. I'll get to testing with it this weekend instead

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

No branches or pull requests

2 participants