We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4471 - [patch] Greatly simplify SDL_IsXInputDevice()
Summary: [patch] Greatly simplify SDL_IsXInputDevice()
Status: RESOLVED WONTFIX
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: HG 2.1
Hardware: x86 Windows (All)
: P2 minor
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-24 23:51 UTC by Jimb Esser
Modified: 2019-01-28 17:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jimb Esser 2019-01-24 23:51:56 UTC
Now that we're generally getting the HID path for DirectInput devices anyway, we can trivially look at that instead of searching all raw HID devices for one that matches the vendor/product IDs and using that to look up the HID path.  Unless I'm missing something, this greatly simplifies this code.

Only real functional change (besides potentially a lot less calling of GetRawInputDeviceList) is we're now momentarily creating the DInput interface (to query the HID path from) for some joysticks that we previously would not  have been.

Admittedly, the original SDL_IsXInputDevice early-outs on the hard-coded list of known IDs, so this is probably going to do slightly more work, but never more than when XInput is disabled anyway.  I could refactor this to keep the early-out if really needed.

Can view the diff here: https://github.com/Jimbly/SDL-mirror/commit/a8f450f66b3a0bc5835524025167cdf6cd7f738c

Patch file: https://github.com/Jimbly/SDL-mirror/commit/a8f450f66b3a0bc5835524025167cdf6cd7f738c.patch
Comment 1 Jimb Esser 2019-01-25 00:01:49 UTC
Hmm... stumbled upon this bug: https://bugzilla.libsdl.org/show_bug.cgi?id=3403 which seems to indicate looking for "IG_" might not be right anymore (though, possibly, only through the RawDevices API, not through the DirectInput query).  I'll have an XBox One controller in a couple days and will investigate further.
Comment 2 Sam Lantinga 2019-01-25 09:52:25 UTC
Creating the DInput interface is very expensive, and under the hood does a lot of raw HID calls. The original code is probably better.
Comment 3 Jimb Esser 2019-01-28 17:06:47 UTC
Okay, fair enough.