Use the real device VID/PID when seeing the Steam virtual controller

This commit is contained in:
Sam Lantinga 2022-02-11 22:10:33 -08:00
parent 85e6500065
commit f97a29f6e1
1 changed files with 14 additions and 3 deletions

View File

@ -201,9 +201,20 @@ GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion)
* userid, but we'll record it so we'll at least be consistent * userid, but we'll record it so we'll at least be consistent
* when the raw device list changes. * when the raw device list changes.
*/ */
*pVID = (Uint16)rdi.hid.dwVendorId; if (rdi.hid.dwVendorId == USB_VENDOR_VALVE &&
*pPID = (Uint16)rdi.hid.dwProductId; rdi.hid.dwProductId == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD) {
*pVersion = (Uint16)rdi.hid.dwVersionNumber; /* Steam encodes the real device in the path */
int realVID = rdi.hid.dwVendorId;
int realPID = rdi.hid.dwProductId;
SDL_sscanf(devName, "\\\\.\\pipe\\HID#VID_045E&PID_028E&IG_00#%x&%x&", &realVID, &realPID);
*pVID = (Uint16)realVID;
*pPID = (Uint16)realPID;
*pVersion = 0;
} else {
*pVID = (Uint16)rdi.hid.dwVendorId;
*pPID = (Uint16)rdi.hid.dwProductId;
*pVersion = (Uint16)rdi.hid.dwVersionNumber;
}
if (s_arrXInputDevicePath[userid]) { if (s_arrXInputDevicePath[userid]) {
SDL_free(s_arrXInputDevicePath[userid]); SDL_free(s_arrXInputDevicePath[userid]);
} }