mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-06 01:46:25 +00:00
Added Steam Input API support for game controllers
Added support for getting the real controller info, as well as the function SDL_GetGamepadSteamHandle() to get the Steam Input API handle, from the virtual gamepads provided by Steam. Also added an event SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED which is triggered when a controller's API handle changes, e.g. the controllers were reassigned slots in the Steam UI.
This commit is contained in:
@@ -127,13 +127,31 @@ static SDL_bool GetXInputDeviceInfo(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Ui
|
||||
capabilities.ProductId = USB_PRODUCT_XBOX360_XUSB_CONTROLLER;
|
||||
}
|
||||
|
||||
*pVID = capabilities.VendorId;
|
||||
*pPID = capabilities.ProductId;
|
||||
*pVersion = capabilities.ProductVersion;
|
||||
|
||||
if (pVID) {
|
||||
*pVID = capabilities.VendorId;
|
||||
}
|
||||
if (pPID) {
|
||||
*pPID = capabilities.ProductId;
|
||||
}
|
||||
if (pVersion) {
|
||||
*pVersion = capabilities.ProductVersion;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
int SDL_XINPUT_GetSteamVirtualGamepadSlot(Uint8 userid)
|
||||
{
|
||||
XINPUT_CAPABILITIES_EX capabilities;
|
||||
|
||||
if (XINPUTGETCAPABILITIESEX &&
|
||||
XINPUTGETCAPABILITIESEX(1, userid, 0, &capabilities) == ERROR_SUCCESS &&
|
||||
capabilities.VendorId == USB_VENDOR_VALVE &&
|
||||
capabilities.ProductId == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD) {
|
||||
return (int)capabilities.unk2;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
|
||||
{
|
||||
Uint16 vendor = 0;
|
||||
|
Reference in New Issue
Block a user