Skip to content

Commit

Permalink
Only use Steam Virtual Gamepads if we're running under Steam
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Oct 16, 2024
1 parent b1fddb7 commit 2d89f8a
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions src/joystick/SDL_gamepad.c
Original file line number Diff line number Diff line change
Expand Up @@ -2624,28 +2624,10 @@ bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid)
return true;
}

if (SDL_allowed_gamepads.num_included_entries == 0 &&
SDL_ignored_gamepads.num_included_entries == 0) {
return false;
}

SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version, NULL);

if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", false)) {
// We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real gamepads so it can remap input for the virtual gamepad
// https://partner.steamgames.com/doc/features/steam_gamepad/steam_input_gamepad_emulation_bestpractices
bool bSteamVirtualGamepad = false;
#ifdef SDL_PLATFORM_LINUX
bSteamVirtualGamepad = (vendor == USB_VENDOR_VALVE && product == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD);
#elif defined(SDL_PLATFORM_MACOS)
bSteamVirtualGamepad = (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 0);
#elif defined(SDL_PLATFORM_WIN32)
// We can't tell on Windows, but Steam will block others in input hooks
bSteamVirtualGamepad = true;
#endif
if (bSteamVirtualGamepad) {
return false;
}
if (SDL_IsJoystickSteamVirtualGamepad(vendor, product, version)) {
return !SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", false);
}

if (SDL_allowed_gamepads.num_included_entries > 0) {
Expand Down

0 comments on commit 2d89f8a

Please sign in to comment.