Added a private hint for Steam to bypass the controller filtering for the Steam virtual gamepad
authorSam Lantinga
Wed, 09 Aug 2017 12:38:20 -0700
changeset 112032c405337cf3d
parent 11202 e393438c4a95
child 11204 539c60c59e35
Added a private hint for Steam to bypass the controller filtering for the Steam virtual gamepad
src/joystick/SDL_gamecontroller.c
     1.1 --- a/src/joystick/SDL_gamecontroller.c	Wed Aug 09 12:11:59 2017 -0700
     1.2 +++ b/src/joystick/SDL_gamecontroller.c	Wed Aug 09 12:38:20 2017 -0700
     1.3 @@ -1264,6 +1264,22 @@
     1.4      SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
     1.5      vidpid = MAKE_VIDPID(vendor, product);
     1.6  
     1.7 +    if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE)) {
     1.8 +        /* We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real controllers so it can remap input for the virtual controller */
     1.9 +        SDL_bool bSteamVirtualGamepad = SDL_FALSE;
    1.10 +#if defined(__LINUX__)
    1.11 +        bSteamVirtualGamepad = (vendor == 0x28DE && product == 0x11FF);
    1.12 +#elif defined(__MACOSX__)
    1.13 +        bSteamVirtualGamepad = (SDL_strncmp(name, "GamePad-", 8) == 0);
    1.14 +#elif defined(__WIN32__)
    1.15 +        /* We can't tell on Windows, but Steam will block others in input hooks */
    1.16 +        bSteamVirtualGamepad = SDL_TRUE;
    1.17 +#endif
    1.18 +        if (bSteamVirtualGamepad) {
    1.19 +            return SDL_FALSE;
    1.20 +        }
    1.21 +    }
    1.22 +
    1.23      if (SDL_allowed_controllers.num_entries > 0) {
    1.24          for (i = 0; i < SDL_allowed_controllers.num_entries; ++i) {
    1.25              if (vidpid == SDL_allowed_controllers.entries[i]) {