Made the latest XInput + Haptic changes compile and run on WinRT
authorDavid Ludwig <dludwig@pobox.com>
Fri, 04 Jul 2014 18:20:23 -0400
changeset 897347fb6a7e7f68
parent 8972 dfc759d7486f
child 8974 f813b8b10b55
Made the latest XInput + Haptic changes compile and run on WinRT

Notes:
- Support for the 'Guide' button does not seem to be possible, as
XInputGetStateEx is not available on WinRT.
- Haptic support appears to be working on WinRT now!
- SDL/WinRT does not allow calls to LoadLibrary or LoadLibraryEx. The calls
to those were removed by this change, but only when compiling for WinRT.
Non-WinRT Windows will continue to detect and load XInput via LoadLibrary and
GetProcAddress calls.
VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj
VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj.filters
VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj
VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters
include/SDL_config_winrt.h
src/core/windows/SDL_xinput.c
     1.1 --- a/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj	Thu Jul 03 15:39:55 2014 -0700
     1.2 +++ b/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj	Fri Jul 04 18:20:23 2014 -0400
     1.3 @@ -234,6 +234,7 @@
     1.4      <ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
     1.5      <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
     1.6      <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
     1.7 +    <ClInclude Include="..\..\src\joystick\windows\SDL_xinputjoystick_c.h" />
     1.8      <ClInclude Include="..\..\src\render\direct3d11\SDL_render_winrt.h" />
     1.9      <ClInclude Include="..\..\src\render\mmx.h" />
    1.10      <ClInclude Include="..\..\src\render\SDL_d3dmath.h" />
    1.11 @@ -333,6 +334,7 @@
    1.12      <ClCompile Include="..\..\src\joystick\dummy\SDL_sysjoystick.c" />
    1.13      <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" />
    1.14      <ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
    1.15 +    <ClCompile Include="..\..\src\joystick\windows\SDL_xinputjoystick.c" />
    1.16      <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
    1.17      <ClCompile Include="..\..\src\power\SDL_power.c" />
    1.18      <ClCompile Include="..\..\src\power\winrt\SDL_syspower.cpp" />
     2.1 --- a/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj.filters	Thu Jul 03 15:39:55 2014 -0700
     2.2 +++ b/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj.filters	Fri Jul 04 18:20:23 2014 -0400
     2.3 @@ -357,6 +357,9 @@
     2.4      <ClInclude Include="..\..\src\video\winrt\SDL_winrtmessagebox.h">
     2.5        <Filter>Source Files</Filter>
     2.6      </ClInclude>
     2.7 +    <ClInclude Include="..\..\src\joystick\windows\SDL_xinputjoystick_c.h">
     2.8 +      <Filter>Source Files</Filter>
     2.9 +    </ClInclude>
    2.10    </ItemGroup>
    2.11    <ItemGroup>
    2.12      <ClCompile Include="..\..\src\atomic\SDL_atomic.c">
    2.13 @@ -644,5 +647,8 @@
    2.14      <ClCompile Include="..\..\src\video\winrt\SDL_winrtmessagebox.cpp">
    2.15        <Filter>Source Files</Filter>
    2.16      </ClCompile>
    2.17 +    <ClCompile Include="..\..\src\joystick\windows\SDL_xinputjoystick.c">
    2.18 +      <Filter>Source Files</Filter>
    2.19 +    </ClCompile>
    2.20    </ItemGroup>
    2.21  </Project>
    2.22 \ No newline at end of file
     3.1 --- a/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj	Thu Jul 03 15:39:55 2014 -0700
     3.2 +++ b/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj	Fri Jul 04 18:20:23 2014 -0400
     3.3 @@ -100,6 +100,7 @@
     3.4      <ClInclude Include="..\..\src\joystick\SDL_gamecontrollerdb.h" />
     3.5      <ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
     3.6      <ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
     3.7 +    <ClInclude Include="..\..\src\joystick\windows\SDL_xinputjoystick_c.h" />
     3.8      <ClInclude Include="..\..\src\render\direct3d11\SDL_render_winrt.h" />
     3.9      <ClInclude Include="..\..\src\render\mmx.h" />
    3.10      <ClInclude Include="..\..\src\render\opengles2\SDL_gles2funcs.h" />
    3.11 @@ -204,7 +205,7 @@
    3.12      <ClCompile Include="..\..\src\joystick\dummy\SDL_sysjoystick.c" />
    3.13      <ClCompile Include="..\..\src\joystick\SDL_gamecontroller.c" />
    3.14      <ClCompile Include="..\..\src\joystick\SDL_joystick.c" />
    3.15 -    <ClCompile Include="..\..\src\joystick\winrt\SDL_xinputjoystick.c" />
    3.16 +    <ClCompile Include="..\..\src\joystick\windows\SDL_xinputjoystick.c" />
    3.17      <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
    3.18      <ClCompile Include="..\..\src\power\SDL_power.c" />
    3.19      <ClCompile Include="..\..\src\power\winrt\SDL_syspower.cpp" />
     4.1 --- a/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters	Thu Jul 03 15:39:55 2014 -0700
     4.2 +++ b/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters	Fri Jul 04 18:20:23 2014 -0400
     4.3 @@ -381,6 +381,9 @@
     4.4      <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h">
     4.5        <Filter>Source Files</Filter>
     4.6      </ClInclude>
     4.7 +    <ClInclude Include="..\..\src\joystick\windows\SDL_xinputjoystick_c.h">
     4.8 +      <Filter>Source Files</Filter>
     4.9 +    </ClInclude>
    4.10    </ItemGroup>
    4.11    <ItemGroup>
    4.12      <ClCompile Include="..\..\src\atomic\SDL_atomic.c">
    4.13 @@ -485,9 +488,6 @@
    4.14      <ClCompile Include="..\..\src\joystick\SDL_joystick.c">
    4.15        <Filter>Source Files</Filter>
    4.16      </ClCompile>
    4.17 -    <ClCompile Include="..\..\src\joystick\winrt\SDL_xinputjoystick.c">
    4.18 -      <Filter>Source Files</Filter>
    4.19 -    </ClCompile>
    4.20      <ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c">
    4.21        <Filter>Source Files</Filter>
    4.22      </ClCompile>
    4.23 @@ -683,5 +683,8 @@
    4.24      <ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
    4.25        <Filter>Source Files</Filter>
    4.26      </ClCompile>
    4.27 +    <ClCompile Include="..\..\src\joystick\windows\SDL_xinputjoystick.c">
    4.28 +      <Filter>Source Files</Filter>
    4.29 +    </ClCompile>
    4.30    </ItemGroup>
    4.31  </Project>
    4.32 \ No newline at end of file
     5.1 --- a/include/SDL_config_winrt.h	Thu Jul 03 15:39:55 2014 -0700
     5.2 +++ b/include/SDL_config_winrt.h	Fri Jul 04 18:20:23 2014 -0400
     5.3 @@ -78,7 +78,9 @@
     5.4  
     5.5  /* Useful headers */
     5.6  #define HAVE_DXGI_H 1
     5.7 +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
     5.8  #define HAVE_XINPUT_H 1
     5.9 +#endif
    5.10  #define HAVE_LIBC 1
    5.11  #define HAVE_STDIO_H 1
    5.12  #define STDC_HEADERS 1
     6.1 --- a/src/core/windows/SDL_xinput.c	Thu Jul 03 15:39:55 2014 -0700
     6.2 +++ b/src/core/windows/SDL_xinput.c	Fri Jul 04 18:20:23 2014 -0400
     6.3 @@ -35,6 +35,40 @@
     6.4  static int s_XInputDLLRefCount = 0;
     6.5  
     6.6  
     6.7 +#ifdef __WINRT__
     6.8 +
     6.9 +int
    6.10 +WIN_LoadXInputDLL(void)
    6.11 +{
    6.12 +    /* Getting handles to system dlls (via LoadLibrary and its variants) is not
    6.13 +     * supported on WinRT, thus, pointers to XInput's functions can't be
    6.14 +     * retrieved via GetProcAddress.
    6.15 +     *
    6.16 +     * When on WinRT, assume that XInput is already loaded, and directly map
    6.17 +     * its XInput.h-declared functions to the SDL_XInput* set of function
    6.18 +     * pointers.
    6.19 +     *
    6.20 +     * Side-note: XInputGetStateEx is not available for use in WinRT.
    6.21 +     * This seems to mean that support for the guide button is not available
    6.22 +     * in WinRT, unfortunately.
    6.23 +     */
    6.24 +    SDL_XInputGetState = (XInputGetState_t)XInputGetState;
    6.25 +    SDL_XInputSetState = (XInputSetState_t)XInputSetState;
    6.26 +    SDL_XInputGetCapabilities = (XInputGetCapabilities_t)XInputGetCapabilities;
    6.27 +
    6.28 +    /* XInput 1.4 ships with Windows 8 and 8.1: */
    6.29 +    SDL_XInputVersion = (1 << 16) | 4;
    6.30 +
    6.31 +    return 0;
    6.32 +}
    6.33 +
    6.34 +void
    6.35 +WIN_UnloadXInputDLL(void)
    6.36 +{
    6.37 +}
    6.38 +
    6.39 +#else /* !__WINRT__ */
    6.40 +
    6.41  int
    6.42  WIN_LoadXInputDLL(void)
    6.43  {
    6.44 @@ -89,6 +123,7 @@
    6.45      }
    6.46  }
    6.47  
    6.48 +#endif /* __WINRT__ */
    6.49  #endif /* HAVE_XINPUT_H */
    6.50  
    6.51  /* vi: set ts=4 sw=4 expandtab: */