Windows: Try to use xinput9_1_0.dll if XInput 1.4 and 1.3 are not available.
authorAlex Szpakowski <slime73@gmail.com>
Mon, 14 Sep 2015 22:50:55 -0300
changeset 9865c1941443f59a
parent 9864 2e197ad97280
child 9866 88e9cf11b8eb
Windows: Try to use xinput9_1_0.dll if XInput 1.4 and 1.3 are not available.

XInput "9.1.0" ships with Windows Vista and 7 systems, but it lacks some features, including support for detecting Guide button presses.
src/core/windows/SDL_xinput.c
     1.1 --- a/src/core/windows/SDL_xinput.c	Mon Sep 14 22:44:20 2015 -0300
     1.2 +++ b/src/core/windows/SDL_xinput.c	Mon Sep 14 22:50:55 2015 -0300
     1.3 @@ -84,12 +84,16 @@
     1.4      s_pXInputDLL = LoadLibrary(L"XInput1_4.dll");  /* 1.4 Ships with Windows 8. */
     1.5      if (!s_pXInputDLL) {
     1.6          version = (1 << 16) | 3;
     1.7 -        s_pXInputDLL = LoadLibrary(L"XInput1_3.dll");  /* 1.3 Ships with Vista and Win7, can be installed as a redistributable component. */
     1.8 +        s_pXInputDLL = LoadLibrary(L"XInput1_3.dll");  /* 1.3 can be installed as a redistributable component. */
     1.9      }
    1.10      if (!s_pXInputDLL) {
    1.11          s_pXInputDLL = LoadLibrary(L"bin\\XInput1_3.dll");
    1.12      }
    1.13      if (!s_pXInputDLL) {
    1.14 +        /* "9.1.0" Ships with Vista and Win7, and is more limited than 1.3+ (e.g. XInputGetStateEx is not available.)  */
    1.15 +        s_pXInputDLL = LoadLibrary(L"XInput9_1_0.dll");
    1.16 +    }
    1.17 +    if (!s_pXInputDLL) {
    1.18          return -1;
    1.19      }
    1.20  
    1.21 @@ -99,6 +103,9 @@
    1.22  
    1.23      /* 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... */
    1.24      SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, (LPCSTR)100);
    1.25 +    if (!SDL_XInputGetState) {
    1.26 +        SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetState");
    1.27 +    }
    1.28      SDL_XInputSetState = (XInputSetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputSetState");
    1.29      SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetCapabilities");
    1.30      if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) {