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

XINPUT_STATE_EX does not exist #2797

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 1 comment
Closed

XINPUT_STATE_EX does not exist #2797

SDLBugzilla opened this issue Feb 11, 2021 · 1 comment
Labels
waiting Waiting on user response

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.1
Reported for operating system, platform: All, All

Comments on the original bug report:

On 2018-01-16 14:47:50 +0000, Andrew Eikum wrote:

Created attachment 3141
Patch to remove XINPUT_STATE_EX

This revision introduced the XINPUT_STATE_EX and XINPUT_GAMEPAD_EX structs, which are identical to XINPUT_STATE and XINPUT_GAMEPAD, but add an extra 4 bytes for "padding":

changeset: 6690:9548c8a58103
user: Sam Lantinga slouken@libsdl.org
date: Mon Nov 26 16:37:54 2012 -0800
summary: Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds

As far as I can tell, these structs do not exist in the win32 API. Tests against Microsoft's xinput DLLs show that it never writes to this padding field.

These bogus structs have been copied into mumble-voip[1] and into Wine[2] and from there into mingw-w64. It actually caused a bug in Wine due to our writing into the padding field, which the application never allocated, because it doesn't exist.

To stem the spread of these structs and prevent confusion, I suggest eliminating these structs from SDL. I've attached a diff here that eliminates them from libSDL. Note that I didn't regenerate configure and other build files, as I'm not familiar with your build system.

If you desire to keep the EX versions for type safety reasons, then I suggest eliminating the dwPaddingReserved field.

See also my thread on the Discourse[3].

I suspect the same may be true of XINPUT_BATTERY_INFORMATION_EX, but I didn't test this struct against Microsoft's implementation.

[1] mumble-voip/mumble#2018

[2] https://source.winehq.org/git/wine.git/blob/wine-3.0-rc6:/include/xinput.h#l173

[3] https://discourse.libsdl.org/t/sdl-archaeology-where-does-xinput-gamepad-ex-come-from/23714

On 2018-01-16 20:09:41 +0000, Sam Lantinga wrote:

I believe this struct is used with the undocumented XInputGetStateEx() function (ordinal 100)

Have you tried verifying that?

On 2018-01-17 13:45:04 +0000, Andrew Eikum wrote:

Yes, that's what I tested with. I set dwPaddingReserved to some value, called that function, and verified that it still had the original value afterwards. Additionally, real win32 apps do not allocate memory for dwPaddingReserved before calling ordinal 100, and they do not crash.

@SDLBugzilla SDLBugzilla added bug waiting Waiting on user response labels Feb 11, 2021
@slouken slouken removed the bug label May 11, 2022
slouken added a commit that referenced this issue Nov 5, 2023
XINPUT_STATE_EX isn't actually a thing, we can just use the normal XINPUT_STATE

Fixes #2797
@slouken slouken closed this as completed in d3f2eb2 Nov 5, 2023
@slouken
Copy link
Collaborator

slouken commented Nov 5, 2023

Patch added, thanks!

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

No branches or pull requests

2 participants