Hey all, I’m a Wine dev looking into our implementation of xinput.
We have a struct called XINPUT_GAMEPAD_EX. As far as I can tell, this struct does not actually exist in the Windows PSDK, nor almost anywhere on the Internet. It is referenced only in SDL’s header files, in some mumble-voip bugs which explicitly copy it from SDL, and in Wine itself, where I believe it was also copied from SDL.
I believe this struct originated in this changeset from SDL:
changeset: 6690:9548c8a58103 user: Sam Lantinga <firstname.lastname@example.org> date: Mon Nov 26 16:37:54 2012 -0800 summary: Added hotplug joystick support and simplified game controller API, courtesy of Alfred Reynolds
The struct is used with an undocumented function in xinput, ordinal value 100, which SDL names XInputGetState_t. Since this is undocumented, it makes some sense that its struct is undocumented as well. However, I believe that XInputGetState_t uses the same struct as XInputGetState, and the XINPUT_GAMEPAD_EX struct can be eliminated from SDL to prevent confusion going forward.
Aside from the question of whether this struct even exists, its dwPaddingReserved member caused a real problem for Wine. Since we implement xinput, we would write to this member. However, real Windows titles that call XInputGetState_t give us a buffer that is missing the dwPaddingReserved member, so we end up with a buffer overrun and difficult-to-diagnose crashes. And indeed, if you give a struct with a dwPaddingReserved member to MS’s xinput, their implementation does not overwrite this member. So the evidence is that it never existed, and XInputGetState_t takes the same struct as XInputGetState.
I plan to fix this by eliminating the struct in Wine’s headers. But I thought I’d let you know about this issue, and also take the opportunity to ask if anyone knows where this struct, and the dwPaddingReserved member in particular, came from.