WinRT: file naming and placement cleanup
authorDavid Ludwig <dludwig@pobox.com>
Tue, 20 Aug 2013 21:22:32 -0400
changeset 8483d403ded25942
parent 8482 eb0b00e7519e
child 8484 7258989352eb
WinRT: file naming and placement cleanup
- moved SDL_WinRTApp.* from src/video/windowsrt/ to src/core/winrt/, and renamed them to SDL_winrtapp.* (to mimick case-sensitivity used elsewhere in SDL)
- renamed all "windowsrt" directories (in src) to "winrt", as the shorthand name is used more often (and, IMO, "WinRT" != "Windows RT", not entirely at least)
VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj
VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj.filters
VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj
VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters
src/core/windowsrt/SDL_winrtpaths.cpp
src/core/winrt/SDL_winrtapp.cpp
src/core/winrt/SDL_winrtapp.h
src/core/winrt/SDL_winrtpaths.cpp
src/video/windowsrt/SDL_WinRTApp.cpp
src/video/windowsrt/SDL_WinRTApp.h
src/video/windowsrt/SDL_winrtevents.cpp
src/video/windowsrt/SDL_winrtevents_c.h
src/video/windowsrt/SDL_winrtmouse.cpp
src/video/windowsrt/SDL_winrtmouse.h
src/video/windowsrt/SDL_winrtvideo.cpp
src/video/windowsrt/SDL_winrtvideo.h
src/video/winrt/SDL_winrtevents.cpp
src/video/winrt/SDL_winrtevents_c.h
src/video/winrt/SDL_winrtmouse.cpp
src/video/winrt/SDL_winrtmouse.h
src/video/winrt/SDL_winrtvideo.cpp
src/video/winrt/SDL_winrtvideo.h
     1.1 --- a/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj	Tue Aug 13 20:33:15 2013 -0400
     1.2 +++ b/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj	Tue Aug 20 21:22:32 2013 -0400
     1.3 @@ -197,6 +197,7 @@
     1.4      <ClInclude Include="..\..\src\audio\SDL_wave.h" />
     1.5      <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
     1.6      <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
     1.7 +    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h" />
     1.8      <ClInclude Include="..\..\src\events\blank_cursor.h" />
     1.9      <ClInclude Include="..\..\src\events\default_cursor.h" />
    1.10      <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
    1.11 @@ -244,10 +245,9 @@
    1.12      <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
    1.13      <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
    1.14      <ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
    1.15 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h" />
    1.16 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h" />
    1.17 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h" />
    1.18 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h" />
    1.19 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h" />
    1.20 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse.h" />
    1.21 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo.h" />
    1.22    </ItemGroup>
    1.23    <ItemGroup>
    1.24      <ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
    1.25 @@ -272,13 +272,19 @@
    1.26        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.27        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.28      </ClCompile>
    1.29 -    <ClCompile Include="..\..\src\core\windowsrt\SDL_winrtpaths.cpp">
    1.30 +    <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
    1.31 +    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
    1.32        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.33        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.34        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.35        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.36      </ClCompile>
    1.37 -    <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
    1.38 +    <ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp">
    1.39 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.40 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.41 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.42 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.43 +    </ClCompile>
    1.44      <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
    1.45      <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
    1.46      <ClCompile Include="..\..\src\events\SDL_dropevents.c" />
    1.47 @@ -351,25 +357,19 @@
    1.48      <ClCompile Include="..\..\src\video\SDL_stretch.c" />
    1.49      <ClCompile Include="..\..\src\video\SDL_surface.c" />
    1.50      <ClCompile Include="..\..\src\video\SDL_video.c" />
    1.51 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_WinRTApp.cpp">
    1.52 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtevents.cpp">
    1.53        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.54        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.55        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.56        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.57      </ClCompile>
    1.58 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
    1.59 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtmouse.cpp">
    1.60        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.61        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.62        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.63        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.64      </ClCompile>
    1.65 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
    1.66 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.67 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.68 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    1.69 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    1.70 -    </ClCompile>
    1.71 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
    1.72 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
    1.73        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    1.74        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    1.75        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
     2.1 --- a/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj.filters	Tue Aug 13 20:33:15 2013 -0400
     2.2 +++ b/VisualC-WinPhone/SDL/SDL_VS2012-WinPhone.vcxproj.filters	Tue Aug 20 21:22:32 2013 -0400
     2.3 @@ -321,19 +321,19 @@
     2.4      <ClInclude Include="..\..\src\video\SDL_sysvideo.h">
     2.5        <Filter>Source Files</Filter>
     2.6      </ClInclude>
     2.7 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h">
     2.8 +    <ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h">
     2.9        <Filter>Source Files</Filter>
    2.10      </ClInclude>
    2.11 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h">
    2.12 +    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h">
    2.13        <Filter>Source Files</Filter>
    2.14      </ClInclude>
    2.15 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h">
    2.16 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h">
    2.17        <Filter>Source Files</Filter>
    2.18      </ClInclude>
    2.19 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h">
    2.20 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse.h">
    2.21        <Filter>Source Files</Filter>
    2.22      </ClInclude>
    2.23 -    <ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h">
    2.24 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo.h">
    2.25        <Filter>Source Files</Filter>
    2.26      </ClInclude>
    2.27    </ItemGroup>
    2.28 @@ -374,9 +374,6 @@
    2.29      <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.cpp">
    2.30        <Filter>Source Files</Filter>
    2.31      </ClCompile>
    2.32 -    <ClCompile Include="..\..\src\core\windowsrt\SDL_winrtpaths.cpp">
    2.33 -      <Filter>Source Files</Filter>
    2.34 -    </ClCompile>
    2.35      <ClCompile Include="..\..\src\core\windows\SDL_windows.c">
    2.36        <Filter>Source Files</Filter>
    2.37      </ClCompile>
    2.38 @@ -572,18 +569,6 @@
    2.39      <ClCompile Include="..\..\src\video\SDL_video.c">
    2.40        <Filter>Source Files</Filter>
    2.41      </ClCompile>
    2.42 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_WinRTApp.cpp">
    2.43 -      <Filter>Source Files</Filter>
    2.44 -    </ClCompile>
    2.45 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
    2.46 -      <Filter>Source Files</Filter>
    2.47 -    </ClCompile>
    2.48 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
    2.49 -      <Filter>Source Files</Filter>
    2.50 -    </ClCompile>
    2.51 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
    2.52 -      <Filter>Source Files</Filter>
    2.53 -    </ClCompile>
    2.54      <ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.cpp">
    2.55        <Filter>Source Files</Filter>
    2.56      </ClCompile>
    2.57 @@ -593,6 +578,21 @@
    2.58      <ClCompile Include="..\..\src\stdlib\SDL_malloc.c">
    2.59        <Filter>Source Files</Filter>
    2.60      </ClCompile>
    2.61 +    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
    2.62 +      <Filter>Source Files</Filter>
    2.63 +    </ClCompile>
    2.64 +    <ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp">
    2.65 +      <Filter>Source Files</Filter>
    2.66 +    </ClCompile>
    2.67 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtevents.cpp">
    2.68 +      <Filter>Source Files</Filter>
    2.69 +    </ClCompile>
    2.70 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtmouse.cpp">
    2.71 +      <Filter>Source Files</Filter>
    2.72 +    </ClCompile>
    2.73 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
    2.74 +      <Filter>Source Files</Filter>
    2.75 +    </ClCompile>
    2.76    </ItemGroup>
    2.77    <ItemGroup>
    2.78      <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
     3.1 --- a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj	Tue Aug 13 20:33:15 2013 -0400
     3.2 +++ b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj	Tue Aug 20 21:22:32 2013 -0400
     3.3 @@ -53,7 +53,8 @@
     3.4        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
     3.5        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
     3.6      </ClCompile>
     3.7 -    <ClCompile Include="..\..\src\core\windowsrt\SDL_winrtpaths.cpp">
     3.8 +    <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
     3.9 +    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
    3.10        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    3.11        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    3.12        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    3.13 @@ -61,7 +62,14 @@
    3.14        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    3.15        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    3.16      </ClCompile>
    3.17 -    <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
    3.18 +    <ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp">
    3.19 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    3.20 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    3.21 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    3.22 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    3.23 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    3.24 +      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    3.25 +    </ClCompile>
    3.26      <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
    3.27      <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
    3.28      <ClCompile Include="..\..\src\events\SDL_dropevents.c" />
    3.29 @@ -136,7 +144,7 @@
    3.30      <ClCompile Include="..\..\src\video\SDL_stretch.c" />
    3.31      <ClCompile Include="..\..\src\video\SDL_surface.c" />
    3.32      <ClCompile Include="..\..\src\video\SDL_video.c" />
    3.33 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_WinRTApp.cpp">
    3.34 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtevents.cpp">
    3.35        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    3.36        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    3.37        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    3.38 @@ -144,7 +152,7 @@
    3.39        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    3.40        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    3.41      </ClCompile>
    3.42 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
    3.43 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtmouse.cpp">
    3.44        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    3.45        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    3.46        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    3.47 @@ -152,15 +160,7 @@
    3.48        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    3.49        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    3.50      </ClCompile>
    3.51 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
    3.52 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    3.53 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    3.54 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    3.55 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
    3.56 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
    3.57 -      <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
    3.58 -    </ClCompile>
    3.59 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
    3.60 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
    3.61        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
    3.62        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
    3.63        <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
    3.64 @@ -227,6 +227,7 @@
    3.65      <ClInclude Include="..\..\src\audio\SDL_wave.h" />
    3.66      <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h" />
    3.67      <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
    3.68 +    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h" />
    3.69      <ClInclude Include="..\..\src\events\blank_cursor.h" />
    3.70      <ClInclude Include="..\..\src\events\default_cursor.h" />
    3.71      <ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
    3.72 @@ -275,10 +276,9 @@
    3.73      <ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
    3.74      <ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
    3.75      <ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
    3.76 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h" />
    3.77 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h" />
    3.78 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h" />
    3.79 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h" />
    3.80 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h" />
    3.81 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse.h" />
    3.82 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo.h" />
    3.83    </ItemGroup>
    3.84    <ItemGroup>
    3.85      <FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
     4.1 --- a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters	Tue Aug 13 20:33:15 2013 -0400
     4.2 +++ b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters	Tue Aug 20 21:22:32 2013 -0400
     4.3 @@ -225,18 +225,6 @@
     4.4      <ClCompile Include="..\..\src\core\windows\SDL_windows.c">
     4.5        <Filter>Source Files</Filter>
     4.6      </ClCompile>
     4.7 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_WinRTApp.cpp">
     4.8 -      <Filter>Source Files</Filter>
     4.9 -    </ClCompile>
    4.10 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtevents.cpp">
    4.11 -      <Filter>Source Files</Filter>
    4.12 -    </ClCompile>
    4.13 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtmouse.cpp">
    4.14 -      <Filter>Source Files</Filter>
    4.15 -    </ClCompile>
    4.16 -    <ClCompile Include="..\..\src\video\windowsrt\SDL_winrtvideo.cpp">
    4.17 -      <Filter>Source Files</Filter>
    4.18 -    </ClCompile>
    4.19      <ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2.c">
    4.20        <Filter>Source Files</Filter>
    4.21      </ClCompile>
    4.22 @@ -252,9 +240,6 @@
    4.23      <ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c">
    4.24        <Filter>Source Files</Filter>
    4.25      </ClCompile>
    4.26 -    <ClCompile Include="..\..\src\core\windowsrt\SDL_winrtpaths.cpp">
    4.27 -      <Filter>Source Files</Filter>
    4.28 -    </ClCompile>
    4.29      <ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.cpp">
    4.30        <Filter>Source Files</Filter>
    4.31      </ClCompile>
    4.32 @@ -267,6 +252,21 @@
    4.33      <ClCompile Include="..\..\src\stdlib\SDL_malloc.c">
    4.34        <Filter>Source Files</Filter>
    4.35      </ClCompile>
    4.36 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtevents.cpp">
    4.37 +      <Filter>Source Files</Filter>
    4.38 +    </ClCompile>
    4.39 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtmouse.cpp">
    4.40 +      <Filter>Source Files</Filter>
    4.41 +    </ClCompile>
    4.42 +    <ClCompile Include="..\..\src\video\winrt\SDL_winrtvideo.cpp">
    4.43 +      <Filter>Source Files</Filter>
    4.44 +    </ClCompile>
    4.45 +    <ClCompile Include="..\..\src\core\winrt\SDL_winrtapp.cpp">
    4.46 +      <Filter>Source Files</Filter>
    4.47 +    </ClCompile>
    4.48 +    <ClCompile Include="..\..\src\core\winrt\SDL_winrtpaths.cpp">
    4.49 +      <Filter>Source Files</Filter>
    4.50 +    </ClCompile>
    4.51    </ItemGroup>
    4.52    <ItemGroup>
    4.53      <ClInclude Include="..\..\include\begin_code.h">
    4.54 @@ -353,9 +353,6 @@
    4.55      <ClInclude Include="..\..\src\events\SDL_windowevents_c.h">
    4.56        <Filter>Source Files</Filter>
    4.57      </ClInclude>
    4.58 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtevents_c.h">
    4.59 -      <Filter>Source Files</Filter>
    4.60 -    </ClInclude>
    4.61      <ClInclude Include="..\..\src\render\SDL_yuv_sw_c.h">
    4.62        <Filter>Source Files</Filter>
    4.63      </ClInclude>
    4.64 @@ -569,15 +566,6 @@
    4.65      <ClInclude Include="..\..\src\core\windows\SDL_windows.h">
    4.66        <Filter>Source Files</Filter>
    4.67      </ClInclude>
    4.68 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_WinRTApp.h">
    4.69 -      <Filter>Source Files</Filter>
    4.70 -    </ClInclude>
    4.71 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtmouse.h">
    4.72 -      <Filter>Source Files</Filter>
    4.73 -    </ClInclude>
    4.74 -    <ClInclude Include="..\..\src\video\windowsrt\SDL_winrtvideo.h">
    4.75 -      <Filter>Source Files</Filter>
    4.76 -    </ClInclude>
    4.77      <ClInclude Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.h">
    4.78        <Filter>Source Files</Filter>
    4.79      </ClInclude>
    4.80 @@ -596,6 +584,18 @@
    4.81      <ClInclude Include="..\..\src\joystick\SDL_gamecontrollerdb.h">
    4.82        <Filter>Header Files</Filter>
    4.83      </ClInclude>
    4.84 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h">
    4.85 +      <Filter>Source Files</Filter>
    4.86 +    </ClInclude>
    4.87 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse.h">
    4.88 +      <Filter>Source Files</Filter>
    4.89 +    </ClInclude>
    4.90 +    <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo.h">
    4.91 +      <Filter>Source Files</Filter>
    4.92 +    </ClInclude>
    4.93 +    <ClInclude Include="..\..\src\core\winrt\SDL_winrtapp.h">
    4.94 +      <Filter>Source Files</Filter>
    4.95 +    </ClInclude>
    4.96    </ItemGroup>
    4.97    <ItemGroup>
    4.98      <Filter Include="Header Files">
     5.1 --- a/src/core/windowsrt/SDL_winrtpaths.cpp	Tue Aug 13 20:33:15 2013 -0400
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,94 +0,0 @@
     5.4 -/* TODO, WinRT: include copyright info in SDL_winrtpaths.cpp
     5.5 -   TODO, WinRT: add note to SDL_winrtpaths.cpp mentioning that /ZW must be used when compiling the file
     5.6 -*/
     5.7 -
     5.8 -#include "SDL_config.h"
     5.9 -
    5.10 -#ifdef __WINRT__
    5.11 -
    5.12 -extern "C" {
    5.13 -#include "SDL_error.h"
    5.14 -#include "SDL_stdinc.h"
    5.15 -#include "SDL_system.h"
    5.16 -#include "../windows/SDL_windows.h"
    5.17 -}
    5.18 -
    5.19 -#include <string>
    5.20 -#include <unordered_map>
    5.21 -
    5.22 -using namespace std;
    5.23 -using namespace Windows::Storage;
    5.24 -
    5.25 -extern "C" const wchar_t *
    5.26 -SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
    5.27 -{
    5.28 -    switch (pathType) {
    5.29 -        case SDL_WINRT_PATH_INSTALLED_LOCATION:
    5.30 -        {
    5.31 -            static wstring path;
    5.32 -            if (path.empty()) {
    5.33 -                path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
    5.34 -            }
    5.35 -            return path.c_str();
    5.36 -        }
    5.37 -
    5.38 -        case SDL_WINRT_PATH_LOCAL_FOLDER:
    5.39 -        {
    5.40 -            static wstring path;
    5.41 -            if (path.empty()) {
    5.42 -                path = ApplicationData::Current->LocalFolder->Path->Data();
    5.43 -            }
    5.44 -            return path.c_str();
    5.45 -        }
    5.46 -
    5.47 -#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
    5.48 -        case SDL_WINRT_PATH_ROAMING_FOLDER:
    5.49 -        {
    5.50 -            static wstring path;
    5.51 -            if (path.empty()) {
    5.52 -                path = ApplicationData::Current->RoamingFolder->Path->Data();
    5.53 -            }
    5.54 -            return path.c_str();
    5.55 -        }
    5.56 -
    5.57 -        case SDL_WINRT_PATH_TEMP_FOLDER:
    5.58 -        {
    5.59 -            static wstring path;
    5.60 -            if (path.empty()) {
    5.61 -                path = ApplicationData::Current->TemporaryFolder->Path->Data();
    5.62 -            }
    5.63 -            return path.c_str();
    5.64 -        }
    5.65 -#endif
    5.66 -
    5.67 -        default:
    5.68 -            break;
    5.69 -    }
    5.70 -
    5.71 -    SDL_Unsupported();
    5.72 -    return NULL;
    5.73 -}
    5.74 -
    5.75 -extern "C" const char *
    5.76 -SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
    5.77 -{
    5.78 -    typedef unordered_map<SDL_WinRT_Path, string> UTF8PathMap;
    5.79 -    static UTF8PathMap utf8Paths;
    5.80 -
    5.81 -    UTF8PathMap::iterator searchResult = utf8Paths.find(pathType);
    5.82 -    if (searchResult != utf8Paths.end()) {
    5.83 -        return searchResult->second.c_str();
    5.84 -    }
    5.85 -
    5.86 -    const wchar_t * ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
    5.87 -    if (!ucs2Path) {
    5.88 -        return NULL;
    5.89 -    }
    5.90 -
    5.91 -    char * utf8Path = WIN_StringToUTF8(ucs2Path);
    5.92 -    utf8Paths[pathType] = utf8Path;
    5.93 -    SDL_free(utf8Path);
    5.94 -    return utf8Paths[pathType].c_str();
    5.95 -}
    5.96 -
    5.97 -#endif /* __WINRT__ */
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/core/winrt/SDL_winrtapp.cpp	Tue Aug 20 21:22:32 2013 -0400
     6.3 @@ -0,0 +1,986 @@
     6.4 +
     6.5 +#include <string>
     6.6 +#include <unordered_map>
     6.7 +#include <sstream>
     6.8 +
     6.9 +#include "ppltasks.h"
    6.10 +
    6.11 +extern "C" {
    6.12 +#include "SDL_assert.h"
    6.13 +#include "SDL_events.h"
    6.14 +#include "SDL_hints.h"
    6.15 +#include "SDL_log.h"
    6.16 +#include "SDL_main.h"
    6.17 +#include "SDL_stdinc.h"
    6.18 +#include "SDL_render.h"
    6.19 +#include "../../video/SDL_sysvideo.h"
    6.20 +//#include "../../SDL_hints_c.h"
    6.21 +#include "../../events/scancodes_windows.h"
    6.22 +#include "../../events/SDL_mouse_c.h"
    6.23 +#include "../../events/SDL_keyboard_c.h"
    6.24 +#include "../../events/SDL_windowevents_c.h"
    6.25 +#include "../../render/SDL_sysrender.h"
    6.26 +}
    6.27 +
    6.28 +#include "../../video/winrt/SDL_winrtvideo.h"
    6.29 +#include "SDL_winrtapp.h"
    6.30 +
    6.31 +using namespace concurrency;
    6.32 +using namespace std;
    6.33 +using namespace Windows::ApplicationModel;
    6.34 +using namespace Windows::ApplicationModel::Core;
    6.35 +using namespace Windows::ApplicationModel::Activation;
    6.36 +using namespace Windows::Devices::Input;
    6.37 +using namespace Windows::Graphics::Display;
    6.38 +using namespace Windows::Foundation;
    6.39 +using namespace Windows::System;
    6.40 +using namespace Windows::UI::Core;
    6.41 +using namespace Windows::UI::Input;
    6.42 +
    6.43 +// Compile-time debugging options:
    6.44 +// To enable, uncomment; to disable, comment them out.
    6.45 +//#define LOG_POINTER_EVENTS 1
    6.46 +//#define LOG_WINDOW_EVENTS 1
    6.47 +//#define LOG_ORIENTATION_EVENTS 1
    6.48 +
    6.49 +
    6.50 +// HACK, DLudwig: The C-style main() will get loaded via the app's
    6.51 +// WinRT-styled main(), which is part of SDLmain_for_WinRT.cpp.
    6.52 +// This seems wrong on some level, but does seem to work.
    6.53 +typedef int (*SDL_WinRT_MainFunction)(int, char **);
    6.54 +static SDL_WinRT_MainFunction SDL_WinRT_main = nullptr;
    6.55 +
    6.56 +// HACK, DLudwig: record a reference to the global, Windows RT 'app'/view.
    6.57 +// SDL/WinRT will use this throughout its code.
    6.58 +//
    6.59 +// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something
    6.60 +// non-global, such as something created inside
    6.61 +// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside
    6.62 +// SDL_CreateWindow().
    6.63 +SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
    6.64 +
    6.65 +ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
    6.66 +{
    6.67 +public:
    6.68 +    virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
    6.69 +};
    6.70 +
    6.71 +IFrameworkView^ SDLApplicationSource::CreateView()
    6.72 +{
    6.73 +    // TODO, WinRT: see if this function (CreateView) can ever get called
    6.74 +    // more than once.  For now, just prevent it from ever assigning
    6.75 +    // SDL_WinRTGlobalApp more than once.
    6.76 +    SDL_assert(!SDL_WinRTGlobalApp);
    6.77 +    SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
    6.78 +    if (!SDL_WinRTGlobalApp)
    6.79 +    {
    6.80 +        SDL_WinRTGlobalApp = app;
    6.81 +    }
    6.82 +    return app;
    6.83 +}
    6.84 +
    6.85 +__declspec(dllexport) int SDL_WinRT_RunApplication(SDL_WinRT_MainFunction mainFunction)
    6.86 +{
    6.87 +    SDL_WinRT_main = mainFunction;
    6.88 +    auto direct3DApplicationSource = ref new SDLApplicationSource();
    6.89 +    CoreApplication::Run(direct3DApplicationSource);
    6.90 +    return 0;
    6.91 +}
    6.92 +
    6.93 +static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
    6.94 +{
    6.95 +    SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
    6.96 +
    6.97 +    // Start with no orientation flags, then add each in as they're parsed
    6.98 +    // from newValue.
    6.99 +    unsigned int orientationFlags = 0;
   6.100 +    if (newValue) {
   6.101 +        std::istringstream tokenizer(newValue);
   6.102 +        while (!tokenizer.eof()) {
   6.103 +            std::string orientationName;
   6.104 +            std::getline(tokenizer, orientationName, ' ');
   6.105 +            if (orientationName == "LandscapeLeft") {
   6.106 +                orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped;
   6.107 +            } else if (orientationName == "LandscapeRight") {
   6.108 +                orientationFlags |= (unsigned int) DisplayOrientations::Landscape;
   6.109 +            } else if (orientationName == "Portrait") {
   6.110 +                orientationFlags |= (unsigned int) DisplayOrientations::Portrait;
   6.111 +            } else if (orientationName == "PortraitUpsideDown") {
   6.112 +                orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped;
   6.113 +            }
   6.114 +        }
   6.115 +    }
   6.116 +
   6.117 +    // If no valid orientation flags were specified, use a reasonable set of defaults:
   6.118 +    if (!orientationFlags) {
   6.119 +        // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s).
   6.120 +        orientationFlags = (unsigned int) ( \
   6.121 +            DisplayOrientations::Landscape |
   6.122 +            DisplayOrientations::LandscapeFlipped |
   6.123 +            DisplayOrientations::Portrait |
   6.124 +            DisplayOrientations::PortraitFlipped);
   6.125 +    }
   6.126 +
   6.127 +    // Set the orientation/rotation preferences.  Please note that this does
   6.128 +    // not constitute a 100%-certain lock of a given set of possible
   6.129 +    // orientations.  According to Microsoft's documentation on Windows RT [1]
   6.130 +    // when a device is not capable of being rotated, Windows may ignore
   6.131 +    // the orientation preferences, and stick to what the device is capable of
   6.132 +    // displaying.
   6.133 +    //
   6.134 +    // [1] Documentation on the 'InitialRotationPreference' setting for a
   6.135 +    // Windows app's manifest file describes how some orientation/rotation
   6.136 +    // preferences may be ignored.  See
   6.137 +    // http://msdn.microsoft.com/en-us/library/windows/apps/hh700343.aspx
   6.138 +    // for details.  Microsoft's "Display orientation sample" also gives an
   6.139 +    // outline of how Windows treats device rotation
   6.140 +    // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
   6.141 +    DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
   6.142 +}
   6.143 +
   6.144 +SDL_WinRTApp::SDL_WinRTApp() :
   6.145 +    m_windowClosed(false),
   6.146 +    m_windowVisible(true),
   6.147 +    m_sdlWindowData(NULL),
   6.148 +    m_sdlVideoDevice(NULL),
   6.149 +    m_useRelativeMouseMode(false)
   6.150 +{
   6.151 +}
   6.152 +
   6.153 +void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
   6.154 +{
   6.155 +    applicationView->Activated +=
   6.156 +        ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
   6.157 +
   6.158 +    CoreApplication::Suspending +=
   6.159 +        ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
   6.160 +
   6.161 +    CoreApplication::Resuming +=
   6.162 +        ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
   6.163 +
   6.164 +    DisplayProperties::OrientationChanged +=
   6.165 +        ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged);
   6.166 +
   6.167 +    // Register the hint, SDL_HINT_ORIENTATIONS, with SDL.  This needs to be
   6.168 +    // done before the hint's callback is registered (as of Feb 22, 2013),
   6.169 +    // otherwise the hint callback won't get registered.
   6.170 +    //
   6.171 +    // WinRT, TODO: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly.
   6.172 +    //SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight Portrait PortraitUpsideDown");   // DavidL: this is no longer needed (for SDL_AddHintCallback)
   6.173 +    SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL);
   6.174 +}
   6.175 +
   6.176 +void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
   6.177 +{
   6.178 +#if LOG_ORIENTATION_EVENTS==1
   6.179 +    CoreWindow^ window = CoreWindow::GetForCurrentThread();
   6.180 +    if (window) {
   6.181 +        SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Size={%f,%f}\n",
   6.182 +            __FUNCTION__,
   6.183 +            (int)DisplayProperties::CurrentOrientation,
   6.184 +            (int)DisplayProperties::NativeOrientation,
   6.185 +            (int)DisplayProperties::AutoRotationPreferences,
   6.186 +            window->Bounds.Width,
   6.187 +            window->Bounds.Height);
   6.188 +    } else {
   6.189 +        SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n",
   6.190 +            __FUNCTION__,
   6.191 +            (int)DisplayProperties::CurrentOrientation,
   6.192 +            (int)DisplayProperties::NativeOrientation,
   6.193 +            (int)DisplayProperties::AutoRotationPreferences);
   6.194 +    }
   6.195 +#endif
   6.196 +}
   6.197 +
   6.198 +void SDL_WinRTApp::SetWindow(CoreWindow^ window)
   6.199 +{
   6.200 +#if LOG_WINDOW_EVENTS==1
   6.201 +    SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window Size={%f,%f}\n",
   6.202 +        __FUNCTION__,
   6.203 +        (int)DisplayProperties::CurrentOrientation,
   6.204 +        (int)DisplayProperties::NativeOrientation,
   6.205 +        (int)DisplayProperties::AutoRotationPreferences,
   6.206 +        window->Bounds.Width,
   6.207 +        window->Bounds.Height);
   6.208 +#endif
   6.209 +
   6.210 +    window->SizeChanged += 
   6.211 +        ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
   6.212 +
   6.213 +    window->VisibilityChanged +=
   6.214 +        ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
   6.215 +
   6.216 +    window->Closed += 
   6.217 +        ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
   6.218 +
   6.219 +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
   6.220 +    window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
   6.221 +#endif
   6.222 +
   6.223 +    window->PointerPressed +=
   6.224 +        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
   6.225 +
   6.226 +    window->PointerReleased +=
   6.227 +        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
   6.228 +
   6.229 +    window->PointerWheelChanged +=
   6.230 +        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerWheelChanged);
   6.231 +
   6.232 +    window->PointerMoved +=
   6.233 +        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
   6.234 +
   6.235 +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
   6.236 +    // Retrieves relative-only mouse movements:
   6.237 +    Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
   6.238 +        ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &SDL_WinRTApp::OnMouseMoved);
   6.239 +#endif
   6.240 +
   6.241 +    window->KeyDown +=
   6.242 +        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyDown);
   6.243 +
   6.244 +    window->KeyUp +=
   6.245 +        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyUp);
   6.246 +}
   6.247 +
   6.248 +void SDL_WinRTApp::Load(Platform::String^ entryPoint)
   6.249 +{
   6.250 +}
   6.251 +
   6.252 +void SDL_WinRTApp::Run()
   6.253 +{
   6.254 +    SDL_SetMainReady();
   6.255 +    if (SDL_WinRT_main)
   6.256 +    {
   6.257 +        // TODO, WinRT: pass the C-style main() a reasonably realistic
   6.258 +        // representation of command line arguments.
   6.259 +        int argc = 0;
   6.260 +        char **argv = NULL;
   6.261 +        SDL_WinRT_main(argc, argv);
   6.262 +    }
   6.263 +}
   6.264 +
   6.265 +void SDL_WinRTApp::PumpEvents()
   6.266 +{
   6.267 +    if (!m_windowClosed)
   6.268 +    {
   6.269 +        if (m_windowVisible)
   6.270 +        {
   6.271 +            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
   6.272 +        }
   6.273 +        else
   6.274 +        {
   6.275 +            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
   6.276 +        }
   6.277 +    }
   6.278 +}
   6.279 +
   6.280 +void SDL_WinRTApp::Uninitialize()
   6.281 +{
   6.282 +}
   6.283 +
   6.284 +void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
   6.285 +{
   6.286 +#if LOG_WINDOW_EVENTS==1
   6.287 +    SDL_Log("%s, size={%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, m_sdlWindowData?=%s\n",
   6.288 +        __FUNCTION__,
   6.289 +        args->Size.Width, args->Size.Height,
   6.290 +        (int)DisplayProperties::CurrentOrientation,
   6.291 +        (int)DisplayProperties::NativeOrientation,
   6.292 +        (int)DisplayProperties::AutoRotationPreferences,
   6.293 +        (m_sdlWindowData ? "yes" : "no"));
   6.294 +#endif
   6.295 +
   6.296 +    if (m_sdlWindowData) {
   6.297 +        // Make the new window size be the one true fullscreen mode.
   6.298 +        // This change was done, in part, to allow the Direct3D 11.1 renderer
   6.299 +        // to receive window-resize events as a device rotates.
   6.300 +        // Before, rotating a device from landscape, to portrait, and then
   6.301 +        // back to landscape would cause the Direct3D 11.1 swap buffer to
   6.302 +        // not get resized appropriately.  SDL would, on the rotation from
   6.303 +        // landscape to portrait, re-resize the SDL window to it's initial
   6.304 +        // size (landscape).  On the subsequent rotation, SDL would drop the
   6.305 +        // window-resize event as it appeared the SDL window didn't change
   6.306 +        // size, and the Direct3D 11.1 renderer wouldn't resize its swap
   6.307 +        // chain.
   6.308 +        //
   6.309 +        // TODO, WinRT: consider dropping old display modes after the fullscreen window changes size (from rotations, etc.)
   6.310 +        m_sdlWindowData->sdlWindow->fullscreen_mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
   6.311 +        SDL_AddDisplayMode(&m_sdlVideoDevice->displays[0], &m_sdlWindowData->sdlWindow->fullscreen_mode);
   6.312 +
   6.313 +        // HACK, Feb 19, 2013: SDL_WINDOWEVENT_RESIZED events, when sent,
   6.314 +        // will attempt to fix the values of the main window's renderer's
   6.315 +        // viewport.  While this can be good, it does appear to be buggy,
   6.316 +        // and can cause a fullscreen viewport to become corrupted.  This
   6.317 +        // behavior was noticed on a Surface RT while rotating the device
   6.318 +        // from landscape to portrait.  Oddly enough, this did not occur
   6.319 +        // in the Windows Simulator.
   6.320 +        //
   6.321 +        // Backing up, then restoring, the main renderer's 'resized' flag
   6.322 +        // seems to fix fullscreen viewport problems when rotating a
   6.323 +        // Windows device.
   6.324 +        //
   6.325 +        // Commencing hack in 3... 2... 1...
   6.326 +        //
   6.327 +        // UPDATE, SDL 2.0.0 update: the 'resized' flag is now gone.  This
   6.328 +        // hack might not be necessary any more.
   6.329 +        //
   6.330 +        //SDL_Renderer * rendererForMainWindow = SDL_GetRenderer(m_sdlWindowData->sdlWindow);
   6.331 +        // For now, limit the hack to when the Direct3D 11.1 is getting used:
   6.332 +        //const bool usingD3D11Renderer = \
   6.333 +        //    (rendererForMainWindow != NULL) &&
   6.334 +        //    (SDL_strcmp(rendererForMainWindow->info.name, "direct3d 11.1") == 0);
   6.335 +        //SDL_bool wasD3D11RendererResized = SDL_FALSE;
   6.336 +        //if (usingD3D11Renderer) {
   6.337 +        //    wasD3D11RendererResized = rendererForMainWindow->resized;
   6.338 +        //}
   6.339 +
   6.340 +        // Send the window-resize event to the rest of SDL, and to apps:
   6.341 +        const int windowWidth = (int) ceil(args->Size.Width);
   6.342 +        const int windowHeight = (int) ceil(args->Size.Height);
   6.343 +        SDL_SendWindowEvent(
   6.344 +            m_sdlWindowData->sdlWindow,
   6.345 +            SDL_WINDOWEVENT_RESIZED,
   6.346 +            windowWidth,
   6.347 +            windowHeight);
   6.348 +
   6.349 +        //// Viewport hack, part two:
   6.350 +        //if (usingD3D11Renderer) {
   6.351 +        //    rendererForMainWindow->resized = wasD3D11RendererResized;
   6.352 +        //}
   6.353 +    }
   6.354 +}
   6.355 +
   6.356 +void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
   6.357 +{
   6.358 +#if LOG_WINDOW_EVENTS==1
   6.359 +    SDL_Log("%s, visible?=%s, m_sdlWindowData?=%s\n",
   6.360 +        __FUNCTION__,
   6.361 +        (args->Visible ? "yes" : "no"),
   6.362 +        (m_sdlWindowData ? "yes" : "no"));
   6.363 +#endif
   6.364 +
   6.365 +    m_windowVisible = args->Visible;
   6.366 +    if (m_sdlWindowData) {
   6.367 +        SDL_bool wasSDLWindowSurfaceValid = m_sdlWindowData->sdlWindow->surface_valid;
   6.368 +
   6.369 +        if (args->Visible) {
   6.370 +            SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
   6.371 +        } else {
   6.372 +            SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
   6.373 +        }
   6.374 +
   6.375 +        // HACK: Prevent SDL's window-hide handling code, which currently
   6.376 +        // triggers a fake window resize (possibly erronously), from
   6.377 +        // marking the SDL window's surface as invalid.
   6.378 +        //
   6.379 +        // A better solution to this probably involves figuring out if the
   6.380 +        // fake window resize can be prevented.
   6.381 +        m_sdlWindowData->sdlWindow->surface_valid = wasSDLWindowSurfaceValid;
   6.382 +    }
   6.383 +}
   6.384 +
   6.385 +void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
   6.386 +{
   6.387 +#if LOG_WINDOW_EVENTS==1
   6.388 +    SDL_Log("%s\n", __FUNCTION__);
   6.389 +#endif
   6.390 +    m_windowClosed = true;
   6.391 +}
   6.392 +
   6.393 +static Uint8
   6.394 +WINRT_GetSDLButtonForPointerPoint(PointerPoint ^ pt)
   6.395 +{
   6.396 +    switch (pt->Properties->PointerUpdateKind)
   6.397 +    {
   6.398 +        case PointerUpdateKind::LeftButtonPressed:
   6.399 +        case PointerUpdateKind::LeftButtonReleased:
   6.400 +            return SDL_BUTTON_LEFT;
   6.401 +
   6.402 +        case PointerUpdateKind::RightButtonPressed:
   6.403 +        case PointerUpdateKind::RightButtonReleased:
   6.404 +            return SDL_BUTTON_RIGHT;
   6.405 +
   6.406 +        case PointerUpdateKind::MiddleButtonPressed:
   6.407 +        case PointerUpdateKind::MiddleButtonReleased:
   6.408 +            return SDL_BUTTON_MIDDLE;
   6.409 +
   6.410 +        case PointerUpdateKind::XButton1Pressed:
   6.411 +        case PointerUpdateKind::XButton1Released:
   6.412 +            return SDL_BUTTON_X1;
   6.413 +
   6.414 +        case PointerUpdateKind::XButton2Pressed:
   6.415 +        case PointerUpdateKind::XButton2Released:
   6.416 +            return SDL_BUTTON_X2;
   6.417 +
   6.418 +        default:
   6.419 +            break;
   6.420 +    }
   6.421 +
   6.422 +    return 0;
   6.423 +}
   6.424 +
   6.425 +static const char *
   6.426 +WINRT_ConvertPointerUpdateKindToString(PointerUpdateKind kind)
   6.427 +{
   6.428 +    switch (kind)
   6.429 +    {
   6.430 +        case PointerUpdateKind::Other:
   6.431 +            return "Other";
   6.432 +        case PointerUpdateKind::LeftButtonPressed:
   6.433 +            return "LeftButtonPressed";
   6.434 +        case PointerUpdateKind::LeftButtonReleased:
   6.435 +            return "LeftButtonReleased";
   6.436 +        case PointerUpdateKind::RightButtonPressed:
   6.437 +            return "RightButtonPressed";
   6.438 +        case PointerUpdateKind::RightButtonReleased:
   6.439 +            return "RightButtonReleased";
   6.440 +        case PointerUpdateKind::MiddleButtonPressed:
   6.441 +            return "MiddleButtonPressed";
   6.442 +        case PointerUpdateKind::MiddleButtonReleased:
   6.443 +            return "MiddleButtonReleased";
   6.444 +        case PointerUpdateKind::XButton1Pressed:
   6.445 +            return "XButton1Pressed";
   6.446 +        case PointerUpdateKind::XButton1Released:
   6.447 +            return "XButton1Released";
   6.448 +        case PointerUpdateKind::XButton2Pressed:
   6.449 +            return "XButton2Pressed";
   6.450 +        case PointerUpdateKind::XButton2Released:
   6.451 +            return "XButton2Released";
   6.452 +    }
   6.453 +
   6.454 +    return "";
   6.455 +}
   6.456 +
   6.457 +static void
   6.458 +WINRT_LogPointerEvent(const string & header, PointerEventArgs ^ args, Point transformedPoint)
   6.459 +{
   6.460 +    PointerPoint ^ pt = args->CurrentPoint;
   6.461 +    SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, PointerUpdateKind=%s\n",
   6.462 +        header.c_str(),
   6.463 +        pt->Position.X, pt->Position.Y,
   6.464 +        transformedPoint.X, transformedPoint.Y,
   6.465 +        pt->Properties->MouseWheelDelta,
   6.466 +        pt->FrameId,
   6.467 +        pt->PointerId,
   6.468 +        WINRT_ConvertPointerUpdateKindToString(args->CurrentPoint->Properties->PointerUpdateKind));
   6.469 +}
   6.470 +
   6.471 +void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
   6.472 +{
   6.473 +#if LOG_POINTER_EVENTS
   6.474 +    WINRT_LogPointerEvent("mouse down", args, TransformCursor(args->CurrentPoint->Position));
   6.475 +#endif
   6.476 +
   6.477 +    if (m_sdlWindowData) {
   6.478 +        Uint8 button = WINRT_GetSDLButtonForPointerPoint(args->CurrentPoint);
   6.479 +        if (button) {
   6.480 +            SDL_SendMouseButton(m_sdlWindowData->sdlWindow, 0, SDL_PRESSED, button);
   6.481 +        }
   6.482 +    }
   6.483 +}
   6.484 +
   6.485 +void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
   6.486 +{
   6.487 +#if LOG_POINTER_EVENTS
   6.488 +    WINRT_LogPointerEvent("mouse up", args, TransformCursor(args->CurrentPoint->Position));
   6.489 +#endif
   6.490 +
   6.491 +    if (m_sdlWindowData) {
   6.492 +        Uint8 button = WINRT_GetSDLButtonForPointerPoint(args->CurrentPoint);
   6.493 +        if (button) {
   6.494 +            SDL_SendMouseButton(m_sdlWindowData->sdlWindow, 0, SDL_RELEASED, button);
   6.495 +        }
   6.496 +    }
   6.497 +}
   6.498 +
   6.499 +void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
   6.500 +{
   6.501 +#if LOG_POINTER_EVENTS
   6.502 +    WINRT_LogPointerEvent("wheel changed", args, TransformCursor(args->CurrentPoint->Position));
   6.503 +#endif
   6.504 +
   6.505 +    if (m_sdlWindowData) {
   6.506 +        // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
   6.507 +        short motion = args->CurrentPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
   6.508 +        SDL_SendMouseWheel(m_sdlWindowData->sdlWindow, 0, 0, motion);
   6.509 +    }
   6.510 +}
   6.511 +
   6.512 +static inline int _lround(float arg) {
   6.513 +    if (arg >= 0.0f) {
   6.514 +        return (int)floor(arg + 0.5f);
   6.515 +    } else {
   6.516 +        return (int)ceil(arg - 0.5f);
   6.517 +    }
   6.518 +}
   6.519 +
   6.520 +void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
   6.521 +{
   6.522 +    if (m_sdlWindowData && m_useRelativeMouseMode) {
   6.523 +        // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows
   6.524 +        // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs'
   6.525 +        // MouseDelta field often reports very large values.  More information
   6.526 +        // on this can be found at the following pages on MSDN:
   6.527 +        //  - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8
   6.528 +        //  - https://connect.microsoft.com/VisualStudio/Feedback/details/756515
   6.529 +        //
   6.530 +        // The values do not appear to be as large when running on some systems,
   6.531 +        // most notably a Surface RT.  Furthermore, the values returned by
   6.532 +        // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved
   6.533 +        // method, do not ever appear to be large, even when MouseEventArgs'
   6.534 +        // MouseDelta is reporting to the contrary.
   6.535 +        //
   6.536 +        // On systems with the large-values behavior, it appears that the values
   6.537 +        // get reported as if the screen's size is 65536 units in both the X and Y
   6.538 +        // dimensions.  This can be viewed by using Windows' now-private, "Raw Input"
   6.539 +        // APIs.  (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.)
   6.540 +        //
   6.541 +        // MSDN's documentation on MouseEventArgs' MouseDelta field (at
   6.542 +        // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
   6.543 +        // does not seem to indicate (to me) that its values should be so large.  It
   6.544 +        // says that its values should be a "change in screen location".  I could
   6.545 +        // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see: 
   6.546 +        // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
   6.547 +        // indicates that these values are in DIPs, which is the same unit used
   6.548 +        // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
   6.549 +        // property.  See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx
   6.550 +        // for details.)
   6.551 +        //
   6.552 +        // To note, PointerMoved events are sent a 'RawPosition' value (via the
   6.553 +        // CurrentPoint property in MouseEventArgs), however these do not seem
   6.554 +        // to exhibit the same large-value behavior.
   6.555 +        //
   6.556 +        // The values passed via PointerMoved events can't always be used for relative
   6.557 +        // mouse motion, unfortunately.  Its values are bound to the cursor's position,
   6.558 +        // which stops when it hits one of the screen's edges.  This can be a problem in
   6.559 +        // first person shooters, whereby it is normal for mouse motion to travel far
   6.560 +        // along any one axis for a period of time.  MouseMoved events do not have the
   6.561 +        // screen-bounding limitation, and can be used regardless of where the system's
   6.562 +        // cursor is.
   6.563 +        //
   6.564 +        // One possible workaround would be to programmatically set the cursor's
   6.565 +        // position to the screen's center (when SDL's relative mouse mode is enabled),
   6.566 +        // however Windows RT does not yet seem to have the ability to set the cursor's
   6.567 +        // position via a public API.  Win32 did this via an API call, SetCursorPos,
   6.568 +        // however WinRT makes this function be private.  Apps that use it won't get
   6.569 +        // approved for distribution in the Windows Store.  I've yet to be able to find
   6.570 +        // a suitable, store-friendly counterpart for WinRT.
   6.571 +        //
   6.572 +        // There may be some room for a workaround whereby OnPointerMoved's values
   6.573 +        // are compared to the values from OnMouseMoved in order to detect
   6.574 +        // when this bug is active.  A suitable transformation could then be made to
   6.575 +        // OnMouseMoved's values.  For now, however, the system-reported values are sent
   6.576 +        // to SDL with minimal transformation: from native screen coordinates (in DIPs)
   6.577 +        // to SDL window coordinates.
   6.578 +        //
   6.579 +        const Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
   6.580 +        const Point mouseDeltaInSDLWindowCoords = TransformCursor(mouseDeltaInDIPs);
   6.581 +        SDL_SendMouseMotion(
   6.582 +            m_sdlWindowData->sdlWindow,
   6.583 +            0,
   6.584 +            1,
   6.585 +            _lround(mouseDeltaInSDLWindowCoords.X),
   6.586 +            _lround(mouseDeltaInSDLWindowCoords.Y));
   6.587 +    }
   6.588 +}
   6.589 +
   6.590 +// Applies necessary geometric transformations to raw cursor positions:
   6.591 +Point SDL_WinRTApp::TransformCursor(Point rawPosition)
   6.592 +{
   6.593 +    if ( ! m_sdlWindowData || ! m_sdlWindowData->sdlWindow ) {
   6.594 +        return rawPosition;
   6.595 +    }
   6.596 +    CoreWindow ^ nativeWindow = CoreWindow::GetForCurrentThread();
   6.597 +    Point outputPosition;
   6.598 +    outputPosition.X = rawPosition.X * (((float32)m_sdlWindowData->sdlWindow->w) / nativeWindow->Bounds.Width);
   6.599 +    outputPosition.Y = rawPosition.Y * (((float32)m_sdlWindowData->sdlWindow->h) / nativeWindow->Bounds.Height);
   6.600 +    return outputPosition;
   6.601 +}
   6.602 +
   6.603 +void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
   6.604 +{
   6.605 +#if LOG_POINTER_EVENTS
   6.606 +    WINRT_LogPointerEvent("pointer moved", args, TransformCursor(args->CurrentPoint->Position));
   6.607 +#endif
   6.608 +
   6.609 +    if (m_sdlWindowData && ! m_useRelativeMouseMode)
   6.610 +    {
   6.611 +        Point transformedPoint = TransformCursor(args->CurrentPoint->Position);
   6.612 +        SDL_SendMouseMotion(m_sdlWindowData->sdlWindow, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
   6.613 +    }
   6.614 +}
   6.615 +
   6.616 +static SDL_Scancode WinRT_Official_Keycodes[] = {
   6.617 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.None -- 0
   6.618 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftButton -- 1
   6.619 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.RightButton -- 2
   6.620 +    SDL_SCANCODE_CANCEL, // VirtualKey.Cancel -- 3
   6.621 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.MiddleButton -- 4
   6.622 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton1 -- 5
   6.623 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton2 -- 6
   6.624 +    SDL_SCANCODE_UNKNOWN, // -- 7
   6.625 +    SDL_SCANCODE_BACKSPACE, // VirtualKey.Back -- 8
   6.626 +    SDL_SCANCODE_TAB, // VirtualKey.Tab -- 9
   6.627 +    SDL_SCANCODE_UNKNOWN, // -- 10
   6.628 +    SDL_SCANCODE_UNKNOWN, // -- 11
   6.629 +    SDL_SCANCODE_CLEAR, // VirtualKey.Clear -- 12
   6.630 +    SDL_SCANCODE_RETURN, // VirtualKey.Enter -- 13
   6.631 +    SDL_SCANCODE_UNKNOWN, // -- 14
   6.632 +    SDL_SCANCODE_UNKNOWN, // -- 15
   6.633 +    SDL_SCANCODE_LSHIFT, // VirtualKey.Shift -- 16
   6.634 +    SDL_SCANCODE_LCTRL, // VirtualKey.Control -- 17
   6.635 +    SDL_SCANCODE_MENU, // VirtualKey.Menu -- 18
   6.636 +    SDL_SCANCODE_PAUSE, // VirtualKey.Pause -- 19
   6.637 +    SDL_SCANCODE_CAPSLOCK, // VirtualKey.CapitalLock -- 20
   6.638 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.Kana or VirtualKey.Hangul -- 21
   6.639 +    SDL_SCANCODE_UNKNOWN, // -- 22
   6.640 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.Junja -- 23
   6.641 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.Final -- 24
   6.642 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.Hanja or VirtualKey.Kanji -- 25
   6.643 +    SDL_SCANCODE_UNKNOWN, // -- 26
   6.644 +    SDL_SCANCODE_ESCAPE, // VirtualKey.Escape -- 27
   6.645 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.Convert -- 28
   6.646 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.NonConvert -- 29
   6.647 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.Accept -- 30
   6.648 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.ModeChange -- 31  (maybe SDL_SCANCODE_MODE ?)
   6.649 +    SDL_SCANCODE_SPACE, // VirtualKey.Space -- 32
   6.650 +    SDL_SCANCODE_PAGEUP, // VirtualKey.PageUp -- 33
   6.651 +    SDL_SCANCODE_PAGEDOWN, // VirtualKey.PageDown -- 34
   6.652 +    SDL_SCANCODE_END, // VirtualKey.End -- 35
   6.653 +    SDL_SCANCODE_HOME, // VirtualKey.Home -- 36
   6.654 +    SDL_SCANCODE_LEFT, // VirtualKey.Left -- 37
   6.655 +    SDL_SCANCODE_UP, // VirtualKey.Up -- 38
   6.656 +    SDL_SCANCODE_RIGHT, // VirtualKey.Right -- 39
   6.657 +    SDL_SCANCODE_DOWN, // VirtualKey.Down -- 40
   6.658 +    SDL_SCANCODE_SELECT, // VirtualKey.Select -- 41
   6.659 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.Print -- 42  (maybe SDL_SCANCODE_PRINTSCREEN ?)
   6.660 +    SDL_SCANCODE_EXECUTE, // VirtualKey.Execute -- 43
   6.661 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.Snapshot -- 44
   6.662 +    SDL_SCANCODE_INSERT, // VirtualKey.Insert -- 45
   6.663 +    SDL_SCANCODE_DELETE, // VirtualKey.Delete -- 46
   6.664 +    SDL_SCANCODE_HELP, // VirtualKey.Help -- 47
   6.665 +    SDL_SCANCODE_0, // VirtualKey.Number0 -- 48
   6.666 +    SDL_SCANCODE_1, // VirtualKey.Number1 -- 49
   6.667 +    SDL_SCANCODE_2, // VirtualKey.Number2 -- 50
   6.668 +    SDL_SCANCODE_3, // VirtualKey.Number3 -- 51
   6.669 +    SDL_SCANCODE_4, // VirtualKey.Number4 -- 52
   6.670 +    SDL_SCANCODE_5, // VirtualKey.Number5 -- 53
   6.671 +    SDL_SCANCODE_6, // VirtualKey.Number6 -- 54
   6.672 +    SDL_SCANCODE_7, // VirtualKey.Number7 -- 55
   6.673 +    SDL_SCANCODE_8, // VirtualKey.Number8 -- 56
   6.674 +    SDL_SCANCODE_9, // VirtualKey.Number9 -- 57
   6.675 +    SDL_SCANCODE_UNKNOWN, // -- 58
   6.676 +    SDL_SCANCODE_UNKNOWN, // -- 59
   6.677 +    SDL_SCANCODE_UNKNOWN, // -- 60
   6.678 +    SDL_SCANCODE_UNKNOWN, // -- 61
   6.679 +    SDL_SCANCODE_UNKNOWN, // -- 62
   6.680 +    SDL_SCANCODE_UNKNOWN, // -- 63
   6.681 +    SDL_SCANCODE_UNKNOWN, // -- 64
   6.682 +    SDL_SCANCODE_A, // VirtualKey.A -- 65
   6.683 +    SDL_SCANCODE_B, // VirtualKey.B -- 66
   6.684 +    SDL_SCANCODE_C, // VirtualKey.C -- 67
   6.685 +    SDL_SCANCODE_D, // VirtualKey.D -- 68
   6.686 +    SDL_SCANCODE_E, // VirtualKey.E -- 69
   6.687 +    SDL_SCANCODE_F, // VirtualKey.F -- 70
   6.688 +    SDL_SCANCODE_G, // VirtualKey.G -- 71
   6.689 +    SDL_SCANCODE_H, // VirtualKey.H -- 72
   6.690 +    SDL_SCANCODE_I, // VirtualKey.I -- 73
   6.691 +    SDL_SCANCODE_J, // VirtualKey.J -- 74
   6.692 +    SDL_SCANCODE_K, // VirtualKey.K -- 75
   6.693 +    SDL_SCANCODE_L, // VirtualKey.L -- 76
   6.694 +    SDL_SCANCODE_M, // VirtualKey.M -- 77
   6.695 +    SDL_SCANCODE_N, // VirtualKey.N -- 78
   6.696 +    SDL_SCANCODE_O, // VirtualKey.O -- 79
   6.697 +    SDL_SCANCODE_P, // VirtualKey.P -- 80
   6.698 +    SDL_SCANCODE_Q, // VirtualKey.Q -- 81
   6.699 +    SDL_SCANCODE_R, // VirtualKey.R -- 82
   6.700 +    SDL_SCANCODE_S, // VirtualKey.S -- 83
   6.701 +    SDL_SCANCODE_T, // VirtualKey.T -- 84
   6.702 +    SDL_SCANCODE_U, // VirtualKey.U -- 85
   6.703 +    SDL_SCANCODE_V, // VirtualKey.V -- 86
   6.704 +    SDL_SCANCODE_W, // VirtualKey.W -- 87
   6.705 +    SDL_SCANCODE_X, // VirtualKey.X -- 88
   6.706 +    SDL_SCANCODE_Y, // VirtualKey.Y -- 89
   6.707 +    SDL_SCANCODE_Z, // VirtualKey.Z -- 90
   6.708 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftWindows -- 91  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?)
   6.709 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.RightWindows -- 92  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?)
   6.710 +    SDL_SCANCODE_APPLICATION, // VirtualKey.Application -- 93
   6.711 +    SDL_SCANCODE_UNKNOWN, // -- 94
   6.712 +    SDL_SCANCODE_SLEEP, // VirtualKey.Sleep -- 95
   6.713 +    SDL_SCANCODE_KP_0, // VirtualKey.NumberPad0 -- 96
   6.714 +    SDL_SCANCODE_KP_1, // VirtualKey.NumberPad1 -- 97
   6.715 +    SDL_SCANCODE_KP_2, // VirtualKey.NumberPad2 -- 98
   6.716 +    SDL_SCANCODE_KP_3, // VirtualKey.NumberPad3 -- 99
   6.717 +    SDL_SCANCODE_KP_4, // VirtualKey.NumberPad4 -- 100
   6.718 +    SDL_SCANCODE_KP_5, // VirtualKey.NumberPad5 -- 101
   6.719 +    SDL_SCANCODE_KP_6, // VirtualKey.NumberPad6 -- 102
   6.720 +    SDL_SCANCODE_KP_7, // VirtualKey.NumberPad7 -- 103
   6.721 +    SDL_SCANCODE_KP_8, // VirtualKey.NumberPad8 -- 104
   6.722 +    SDL_SCANCODE_KP_9, // VirtualKey.NumberPad9 -- 105
   6.723 +    SDL_SCANCODE_KP_MULTIPLY, // VirtualKey.Multiply -- 106
   6.724 +    SDL_SCANCODE_KP_PLUS, // VirtualKey.Add -- 107
   6.725 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.Separator -- 108
   6.726 +    SDL_SCANCODE_KP_MINUS, // VirtualKey.Subtract -- 109
   6.727 +    SDL_SCANCODE_UNKNOWN, // VirtualKey.Decimal -- 110  (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?)
   6.728 +    SDL_SCANCODE_KP_DIVIDE, // VirtualKey.Divide -- 111
   6.729 +    SDL_SCANCODE_F1, // VirtualKey.F1 -- 112
   6.730 +    SDL_SCANCODE_F2, // VirtualKey.F2 -- 113
   6.731 +    SDL_SCANCODE_F3, // VirtualKey.F3 -- 114
   6.732 +    SDL_SCANCODE_F4, // VirtualKey.F4 -- 115
   6.733 +    SDL_SCANCODE_F5, // VirtualKey.F5 -- 116
   6.734 +    SDL_SCANCODE_F6, // VirtualKey.F6 -- 117
   6.735 +    SDL_SCANCODE_F7, // VirtualKey.F7 -- 118
   6.736 +    SDL_SCANCODE_F8, // VirtualKey.F8 -- 119
   6.737 +    SDL_SCANCODE_F9, // VirtualKey.F9 -- 120
   6.738 +    SDL_SCANCODE_F10, // VirtualKey.F10 -- 121
   6.739 +    SDL_SCANCODE_F11, // VirtualKey.F11 -- 122
   6.740 +    SDL_SCANCODE_F12, // VirtualKey.F12 -- 123
   6.741 +    SDL_SCANCODE_F13, // VirtualKey.F13 -- 124
   6.742 +    SDL_SCANCODE_F14, // VirtualKey.F14 -- 125
   6.743 +    SDL_SCANCODE_F15, // VirtualKey.F15 -- 126
   6.744 +    SDL_SCANCODE_F16, // VirtualKey.F16 -- 127
   6.745 +    SDL_SCANCODE_F17, // VirtualKey.F17 -- 128
   6.746 +    SDL_SCANCODE_F18, // VirtualKey.F18 -- 129
   6.747 +    SDL_SCANCODE_F19, // VirtualKey.F19 -- 130
   6.748 +    SDL_SCANCODE_F20, // VirtualKey.F20 -- 131
   6.749 +    SDL_SCANCODE_F21, // VirtualKey.F21 -- 132
   6.750 +    SDL_SCANCODE_F22, // VirtualKey.F22 -- 133
   6.751 +    SDL_SCANCODE_F23, // VirtualKey.F23 -- 134
   6.752 +    SDL_SCANCODE_F24, // VirtualKey.F24 -- 135
   6.753 +    SDL_SCANCODE_UNKNOWN, // -- 136
   6.754 +    SDL_SCANCODE_UNKNOWN, // -- 137
   6.755 +    SDL_SCANCODE_UNKNOWN, // -- 138
   6.756 +    SDL_SCANCODE_UNKNOWN, // -- 139
   6.757 +    SDL_SCANCODE_UNKNOWN, // -- 140
   6.758 +    SDL_SCANCODE_UNKNOWN, // -- 141
   6.759 +    SDL_SCANCODE_UNKNOWN, // -- 142
   6.760 +    SDL_SCANCODE_UNKNOWN, // -- 143
   6.761 +    SDL_SCANCODE_NUMLOCKCLEAR, // VirtualKey.NumberKeyLock -- 144
   6.762 +    SDL_SCANCODE_SCROLLLOCK, // VirtualKey.Scroll -- 145
   6.763 +    SDL_SCANCODE_UNKNOWN, // -- 146
   6.764 +    SDL_SCANCODE_UNKNOWN, // -- 147
   6.765 +    SDL_SCANCODE_UNKNOWN, // -- 148
   6.766 +    SDL_SCANCODE_UNKNOWN, // -- 149
   6.767 +    SDL_SCANCODE_UNKNOWN, // -- 150
   6.768 +    SDL_SCANCODE_UNKNOWN, // -- 151
   6.769 +    SDL_SCANCODE_UNKNOWN, // -- 152
   6.770 +    SDL_SCANCODE_UNKNOWN, // -- 153
   6.771 +    SDL_SCANCODE_UNKNOWN, // -- 154
   6.772 +    SDL_SCANCODE_UNKNOWN, // -- 155
   6.773 +    SDL_SCANCODE_UNKNOWN, // -- 156
   6.774 +    SDL_SCANCODE_UNKNOWN, // -- 157
   6.775 +    SDL_SCANCODE_UNKNOWN, // -- 158
   6.776 +    SDL_SCANCODE_UNKNOWN, // -- 159
   6.777 +    SDL_SCANCODE_LSHIFT, // VirtualKey.LeftShift -- 160
   6.778 +    SDL_SCANCODE_RSHIFT, // VirtualKey.RightShift -- 161
   6.779 +    SDL_SCANCODE_LCTRL, // VirtualKey.LeftControl -- 162
   6.780 +    SDL_SCANCODE_RCTRL, // VirtualKey.RightControl -- 163
   6.781 +    SDL_SCANCODE_MENU, // VirtualKey.LeftMenu -- 164
   6.782 +    SDL_SCANCODE_MENU, // VirtualKey.RightMenu -- 165
   6.783 +};
   6.784 +
   6.785 +static std::unordered_map<int, SDL_Scancode> WinRT_Unofficial_Keycodes;
   6.786 +
   6.787 +static SDL_Scancode
   6.788 +TranslateKeycode(int keycode)
   6.789 +{
   6.790 +    if (WinRT_Unofficial_Keycodes.empty()) {
   6.791 +        /* Set up a table of undocumented (by Microsoft), WinRT-specific,
   6.792 +           key codes: */
   6.793 +        // TODO, WinRT: move content declarations of WinRT_Unofficial_Keycodes into a C++11 initializer list, when possible
   6.794 +        WinRT_Unofficial_Keycodes[220] = SDL_SCANCODE_GRAVE;
   6.795 +        WinRT_Unofficial_Keycodes[222] = SDL_SCANCODE_BACKSLASH;
   6.796 +    }
   6.797 +
   6.798 +    /* Try to get a documented, WinRT, 'VirtualKey' first (as documented at
   6.799 +       http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.virtualkey.aspx ).
   6.800 +       If that fails, fall back to a Win32 virtual key.
   6.801 +    */
   6.802 +    // TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints
   6.803 +    //SDL_Log("WinRT TranslateKeycode, keycode=%d\n", (int)keycode);
   6.804 +    SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
   6.805 +    if (keycode < SDL_arraysize(WinRT_Official_Keycodes)) {
   6.806 +        scancode = WinRT_Official_Keycodes[keycode];
   6.807 +    }
   6.808 +    if (scancode == SDL_SCANCODE_UNKNOWN) {
   6.809 +        if (WinRT_Unofficial_Keycodes.find(keycode) != WinRT_Unofficial_Keycodes.end()) {
   6.810 +            scancode = WinRT_Unofficial_Keycodes[keycode];
   6.811 +        }
   6.812 +    }
   6.813 +    if (scancode == SDL_SCANCODE_UNKNOWN) {
   6.814 +        if (keycode < SDL_arraysize(windows_scancode_table)) {
   6.815 +            scancode = windows_scancode_table[keycode];
   6.816 +        }
   6.817 +    }
   6.818 +    if (scancode == SDL_SCANCODE_UNKNOWN) {
   6.819 +        SDL_Log("WinRT TranslateKeycode, unknown keycode=%d\n", (int)keycode);
   6.820 +    }
   6.821 +    return scancode;
   6.822 +}
   6.823 +
   6.824 +void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
   6.825 +{
   6.826 +    SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
   6.827 +#if 0
   6.828 +    SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
   6.829 +    SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n",
   6.830 +        (args->Handled ? "1" : "0"),
   6.831 +        (args->KeyStatus.IsExtendedKey ? "1" : "0"),
   6.832 +        (args->KeyStatus.IsKeyReleased ? "1" : "0"),
   6.833 +        (args->KeyStatus.IsMenuKeyDown ? "1" : "0"),
   6.834 +        args->KeyStatus.RepeatCount,
   6.835 +        args->KeyStatus.ScanCode,
   6.836 +        (args->KeyStatus.WasKeyDown ? "1" : "0"),
   6.837 +        args->VirtualKey,
   6.838 +        sdlScancode,
   6.839 +        SDL_GetScancodeName(sdlScancode),
   6.840 +        keycode,
   6.841 +        SDL_GetKeyName(keycode));
   6.842 +    //args->Handled = true;
   6.843 +    //VirtualKey vkey = args->VirtualKey;
   6.844 +#endif
   6.845 +    SDL_SendKeyboardKey(SDL_PRESSED, sdlScancode);
   6.846 +}
   6.847 +
   6.848 +void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
   6.849 +{
   6.850 +    SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
   6.851 +#if 0
   6.852 +    SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
   6.853 +    SDL_Log("key up, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n",
   6.854 +        (args->Handled ? "1" : "0"),
   6.855 +        (args->KeyStatus.IsExtendedKey ? "1" : "0"),
   6.856 +        (args->KeyStatus.IsKeyReleased ? "1" : "0"),
   6.857 +        (args->KeyStatus.IsMenuKeyDown ? "1" : "0"),
   6.858 +        args->KeyStatus.RepeatCount,
   6.859 +        args->KeyStatus.ScanCode,
   6.860 +        (args->KeyStatus.WasKeyDown ? "1" : "0"),
   6.861 +        args->VirtualKey,
   6.862 +        sdlScancode,
   6.863 +        SDL_GetScancodeName(sdlScancode),
   6.864 +        keycode,
   6.865 +        SDL_GetKeyName(keycode));
   6.866 +    //args->Handled = true;
   6.867 +#endif
   6.868 +    SDL_SendKeyboardKey(SDL_RELEASED, sdlScancode);
   6.869 +}
   6.870 +
   6.871 +void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
   6.872 +{
   6.873 +    CoreWindow::GetForCurrentThread()->Activate();
   6.874 +}
   6.875 +
   6.876 +static int SDLCALL RemoveAppSuspendAndResumeEvents(void * userdata, SDL_Event * event)
   6.877 +{
   6.878 +    if (event->type == SDL_WINDOWEVENT)
   6.879 +    {
   6.880 +        switch (event->window.event)
   6.881 +        {
   6.882 +            case SDL_WINDOWEVENT_MINIMIZED:
   6.883 +            case SDL_WINDOWEVENT_RESTORED:
   6.884 +                // Return 0 to indicate that the event should be removed from the
   6.885 +                // event queue:
   6.886 +                return 0;
   6.887 +            default:
   6.888 +                break;
   6.889 +        }
   6.890 +    }
   6.891 +
   6.892 +    // Return 1 to indicate that the event should stay in the event queue:
   6.893 +    return 1;
   6.894 +}
   6.895 +
   6.896 +void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
   6.897 +{
   6.898 +    // Save app state asynchronously after requesting a deferral. Holding a deferral
   6.899 +    // indicates that the application is busy performing suspending operations. Be
   6.900 +    // aware that a deferral may not be held indefinitely. After about five seconds,
   6.901 +    // the app will be forced to exit.
   6.902 +    SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
   6.903 +    create_task([this, deferral]()
   6.904 +    {
   6.905 +        // Send a window-minimized event immediately to observers.
   6.906 +        // CoreDispatcher::ProcessEvents, which is the backbone on which
   6.907 +        // SDL_WinRTApp::PumpEvents is built, will not return to its caller
   6.908 +        // once it sends out a suspend event.  Any events posted to SDL's
   6.909 +        // event queue won't get received until the WinRT app is resumed.
   6.910 +        // SDL_AddEventWatch() may be used to receive app-suspend events on
   6.911 +        // WinRT.
   6.912 +        //
   6.913 +        // In order to prevent app-suspend events from being received twice:
   6.914 +        // first via a callback passed to SDL_AddEventWatch, and second via
   6.915 +        // SDL's event queue, the event will be sent to SDL, then immediately
   6.916 +        // removed from the queue.
   6.917 +        if (m_sdlWindowData)
   6.918 +        {
   6.919 +            SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);   // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
   6.920 +            SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
   6.921 +        }
   6.922 +        deferral->Complete();
   6.923 +    });
   6.924 +}
   6.925 +
   6.926 +void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
   6.927 +{
   6.928 +    // Restore any data or state that was unloaded on suspend. By default, data
   6.929 +    // and state are persisted when resuming from suspend. Note that this event
   6.930 +    // does not occur if the app was previously terminated.
   6.931 +    if (m_sdlWindowData)
   6.932 +    {
   6.933 +        SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_RESTORED, 0, 0);    // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
   6.934 +
   6.935 +        // Remove the app-resume event from the queue, as is done with the
   6.936 +        // app-suspend event.
   6.937 +        //
   6.938 +        // TODO, WinRT: consider posting this event to the queue even though
   6.939 +        // its counterpart, the app-suspend event, effectively has to be
   6.940 +        // processed immediately.
   6.941 +        SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
   6.942 +    }
   6.943 +}
   6.944 +
   6.945 +SDL_DisplayMode SDL_WinRTApp::GetMainDisplayMode()
   6.946 +{
   6.947 +    // Create an empty, zeroed-out display mode:
   6.948 +    SDL_DisplayMode mode;
   6.949 +    SDL_zero(mode);
   6.950 +
   6.951 +    // Fill in most fields:
   6.952 +    mode.format = SDL_PIXELFORMAT_RGB888;
   6.953 +    mode.refresh_rate = 0;  // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
   6.954 +    mode.driverdata = NULL;
   6.955 +
   6.956 +    // Calculate the display size given the window size, taking into account
   6.957 +    // the current display's DPI:
   6.958 +    const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi; 
   6.959 +    const float dipsPerInch = 96.0f;
   6.960 +    mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
   6.961 +    mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
   6.962 +
   6.963 +    return mode;
   6.964 +}
   6.965 +
   6.966 +const SDL_WindowData * SDL_WinRTApp::GetSDLWindowData() const
   6.967 +{
   6.968 +    return m_sdlWindowData;
   6.969 +}
   6.970 +
   6.971 +bool SDL_WinRTApp::HasSDLWindowData() const
   6.972 +{
   6.973 +    return (m_sdlWindowData != NULL);
   6.974 +}
   6.975 +
   6.976 +void SDL_WinRTApp::SetRelativeMouseMode(bool enable)
   6.977 +{
   6.978 +    m_useRelativeMouseMode = enable;
   6.979 +}
   6.980 +
   6.981 +void SDL_WinRTApp::SetSDLWindowData(const SDL_WindowData * windowData)
   6.982 +{
   6.983 +    m_sdlWindowData = windowData;
   6.984 +}
   6.985 +
   6.986 +void SDL_WinRTApp::SetSDLVideoDevice(const SDL_VideoDevice * videoDevice)
   6.987 +{
   6.988 +    m_sdlVideoDevice = videoDevice;
   6.989 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/core/winrt/SDL_winrtapp.h	Tue Aug 20 21:22:32 2013 -0400
     7.3 @@ -0,0 +1,52 @@
     7.4 +#pragma once
     7.5 +
     7.6 +struct SDL_WindowData;
     7.7 +
     7.8 +ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
     7.9 +{
    7.10 +public:
    7.11 +    SDL_WinRTApp();
    7.12 +    
    7.13 +    // IFrameworkView Methods.
    7.14 +    virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
    7.15 +    virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
    7.16 +    virtual void Load(Platform::String^ entryPoint);
    7.17 +    virtual void Run();
    7.18 +    virtual void Uninitialize();
    7.19 +
    7.20 +internal:
    7.21 +    // SDL-specific methods
    7.22 +    SDL_DisplayMode GetMainDisplayMode();
    7.23 +    void PumpEvents();
    7.24 +    const SDL_WindowData * GetSDLWindowData() const;
    7.25 +    bool HasSDLWindowData() const;
    7.26 +    void SetRelativeMouseMode(bool enable);
    7.27 +    void SetSDLWindowData(const SDL_WindowData * windowData);
    7.28 +    void SetSDLVideoDevice(const SDL_VideoDevice * videoDevice);
    7.29 +    Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
    7.30 +
    7.31 +protected:
    7.32 +    // Event Handlers.
    7.33 +    void OnOrientationChanged(Platform::Object^ sender);
    7.34 +    void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
    7.35 +    void OnLogicalDpiChanged(Platform::Object^ sender);
    7.36 +    void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
    7.37 +    void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
    7.38 +    void OnResuming(Platform::Object^ sender, Platform::Object^ args);
    7.39 +    void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
    7.40 +    void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
    7.41 +    void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    7.42 +    void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    7.43 +    void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    7.44 +    void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
    7.45 +    void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args);
    7.46 +    void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
    7.47 +    void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
    7.48 +
    7.49 +private:
    7.50 +    bool m_windowClosed;
    7.51 +    bool m_windowVisible;
    7.52 +    const SDL_WindowData* m_sdlWindowData;
    7.53 +    const SDL_VideoDevice* m_sdlVideoDevice;
    7.54 +    bool m_useRelativeMouseMode;
    7.55 +};
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/core/winrt/SDL_winrtpaths.cpp	Tue Aug 20 21:22:32 2013 -0400
     8.3 @@ -0,0 +1,94 @@
     8.4 +/* TODO, WinRT: include copyright info in SDL_winrtpaths.cpp
     8.5 +   TODO, WinRT: add note to SDL_winrtpaths.cpp mentioning that /ZW must be used when compiling the file
     8.6 +*/
     8.7 +
     8.8 +#include "SDL_config.h"
     8.9 +
    8.10 +#ifdef __WINRT__
    8.11 +
    8.12 +extern "C" {
    8.13 +#include "SDL_error.h"
    8.14 +#include "SDL_stdinc.h"
    8.15 +#include "SDL_system.h"
    8.16 +#include "../windows/SDL_windows.h"
    8.17 +}
    8.18 +
    8.19 +#include <string>
    8.20 +#include <unordered_map>
    8.21 +
    8.22 +using namespace std;
    8.23 +using namespace Windows::Storage;
    8.24 +
    8.25 +extern "C" const wchar_t *
    8.26 +SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
    8.27 +{
    8.28 +    switch (pathType) {
    8.29 +        case SDL_WINRT_PATH_INSTALLED_LOCATION:
    8.30 +        {
    8.31 +            static wstring path;
    8.32 +            if (path.empty()) {
    8.33 +                path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
    8.34 +            }
    8.35 +            return path.c_str();
    8.36 +        }
    8.37 +
    8.38 +        case SDL_WINRT_PATH_LOCAL_FOLDER:
    8.39 +        {
    8.40 +            static wstring path;
    8.41 +            if (path.empty()) {
    8.42 +                path = ApplicationData::Current->LocalFolder->Path->Data();
    8.43 +            }
    8.44 +            return path.c_str();
    8.45 +        }
    8.46 +
    8.47 +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
    8.48 +        case SDL_WINRT_PATH_ROAMING_FOLDER:
    8.49 +        {
    8.50 +            static wstring path;
    8.51 +            if (path.empty()) {
    8.52 +                path = ApplicationData::Current->RoamingFolder->Path->Data();
    8.53 +            }
    8.54 +            return path.c_str();
    8.55 +        }
    8.56 +
    8.57 +        case SDL_WINRT_PATH_TEMP_FOLDER:
    8.58 +        {
    8.59 +            static wstring path;
    8.60 +            if (path.empty()) {
    8.61 +                path = ApplicationData::Current->TemporaryFolder->Path->Data();
    8.62 +            }
    8.63 +            return path.c_str();
    8.64 +        }
    8.65 +#endif
    8.66 +
    8.67 +        default:
    8.68 +            break;
    8.69 +    }
    8.70 +
    8.71 +    SDL_Unsupported();
    8.72 +    return NULL;
    8.73 +}
    8.74 +
    8.75 +extern "C" const char *
    8.76 +SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
    8.77 +{
    8.78 +    typedef unordered_map<SDL_WinRT_Path, string> UTF8PathMap;
    8.79 +    static UTF8PathMap utf8Paths;
    8.80 +
    8.81 +    UTF8PathMap::iterator searchResult = utf8Paths.find(pathType);
    8.82 +    if (searchResult != utf8Paths.end()) {
    8.83 +        return searchResult->second.c_str();
    8.84 +    }
    8.85 +
    8.86 +    const wchar_t * ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
    8.87 +    if (!ucs2Path) {
    8.88 +        return NULL;
    8.89 +    }
    8.90 +
    8.91 +    char * utf8Path = WIN_StringToUTF8(ucs2Path);
    8.92 +    utf8Paths[pathType] = utf8Path;
    8.93 +    SDL_free(utf8Path);
    8.94 +    return utf8Paths[pathType].c_str();
    8.95 +}
    8.96 +
    8.97 +#endif /* __WINRT__ */
     9.1 --- a/src/video/windowsrt/SDL_WinRTApp.cpp	Tue Aug 13 20:33:15 2013 -0400
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,986 +0,0 @@
     9.4 -
     9.5 -#include <string>
     9.6 -#include <unordered_map>
     9.7 -#include <sstream>
     9.8 -
     9.9 -#include "ppltasks.h"
    9.10 -
    9.11 -extern "C" {
    9.12 -#include "SDL_assert.h"
    9.13 -#include "SDL_events.h"
    9.14 -#include "SDL_hints.h"
    9.15 -#include "SDL_log.h"
    9.16 -#include "SDL_main.h"
    9.17 -#include "SDL_stdinc.h"
    9.18 -#include "SDL_render.h"
    9.19 -#include "../SDL_sysvideo.h"
    9.20 -//#include "../../SDL_hints_c.h"
    9.21 -#include "../../events/scancodes_windows.h"
    9.22 -#include "../../events/SDL_mouse_c.h"
    9.23 -#include "../../events/SDL_keyboard_c.h"
    9.24 -#include "../../events/SDL_windowevents_c.h"
    9.25 -#include "../../render/SDL_sysrender.h"
    9.26 -}
    9.27 -
    9.28 -#include "SDL_winrtvideo.h"
    9.29 -#include "SDL_WinRTApp.h"
    9.30 -
    9.31 -using namespace concurrency;
    9.32 -using namespace std;
    9.33 -using namespace Windows::ApplicationModel;
    9.34 -using namespace Windows::ApplicationModel::Core;
    9.35 -using namespace Windows::ApplicationModel::Activation;
    9.36 -using namespace Windows::Devices::Input;
    9.37 -using namespace Windows::Graphics::Display;
    9.38 -using namespace Windows::Foundation;
    9.39 -using namespace Windows::System;
    9.40 -using namespace Windows::UI::Core;
    9.41 -using namespace Windows::UI::Input;
    9.42 -
    9.43 -// Compile-time debugging options:
    9.44 -// To enable, uncomment; to disable, comment them out.
    9.45 -//#define LOG_POINTER_EVENTS 1
    9.46 -//#define LOG_WINDOW_EVENTS 1
    9.47 -//#define LOG_ORIENTATION_EVENTS 1
    9.48 -
    9.49 -
    9.50 -// HACK, DLudwig: The C-style main() will get loaded via the app's
    9.51 -// WinRT-styled main(), which is part of SDLmain_for_WinRT.cpp.
    9.52 -// This seems wrong on some level, but does seem to work.
    9.53 -typedef int (*SDL_WinRT_MainFunction)(int, char **);
    9.54 -static SDL_WinRT_MainFunction SDL_WinRT_main = nullptr;
    9.55 -
    9.56 -// HACK, DLudwig: record a reference to the global, Windows RT 'app'/view.
    9.57 -// SDL/WinRT will use this throughout its code.
    9.58 -//
    9.59 -// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something
    9.60 -// non-global, such as something created inside
    9.61 -// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside
    9.62 -// SDL_CreateWindow().
    9.63 -SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
    9.64 -
    9.65 -ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
    9.66 -{
    9.67 -public:
    9.68 -    virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
    9.69 -};
    9.70 -
    9.71 -IFrameworkView^ SDLApplicationSource::CreateView()
    9.72 -{
    9.73 -    // TODO, WinRT: see if this function (CreateView) can ever get called
    9.74 -    // more than once.  For now, just prevent it from ever assigning
    9.75 -    // SDL_WinRTGlobalApp more than once.
    9.76 -    SDL_assert(!SDL_WinRTGlobalApp);
    9.77 -    SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
    9.78 -    if (!SDL_WinRTGlobalApp)
    9.79 -    {
    9.80 -        SDL_WinRTGlobalApp = app;
    9.81 -    }
    9.82 -    return app;
    9.83 -}
    9.84 -
    9.85 -__declspec(dllexport) int SDL_WinRT_RunApplication(SDL_WinRT_MainFunction mainFunction)
    9.86 -{
    9.87 -    SDL_WinRT_main = mainFunction;
    9.88 -    auto direct3DApplicationSource = ref new SDLApplicationSource();
    9.89 -    CoreApplication::Run(direct3DApplicationSource);
    9.90 -    return 0;
    9.91 -}
    9.92 -
    9.93 -static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
    9.94 -{
    9.95 -    SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
    9.96 -
    9.97 -    // Start with no orientation flags, then add each in as they're parsed
    9.98 -    // from newValue.
    9.99 -    unsigned int orientationFlags = 0;
   9.100 -    if (newValue) {
   9.101 -        std::istringstream tokenizer(newValue);
   9.102 -        while (!tokenizer.eof()) {
   9.103 -            std::string orientationName;
   9.104 -            std::getline(tokenizer, orientationName, ' ');
   9.105 -            if (orientationName == "LandscapeLeft") {
   9.106 -                orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped;
   9.107 -            } else if (orientationName == "LandscapeRight") {
   9.108 -                orientationFlags |= (unsigned int) DisplayOrientations::Landscape;
   9.109 -            } else if (orientationName == "Portrait") {
   9.110 -                orientationFlags |= (unsigned int) DisplayOrientations::Portrait;
   9.111 -            } else if (orientationName == "PortraitUpsideDown") {
   9.112 -                orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped;
   9.113 -            }
   9.114 -        }
   9.115 -    }
   9.116 -
   9.117 -    // If no valid orientation flags were specified, use a reasonable set of defaults:
   9.118 -    if (!orientationFlags) {
   9.119 -        // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s).
   9.120 -        orientationFlags = (unsigned int) ( \
   9.121 -            DisplayOrientations::Landscape |
   9.122 -            DisplayOrientations::LandscapeFlipped |
   9.123 -            DisplayOrientations::Portrait |
   9.124 -            DisplayOrientations::PortraitFlipped);
   9.125 -    }
   9.126 -
   9.127 -    // Set the orientation/rotation preferences.  Please note that this does
   9.128 -    // not constitute a 100%-certain lock of a given set of possible
   9.129 -    // orientations.  According to Microsoft's documentation on Windows RT [1]
   9.130 -    // when a device is not capable of being rotated, Windows may ignore
   9.131 -    // the orientation preferences, and stick to what the device is capable of
   9.132 -    // displaying.
   9.133 -    //
   9.134 -    // [1] Documentation on the 'InitialRotationPreference' setting for a
   9.135 -    // Windows app's manifest file describes how some orientation/rotation
   9.136 -    // preferences may be ignored.  See
   9.137 -    // http://msdn.microsoft.com/en-us/library/windows/apps/hh700343.aspx
   9.138 -    // for details.  Microsoft's "Display orientation sample" also gives an
   9.139 -    // outline of how Windows treats device rotation
   9.140 -    // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
   9.141 -    DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
   9.142 -}
   9.143 -
   9.144 -SDL_WinRTApp::SDL_WinRTApp() :
   9.145 -    m_windowClosed(false),
   9.146 -    m_windowVisible(true),
   9.147 -    m_sdlWindowData(NULL),
   9.148 -    m_sdlVideoDevice(NULL),
   9.149 -    m_useRelativeMouseMode(false)
   9.150 -{
   9.151 -}
   9.152 -
   9.153 -void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
   9.154 -{
   9.155 -    applicationView->Activated +=
   9.156 -        ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
   9.157 -
   9.158 -    CoreApplication::Suspending +=
   9.159 -        ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
   9.160 -
   9.161 -    CoreApplication::Resuming +=
   9.162 -        ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
   9.163 -
   9.164 -    DisplayProperties::OrientationChanged +=
   9.165 -        ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged);
   9.166 -
   9.167 -    // Register the hint, SDL_HINT_ORIENTATIONS, with SDL.  This needs to be
   9.168 -    // done before the hint's callback is registered (as of Feb 22, 2013),
   9.169 -    // otherwise the hint callback won't get registered.
   9.170 -    //
   9.171 -    // WinRT, TODO: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly.
   9.172 -    //SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight Portrait PortraitUpsideDown");   // DavidL: this is no longer needed (for SDL_AddHintCallback)
   9.173 -    SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL);
   9.174 -}
   9.175 -
   9.176 -void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
   9.177 -{
   9.178 -#if LOG_ORIENTATION_EVENTS==1
   9.179 -    CoreWindow^ window = CoreWindow::GetForCurrentThread();
   9.180 -    if (window) {
   9.181 -        SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Size={%f,%f}\n",
   9.182 -            __FUNCTION__,
   9.183 -            (int)DisplayProperties::CurrentOrientation,
   9.184 -            (int)DisplayProperties::NativeOrientation,
   9.185 -            (int)DisplayProperties::AutoRotationPreferences,
   9.186 -            window->Bounds.Width,
   9.187 -            window->Bounds.Height);
   9.188 -    } else {
   9.189 -        SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n",
   9.190 -            __FUNCTION__,
   9.191 -            (int)DisplayProperties::CurrentOrientation,
   9.192 -            (int)DisplayProperties::NativeOrientation,
   9.193 -            (int)DisplayProperties::AutoRotationPreferences);
   9.194 -    }
   9.195 -#endif
   9.196 -}
   9.197 -
   9.198 -void SDL_WinRTApp::SetWindow(CoreWindow^ window)
   9.199 -{
   9.200 -#if LOG_WINDOW_EVENTS==1
   9.201 -    SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window Size={%f,%f}\n",
   9.202 -        __FUNCTION__,
   9.203 -        (int)DisplayProperties::CurrentOrientation,
   9.204 -        (int)DisplayProperties::NativeOrientation,
   9.205 -        (int)DisplayProperties::AutoRotationPreferences,
   9.206 -        window->Bounds.Width,
   9.207 -        window->Bounds.Height);
   9.208 -#endif
   9.209 -
   9.210 -    window->SizeChanged += 
   9.211 -        ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
   9.212 -
   9.213 -    window->VisibilityChanged +=
   9.214 -        ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
   9.215 -
   9.216 -    window->Closed += 
   9.217 -        ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
   9.218 -
   9.219 -#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
   9.220 -    window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
   9.221 -#endif
   9.222 -
   9.223 -    window->PointerPressed +=
   9.224 -        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
   9.225 -
   9.226 -    window->PointerReleased +=
   9.227 -        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
   9.228 -
   9.229 -    window->PointerWheelChanged +=
   9.230 -        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerWheelChanged);
   9.231 -
   9.232 -    window->PointerMoved +=
   9.233 -        ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
   9.234 -
   9.235 -#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
   9.236 -    // Retrieves relative-only mouse movements:
   9.237 -    Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
   9.238 -        ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &SDL_WinRTApp::OnMouseMoved);
   9.239 -#endif
   9.240 -
   9.241 -    window->KeyDown +=
   9.242 -        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyDown);
   9.243 -
   9.244 -    window->KeyUp +=
   9.245 -        ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyUp);
   9.246 -}
   9.247 -
   9.248 -void SDL_WinRTApp::Load(Platform::String^ entryPoint)
   9.249 -{
   9.250 -}
   9.251 -
   9.252 -void SDL_WinRTApp::Run()
   9.253 -{
   9.254 -    SDL_SetMainReady();
   9.255 -    if (SDL_WinRT_main)
   9.256 -    {
   9.257 -        // TODO, WinRT: pass the C-style main() a reasonably realistic
   9.258 -        // representation of command line arguments.
   9.259 -        int argc = 0;
   9.260 -        char **argv = NULL;
   9.261 -        SDL_WinRT_main(argc, argv);
   9.262 -    }
   9.263 -}
   9.264 -
   9.265 -void SDL_WinRTApp::PumpEvents()
   9.266 -{
   9.267 -    if (!m_windowClosed)
   9.268 -    {
   9.269 -        if (m_windowVisible)
   9.270 -        {
   9.271 -            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
   9.272 -        }
   9.273 -        else
   9.274 -        {
   9.275 -            CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
   9.276 -        }
   9.277 -    }
   9.278 -}
   9.279 -
   9.280 -void SDL_WinRTApp::Uninitialize()
   9.281 -{
   9.282 -}
   9.283 -
   9.284 -void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
   9.285 -{
   9.286 -#if LOG_WINDOW_EVENTS==1
   9.287 -    SDL_Log("%s, size={%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, m_sdlWindowData?=%s\n",
   9.288 -        __FUNCTION__,
   9.289 -        args->Size.Width, args->Size.Height,
   9.290 -        (int)DisplayProperties::CurrentOrientation,
   9.291 -        (int)DisplayProperties::NativeOrientation,
   9.292 -        (int)DisplayProperties::AutoRotationPreferences,
   9.293 -        (m_sdlWindowData ? "yes" : "no"));
   9.294 -#endif
   9.295 -
   9.296 -    if (m_sdlWindowData) {
   9.297 -        // Make the new window size be the one true fullscreen mode.
   9.298 -        // This change was done, in part, to allow the Direct3D 11.1 renderer
   9.299 -        // to receive window-resize events as a device rotates.
   9.300 -        // Before, rotating a device from landscape, to portrait, and then
   9.301 -        // back to landscape would cause the Direct3D 11.1 swap buffer to
   9.302 -        // not get resized appropriately.  SDL would, on the rotation from
   9.303 -        // landscape to portrait, re-resize the SDL window to it's initial
   9.304 -        // size (landscape).  On the subsequent rotation, SDL would drop the
   9.305 -        // window-resize event as it appeared the SDL window didn't change
   9.306 -        // size, and the Direct3D 11.1 renderer wouldn't resize its swap
   9.307 -        // chain.
   9.308 -        //
   9.309 -        // TODO, WinRT: consider dropping old display modes after the fullscreen window changes size (from rotations, etc.)
   9.310 -        m_sdlWindowData->sdlWindow->fullscreen_mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
   9.311 -        SDL_AddDisplayMode(&m_sdlVideoDevice->displays[0], &m_sdlWindowData->sdlWindow->fullscreen_mode);
   9.312 -
   9.313 -        // HACK, Feb 19, 2013: SDL_WINDOWEVENT_RESIZED events, when sent,
   9.314 -        // will attempt to fix the values of the main window's renderer's
   9.315 -        // viewport.  While this can be good, it does appear to be buggy,
   9.316 -        // and can cause a fullscreen viewport to become corrupted.  This
   9.317 -        // behavior was noticed on a Surface RT while rotating the device
   9.318 -        // from landscape to portrait.  Oddly enough, this did not occur
   9.319 -        // in the Windows Simulator.
   9.320 -        //
   9.321 -        // Backing up, then restoring, the main renderer's 'resized' flag
   9.322 -        // seems to fix fullscreen viewport problems when rotating a
   9.323 -        // Windows device.
   9.324 -        //
   9.325 -        // Commencing hack in 3... 2... 1...
   9.326 -        //
   9.327 -        // UPDATE, SDL 2.0.0 update: the 'resized' flag is now gone.  This
   9.328 -        // hack might not be necessary any more.
   9.329 -        //
   9.330 -        //SDL_Renderer * rendererForMainWindow = SDL_GetRenderer(m_sdlWindowData->sdlWindow);
   9.331 -        // For now, limit the hack to when the Direct3D 11.1 is getting used:
   9.332 -        //const bool usingD3D11Renderer = \
   9.333 -        //    (rendererForMainWindow != NULL) &&
   9.334 -        //    (SDL_strcmp(rendererForMainWindow->info.name, "direct3d 11.1") == 0);
   9.335 -        //SDL_bool wasD3D11RendererResized = SDL_FALSE;
   9.336 -        //if (usingD3D11Renderer) {
   9.337 -        //    wasD3D11RendererResized = rendererForMainWindow->resized;
   9.338 -        //}
   9.339 -
   9.340 -        // Send the window-resize event to the rest of SDL, and to apps:
   9.341 -        const int windowWidth = (int) ceil(args->Size.Width);
   9.342 -        const int windowHeight = (int) ceil(args->Size.Height);
   9.343 -        SDL_SendWindowEvent(
   9.344 -            m_sdlWindowData->sdlWindow,
   9.345 -            SDL_WINDOWEVENT_RESIZED,
   9.346 -            windowWidth,
   9.347 -            windowHeight);
   9.348 -
   9.349 -        //// Viewport hack, part two:
   9.350 -        //if (usingD3D11Renderer) {
   9.351 -        //    rendererForMainWindow->resized = wasD3D11RendererResized;
   9.352 -        //}
   9.353 -    }
   9.354 -}
   9.355 -
   9.356 -void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
   9.357 -{
   9.358 -#if LOG_WINDOW_EVENTS==1
   9.359 -    SDL_Log("%s, visible?=%s, m_sdlWindowData?=%s\n",
   9.360 -        __FUNCTION__,
   9.361 -        (args->Visible ? "yes" : "no"),
   9.362 -        (m_sdlWindowData ? "yes" : "no"));
   9.363 -#endif
   9.364 -
   9.365 -    m_windowVisible = args->Visible;
   9.366 -    if (m_sdlWindowData) {
   9.367 -        SDL_bool wasSDLWindowSurfaceValid = m_sdlWindowData->sdlWindow->surface_valid;
   9.368 -
   9.369 -        if (args->Visible) {
   9.370 -            SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
   9.371 -        } else {
   9.372 -            SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
   9.373 -        }
   9.374 -
   9.375 -        // HACK: Prevent SDL's window-hide handling code, which currently
   9.376 -        // triggers a fake window resize (possibly erronously), from
   9.377 -        // marking the SDL window's surface as invalid.
   9.378 -        //
   9.379 -        // A better solution to this probably involves figuring out if the
   9.380 -        // fake window resize can be prevented.
   9.381 -        m_sdlWindowData->sdlWindow->surface_valid = wasSDLWindowSurfaceValid;
   9.382 -    }
   9.383 -}
   9.384 -
   9.385 -void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
   9.386 -{
   9.387 -#if LOG_WINDOW_EVENTS==1
   9.388 -    SDL_Log("%s\n", __FUNCTION__);
   9.389 -#endif
   9.390 -    m_windowClosed = true;
   9.391 -}
   9.392 -
   9.393 -static Uint8
   9.394 -WINRT_GetSDLButtonForPointerPoint(PointerPoint ^ pt)
   9.395 -{
   9.396 -    switch (pt->Properties->PointerUpdateKind)
   9.397 -    {
   9.398 -        case PointerUpdateKind::LeftButtonPressed:
   9.399 -        case PointerUpdateKind::LeftButtonReleased:
   9.400 -            return SDL_BUTTON_LEFT;
   9.401 -
   9.402 -        case PointerUpdateKind::RightButtonPressed:
   9.403 -        case PointerUpdateKind::RightButtonReleased:
   9.404 -            return SDL_BUTTON_RIGHT;
   9.405 -
   9.406 -        case PointerUpdateKind::MiddleButtonPressed:
   9.407 -        case PointerUpdateKind::MiddleButtonReleased:
   9.408 -            return SDL_BUTTON_MIDDLE;
   9.409 -
   9.410 -        case PointerUpdateKind::XButton1Pressed:
   9.411 -        case PointerUpdateKind::XButton1Released:
   9.412 -            return SDL_BUTTON_X1;
   9.413 -
   9.414 -        case PointerUpdateKind::XButton2Pressed:
   9.415 -        case PointerUpdateKind::XButton2Released:
   9.416 -            return SDL_BUTTON_X2;
   9.417 -
   9.418 -        default:
   9.419 -            break;
   9.420 -    }
   9.421 -
   9.422 -    return 0;
   9.423 -}
   9.424 -
   9.425 -static const char *
   9.426 -WINRT_ConvertPointerUpdateKindToString(PointerUpdateKind kind)
   9.427 -{
   9.428 -    switch (kind)
   9.429 -    {
   9.430 -        case PointerUpdateKind::Other:
   9.431 -            return "Other";
   9.432 -        case PointerUpdateKind::LeftButtonPressed:
   9.433 -            return "LeftButtonPressed";
   9.434 -        case PointerUpdateKind::LeftButtonReleased:
   9.435 -            return "LeftButtonReleased";
   9.436 -        case PointerUpdateKind::RightButtonPressed:
   9.437 -            return "RightButtonPressed";
   9.438 -        case PointerUpdateKind::RightButtonReleased:
   9.439 -            return "RightButtonReleased";
   9.440 -        case PointerUpdateKind::MiddleButtonPressed:
   9.441 -            return "MiddleButtonPressed";
   9.442 -        case PointerUpdateKind::MiddleButtonReleased:
   9.443 -            return "MiddleButtonReleased";
   9.444 -        case PointerUpdateKind::XButton1Pressed:
   9.445 -            return "XButton1Pressed";
   9.446 -        case PointerUpdateKind::XButton1Released:
   9.447 -            return "XButton1Released";
   9.448 -        case PointerUpdateKind::XButton2Pressed:
   9.449 -            return "XButton2Pressed";
   9.450 -        case PointerUpdateKind::XButton2Released:
   9.451 -            return "XButton2Released";
   9.452 -    }
   9.453 -
   9.454 -    return "";
   9.455 -}
   9.456 -
   9.457 -static void
   9.458 -WINRT_LogPointerEvent(const string & header, PointerEventArgs ^ args, Point transformedPoint)
   9.459 -{
   9.460 -    PointerPoint ^ pt = args->CurrentPoint;
   9.461 -    SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, PointerUpdateKind=%s\n",
   9.462 -        header.c_str(),
   9.463 -        pt->Position.X, pt->Position.Y,
   9.464 -        transformedPoint.X, transformedPoint.Y,
   9.465 -        pt->Properties->MouseWheelDelta,
   9.466 -        pt->FrameId,
   9.467 -        pt->PointerId,
   9.468 -        WINRT_ConvertPointerUpdateKindToString(args->CurrentPoint->Properties->PointerUpdateKind));
   9.469 -}
   9.470 -
   9.471 -void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
   9.472 -{
   9.473 -#if LOG_POINTER_EVENTS
   9.474 -    WINRT_LogPointerEvent("mouse down", args, TransformCursor(args->CurrentPoint->Position));
   9.475 -#endif
   9.476 -
   9.477 -    if (m_sdlWindowData) {
   9.478 -        Uint8 button = WINRT_GetSDLButtonForPointerPoint(args->CurrentPoint);
   9.479 -        if (button) {
   9.480 -            SDL_SendMouseButton(m_sdlWindowData->sdlWindow, 0, SDL_PRESSED, button);
   9.481 -        }
   9.482 -    }
   9.483 -}
   9.484 -
   9.485 -void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
   9.486 -{
   9.487 -#if LOG_POINTER_EVENTS
   9.488 -    WINRT_LogPointerEvent("mouse up", args, TransformCursor(args->CurrentPoint->Position));
   9.489 -#endif
   9.490 -
   9.491 -    if (m_sdlWindowData) {
   9.492 -        Uint8 button = WINRT_GetSDLButtonForPointerPoint(args->CurrentPoint);
   9.493 -        if (button) {
   9.494 -            SDL_SendMouseButton(m_sdlWindowData->sdlWindow, 0, SDL_RELEASED, button);
   9.495 -        }
   9.496 -    }
   9.497 -}
   9.498 -
   9.499 -void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
   9.500 -{
   9.501 -#if LOG_POINTER_EVENTS
   9.502 -    WINRT_LogPointerEvent("wheel changed", args, TransformCursor(args->CurrentPoint->Position));
   9.503 -#endif
   9.504 -
   9.505 -    if (m_sdlWindowData) {
   9.506 -        // FIXME: This may need to accumulate deltas up to WHEEL_DELTA
   9.507 -        short motion = args->CurrentPoint->Properties->MouseWheelDelta / WHEEL_DELTA;
   9.508 -        SDL_SendMouseWheel(m_sdlWindowData->sdlWindow, 0, 0, motion);
   9.509 -    }
   9.510 -}
   9.511 -
   9.512 -static inline int _lround(float arg) {
   9.513 -    if (arg >= 0.0f) {
   9.514 -        return (int)floor(arg + 0.5f);
   9.515 -    } else {
   9.516 -        return (int)ceil(arg - 0.5f);
   9.517 -    }
   9.518 -}
   9.519 -
   9.520 -void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
   9.521 -{
   9.522 -    if (m_sdlWindowData && m_useRelativeMouseMode) {
   9.523 -        // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows
   9.524 -        // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs'
   9.525 -        // MouseDelta field often reports very large values.  More information
   9.526 -        // on this can be found at the following pages on MSDN:
   9.527 -        //  - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8
   9.528 -        //  - https://connect.microsoft.com/VisualStudio/Feedback/details/756515
   9.529 -        //
   9.530 -        // The values do not appear to be as large when running on some systems,
   9.531 -        // most notably a Surface RT.  Furthermore, the values returned by
   9.532 -        // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved
   9.533 -        // method, do not ever appear to be large, even when MouseEventArgs'
   9.534 -        // MouseDelta is reporting to the contrary.
   9.535 -        //
   9.536 -        // On systems with the large-values behavior, it appears that the values
   9.537 -        // get reported as if the screen's size is 65536 units in both the X and Y
   9.538 -        // dimensions.  This can be viewed by using Windows' now-private, "Raw Input"
   9.539 -        // APIs.  (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.)
   9.540 -        //
   9.541 -        // MSDN's documentation on MouseEventArgs' MouseDelta field (at
   9.542 -        // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ),
   9.543 -        // does not seem to indicate (to me) that its values should be so large.  It
   9.544 -        // says that its values should be a "change in screen location".  I could
   9.545 -        // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see: 
   9.546 -        // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ),
   9.547 -        // indicates that these values are in DIPs, which is the same unit used
   9.548 -        // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint
   9.549 -        // property.  See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx
   9.550 -        // for details.)
   9.551 -        //
   9.552 -        // To note, PointerMoved events are sent a 'RawPosition' value (via the
   9.553 -        // CurrentPoint property in MouseEventArgs), however these do not seem
   9.554 -        // to exhibit the same large-value behavior.
   9.555 -        //
   9.556 -        // The values passed via PointerMoved events can't always be used for relative
   9.557 -        // mouse motion, unfortunately.  Its values are bound to the cursor's position,
   9.558 -        // which stops when it hits one of the screen's edges.  This can be a problem in
   9.559 -        // first person shooters, whereby it is normal for mouse motion to travel far
   9.560 -        // along any one axis for a period of time.  MouseMoved events do not have the
   9.561 -        // screen-bounding limitation, and can be used regardless of where the system's
   9.562 -        // cursor is.
   9.563 -        //
   9.564 -        // One possible workaround would be to programmatically set the cursor's
   9.565 -        // position to the screen's center (when SDL's relative mouse mode is enabled),
   9.566 -        // however Windows RT does not yet seem to have the ability to set the cursor's
   9.567 -        // position via a public API.  Win32 did this via an API call, SetCursorPos,
   9.568 -        // however WinRT makes this function be private.  Apps that use it won't get
   9.569 -        // approved for distribution in the Windows Store.  I've yet to be able to find
   9.570 -        // a suitable, store-friendly counterpart for WinRT.
   9.571 -        //
   9.572 -        // There may be some room for a workaround whereby OnPointerMoved's values
   9.573 -        // are compared to the values from OnMouseMoved in order to detect
   9.574 -        // when this bug is active.  A suitable transformation could then be made to
   9.575 -        // OnMouseMoved's values.  For now, however, the system-reported values are sent
   9.576 -        // to SDL with minimal transformation: from native screen coordinates (in DIPs)
   9.577 -        // to SDL window coordinates.
   9.578 -        //
   9.579 -        const Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y);
   9.580 -        const Point mouseDeltaInSDLWindowCoords = TransformCursor(mouseDeltaInDIPs);
   9.581 -        SDL_SendMouseMotion(
   9.582 -            m_sdlWindowData->sdlWindow,
   9.583 -            0,
   9.584 -            1,
   9.585 -            _lround(mouseDeltaInSDLWindowCoords.X),
   9.586 -            _lround(mouseDeltaInSDLWindowCoords.Y));
   9.587 -    }
   9.588 -}
   9.589 -
   9.590 -// Applies necessary geometric transformations to raw cursor positions:
   9.591 -Point SDL_WinRTApp::TransformCursor(Point rawPosition)
   9.592 -{
   9.593 -    if ( ! m_sdlWindowData || ! m_sdlWindowData->sdlWindow ) {
   9.594 -        return rawPosition;
   9.595 -    }
   9.596 -    CoreWindow ^ nativeWindow = CoreWindow::GetForCurrentThread();
   9.597 -    Point outputPosition;
   9.598 -    outputPosition.X = rawPosition.X * (((float32)m_sdlWindowData->sdlWindow->w) / nativeWindow->Bounds.Width);
   9.599 -    outputPosition.Y = rawPosition.Y * (((float32)m_sdlWindowData->sdlWindow->h) / nativeWindow->Bounds.Height);
   9.600 -    return outputPosition;
   9.601 -}
   9.602 -
   9.603 -void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
   9.604 -{
   9.605 -#if LOG_POINTER_EVENTS
   9.606 -    WINRT_LogPointerEvent("pointer moved", args, TransformCursor(args->CurrentPoint->Position));
   9.607 -#endif
   9.608 -
   9.609 -    if (m_sdlWindowData && ! m_useRelativeMouseMode)
   9.610 -    {
   9.611 -        Point transformedPoint = TransformCursor(args->CurrentPoint->Position);
   9.612 -        SDL_SendMouseMotion(m_sdlWindowData->sdlWindow, 0, 0, (int)transformedPoint.X, (int)transformedPoint.Y);
   9.613 -    }
   9.614 -}
   9.615 -
   9.616 -static SDL_Scancode WinRT_Official_Keycodes[] = {
   9.617 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.None -- 0
   9.618 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftButton -- 1
   9.619 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.RightButton -- 2
   9.620 -    SDL_SCANCODE_CANCEL, // VirtualKey.Cancel -- 3
   9.621 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.MiddleButton -- 4
   9.622 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton1 -- 5
   9.623 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton2 -- 6
   9.624 -    SDL_SCANCODE_UNKNOWN, // -- 7
   9.625 -    SDL_SCANCODE_BACKSPACE, // VirtualKey.Back -- 8
   9.626 -    SDL_SCANCODE_TAB, // VirtualKey.Tab -- 9
   9.627 -    SDL_SCANCODE_UNKNOWN, // -- 10
   9.628 -    SDL_SCANCODE_UNKNOWN, // -- 11
   9.629 -    SDL_SCANCODE_CLEAR, // VirtualKey.Clear -- 12
   9.630 -    SDL_SCANCODE_RETURN, // VirtualKey.Enter -- 13
   9.631 -    SDL_SCANCODE_UNKNOWN, // -- 14
   9.632 -    SDL_SCANCODE_UNKNOWN, // -- 15
   9.633 -    SDL_SCANCODE_LSHIFT, // VirtualKey.Shift -- 16
   9.634 -    SDL_SCANCODE_LCTRL, // VirtualKey.Control -- 17
   9.635 -    SDL_SCANCODE_MENU, // VirtualKey.Menu -- 18
   9.636 -    SDL_SCANCODE_PAUSE, // VirtualKey.Pause -- 19
   9.637 -    SDL_SCANCODE_CAPSLOCK, // VirtualKey.CapitalLock -- 20
   9.638 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Kana or VirtualKey.Hangul -- 21
   9.639 -    SDL_SCANCODE_UNKNOWN, // -- 22
   9.640 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Junja -- 23
   9.641 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Final -- 24
   9.642 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Hanja or VirtualKey.Kanji -- 25
   9.643 -    SDL_SCANCODE_UNKNOWN, // -- 26
   9.644 -    SDL_SCANCODE_ESCAPE, // VirtualKey.Escape -- 27
   9.645 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Convert -- 28
   9.646 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.NonConvert -- 29
   9.647 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Accept -- 30
   9.648 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.ModeChange -- 31  (maybe SDL_SCANCODE_MODE ?)
   9.649 -    SDL_SCANCODE_SPACE, // VirtualKey.Space -- 32
   9.650 -    SDL_SCANCODE_PAGEUP, // VirtualKey.PageUp -- 33
   9.651 -    SDL_SCANCODE_PAGEDOWN, // VirtualKey.PageDown -- 34
   9.652 -    SDL_SCANCODE_END, // VirtualKey.End -- 35
   9.653 -    SDL_SCANCODE_HOME, // VirtualKey.Home -- 36
   9.654 -    SDL_SCANCODE_LEFT, // VirtualKey.Left -- 37
   9.655 -    SDL_SCANCODE_UP, // VirtualKey.Up -- 38
   9.656 -    SDL_SCANCODE_RIGHT, // VirtualKey.Right -- 39
   9.657 -    SDL_SCANCODE_DOWN, // VirtualKey.Down -- 40
   9.658 -    SDL_SCANCODE_SELECT, // VirtualKey.Select -- 41
   9.659 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Print -- 42  (maybe SDL_SCANCODE_PRINTSCREEN ?)
   9.660 -    SDL_SCANCODE_EXECUTE, // VirtualKey.Execute -- 43
   9.661 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Snapshot -- 44
   9.662 -    SDL_SCANCODE_INSERT, // VirtualKey.Insert -- 45
   9.663 -    SDL_SCANCODE_DELETE, // VirtualKey.Delete -- 46
   9.664 -    SDL_SCANCODE_HELP, // VirtualKey.Help -- 47
   9.665 -    SDL_SCANCODE_0, // VirtualKey.Number0 -- 48
   9.666 -    SDL_SCANCODE_1, // VirtualKey.Number1 -- 49
   9.667 -    SDL_SCANCODE_2, // VirtualKey.Number2 -- 50
   9.668 -    SDL_SCANCODE_3, // VirtualKey.Number3 -- 51
   9.669 -    SDL_SCANCODE_4, // VirtualKey.Number4 -- 52
   9.670 -    SDL_SCANCODE_5, // VirtualKey.Number5 -- 53
   9.671 -    SDL_SCANCODE_6, // VirtualKey.Number6 -- 54
   9.672 -    SDL_SCANCODE_7, // VirtualKey.Number7 -- 55
   9.673 -    SDL_SCANCODE_8, // VirtualKey.Number8 -- 56
   9.674 -    SDL_SCANCODE_9, // VirtualKey.Number9 -- 57
   9.675 -    SDL_SCANCODE_UNKNOWN, // -- 58
   9.676 -    SDL_SCANCODE_UNKNOWN, // -- 59
   9.677 -    SDL_SCANCODE_UNKNOWN, // -- 60
   9.678 -    SDL_SCANCODE_UNKNOWN, // -- 61
   9.679 -    SDL_SCANCODE_UNKNOWN, // -- 62
   9.680 -    SDL_SCANCODE_UNKNOWN, // -- 63
   9.681 -    SDL_SCANCODE_UNKNOWN, // -- 64
   9.682 -    SDL_SCANCODE_A, // VirtualKey.A -- 65
   9.683 -    SDL_SCANCODE_B, // VirtualKey.B -- 66
   9.684 -    SDL_SCANCODE_C, // VirtualKey.C -- 67
   9.685 -    SDL_SCANCODE_D, // VirtualKey.D -- 68
   9.686 -    SDL_SCANCODE_E, // VirtualKey.E -- 69
   9.687 -    SDL_SCANCODE_F, // VirtualKey.F -- 70
   9.688 -    SDL_SCANCODE_G, // VirtualKey.G -- 71
   9.689 -    SDL_SCANCODE_H, // VirtualKey.H -- 72
   9.690 -    SDL_SCANCODE_I, // VirtualKey.I -- 73
   9.691 -    SDL_SCANCODE_J, // VirtualKey.J -- 74
   9.692 -    SDL_SCANCODE_K, // VirtualKey.K -- 75
   9.693 -    SDL_SCANCODE_L, // VirtualKey.L -- 76
   9.694 -    SDL_SCANCODE_M, // VirtualKey.M -- 77
   9.695 -    SDL_SCANCODE_N, // VirtualKey.N -- 78
   9.696 -    SDL_SCANCODE_O, // VirtualKey.O -- 79
   9.697 -    SDL_SCANCODE_P, // VirtualKey.P -- 80
   9.698 -    SDL_SCANCODE_Q, // VirtualKey.Q -- 81
   9.699 -    SDL_SCANCODE_R, // VirtualKey.R -- 82
   9.700 -    SDL_SCANCODE_S, // VirtualKey.S -- 83
   9.701 -    SDL_SCANCODE_T, // VirtualKey.T -- 84
   9.702 -    SDL_SCANCODE_U, // VirtualKey.U -- 85
   9.703 -    SDL_SCANCODE_V, // VirtualKey.V -- 86
   9.704 -    SDL_SCANCODE_W, // VirtualKey.W -- 87
   9.705 -    SDL_SCANCODE_X, // VirtualKey.X -- 88
   9.706 -    SDL_SCANCODE_Y, // VirtualKey.Y -- 89
   9.707 -    SDL_SCANCODE_Z, // VirtualKey.Z -- 90
   9.708 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftWindows -- 91  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?)
   9.709 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.RightWindows -- 92  (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?)
   9.710 -    SDL_SCANCODE_APPLICATION, // VirtualKey.Application -- 93
   9.711 -    SDL_SCANCODE_UNKNOWN, // -- 94
   9.712 -    SDL_SCANCODE_SLEEP, // VirtualKey.Sleep -- 95
   9.713 -    SDL_SCANCODE_KP_0, // VirtualKey.NumberPad0 -- 96
   9.714 -    SDL_SCANCODE_KP_1, // VirtualKey.NumberPad1 -- 97
   9.715 -    SDL_SCANCODE_KP_2, // VirtualKey.NumberPad2 -- 98
   9.716 -    SDL_SCANCODE_KP_3, // VirtualKey.NumberPad3 -- 99
   9.717 -    SDL_SCANCODE_KP_4, // VirtualKey.NumberPad4 -- 100
   9.718 -    SDL_SCANCODE_KP_5, // VirtualKey.NumberPad5 -- 101
   9.719 -    SDL_SCANCODE_KP_6, // VirtualKey.NumberPad6 -- 102
   9.720 -    SDL_SCANCODE_KP_7, // VirtualKey.NumberPad7 -- 103
   9.721 -    SDL_SCANCODE_KP_8, // VirtualKey.NumberPad8 -- 104
   9.722 -    SDL_SCANCODE_KP_9, // VirtualKey.NumberPad9 -- 105
   9.723 -    SDL_SCANCODE_KP_MULTIPLY, // VirtualKey.Multiply -- 106
   9.724 -    SDL_SCANCODE_KP_PLUS, // VirtualKey.Add -- 107
   9.725 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Separator -- 108
   9.726 -    SDL_SCANCODE_KP_MINUS, // VirtualKey.Subtract -- 109
   9.727 -    SDL_SCANCODE_UNKNOWN, // VirtualKey.Decimal -- 110  (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?)
   9.728 -    SDL_SCANCODE_KP_DIVIDE, // VirtualKey.Divide -- 111
   9.729 -    SDL_SCANCODE_F1, // VirtualKey.F1 -- 112
   9.730 -    SDL_SCANCODE_F2, // VirtualKey.F2 -- 113
   9.731 -    SDL_SCANCODE_F3, // VirtualKey.F3 -- 114
   9.732 -    SDL_SCANCODE_F4, // VirtualKey.F4 -- 115
   9.733 -    SDL_SCANCODE_F5, // VirtualKey.F5 -- 116
   9.734 -    SDL_SCANCODE_F6, // VirtualKey.F6 -- 117
   9.735 -    SDL_SCANCODE_F7, // VirtualKey.F7 -- 118
   9.736 -    SDL_SCANCODE_F8, // VirtualKey.F8 -- 119
   9.737 -    SDL_SCANCODE_F9, // VirtualKey.F9 -- 120
   9.738 -    SDL_SCANCODE_F10, // VirtualKey.F10 -- 121
   9.739 -    SDL_SCANCODE_F11, // VirtualKey.F11 -- 122
   9.740 -    SDL_SCANCODE_F12, // VirtualKey.F12 -- 123
   9.741 -    SDL_SCANCODE_F13, // VirtualKey.F13 -- 124
   9.742 -    SDL_SCANCODE_F14, // VirtualKey.F14 -- 125
   9.743 -    SDL_SCANCODE_F15, // VirtualKey.F15 -- 126
   9.744 -    SDL_SCANCODE_F16, // VirtualKey.F16 -- 127
   9.745 -    SDL_SCANCODE_F17, // VirtualKey.F17 -- 128
   9.746 -    SDL_SCANCODE_F18, // VirtualKey.F18 -- 129
   9.747 -    SDL_SCANCODE_F19, // VirtualKey.F19 -- 130
   9.748 -    SDL_SCANCODE_F20, // VirtualKey.F20 -- 131
   9.749 -    SDL_SCANCODE_F21, // VirtualKey.F21 -- 132
   9.750 -    SDL_SCANCODE_F22, // VirtualKey.F22 -- 133
   9.751 -    SDL_SCANCODE_F23, // VirtualKey.F23 -- 134
   9.752 -    SDL_SCANCODE_F24, // VirtualKey.F24 -- 135
   9.753 -    SDL_SCANCODE_UNKNOWN, // -- 136
   9.754 -    SDL_SCANCODE_UNKNOWN, // -- 137
   9.755 -    SDL_SCANCODE_UNKNOWN, // -- 138
   9.756 -    SDL_SCANCODE_UNKNOWN, // -- 139
   9.757 -    SDL_SCANCODE_UNKNOWN, // -- 140
   9.758 -    SDL_SCANCODE_UNKNOWN, // -- 141
   9.759 -    SDL_SCANCODE_UNKNOWN, // -- 142
   9.760 -    SDL_SCANCODE_UNKNOWN, // -- 143
   9.761 -    SDL_SCANCODE_NUMLOCKCLEAR, // VirtualKey.NumberKeyLock -- 144
   9.762 -    SDL_SCANCODE_SCROLLLOCK, // VirtualKey.Scroll -- 145
   9.763 -    SDL_SCANCODE_UNKNOWN, // -- 146
   9.764 -    SDL_SCANCODE_UNKNOWN, // -- 147
   9.765 -    SDL_SCANCODE_UNKNOWN, // -- 148
   9.766 -    SDL_SCANCODE_UNKNOWN, // -- 149
   9.767 -    SDL_SCANCODE_UNKNOWN, // -- 150
   9.768 -    SDL_SCANCODE_UNKNOWN, // -- 151
   9.769 -    SDL_SCANCODE_UNKNOWN, // -- 152
   9.770 -    SDL_SCANCODE_UNKNOWN, // -- 153
   9.771 -    SDL_SCANCODE_UNKNOWN, // -- 154
   9.772 -    SDL_SCANCODE_UNKNOWN, // -- 155
   9.773 -    SDL_SCANCODE_UNKNOWN, // -- 156
   9.774 -    SDL_SCANCODE_UNKNOWN, // -- 157
   9.775 -    SDL_SCANCODE_UNKNOWN, // -- 158
   9.776 -    SDL_SCANCODE_UNKNOWN, // -- 159
   9.777 -    SDL_SCANCODE_LSHIFT, // VirtualKey.LeftShift -- 160
   9.778 -    SDL_SCANCODE_RSHIFT, // VirtualKey.RightShift -- 161
   9.779 -    SDL_SCANCODE_LCTRL, // VirtualKey.LeftControl -- 162
   9.780 -    SDL_SCANCODE_RCTRL, // VirtualKey.RightControl -- 163
   9.781 -    SDL_SCANCODE_MENU, // VirtualKey.LeftMenu -- 164
   9.782 -    SDL_SCANCODE_MENU, // VirtualKey.RightMenu -- 165
   9.783 -};
   9.784 -
   9.785 -static std::unordered_map<int, SDL_Scancode> WinRT_Unofficial_Keycodes;
   9.786 -
   9.787 -static SDL_Scancode
   9.788 -TranslateKeycode(int keycode)
   9.789 -{
   9.790 -    if (WinRT_Unofficial_Keycodes.empty()) {
   9.791 -        /* Set up a table of undocumented (by Microsoft), WinRT-specific,
   9.792 -           key codes: */
   9.793 -        // TODO, WinRT: move content declarations of WinRT_Unofficial_Keycodes into a C++11 initializer list, when possible
   9.794 -        WinRT_Unofficial_Keycodes[220] = SDL_SCANCODE_GRAVE;
   9.795 -        WinRT_Unofficial_Keycodes[222] = SDL_SCANCODE_BACKSLASH;
   9.796 -    }
   9.797 -
   9.798 -    /* Try to get a documented, WinRT, 'VirtualKey' first (as documented at
   9.799 -       http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.virtualkey.aspx ).
   9.800 -       If that fails, fall back to a Win32 virtual key.
   9.801 -    */
   9.802 -    // TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints
   9.803 -    //SDL_Log("WinRT TranslateKeycode, keycode=%d\n", (int)keycode);
   9.804 -    SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
   9.805 -    if (keycode < SDL_arraysize(WinRT_Official_Keycodes)) {
   9.806 -        scancode = WinRT_Official_Keycodes[keycode];
   9.807 -    }
   9.808 -    if (scancode == SDL_SCANCODE_UNKNOWN) {
   9.809 -        if (WinRT_Unofficial_Keycodes.find(keycode) != WinRT_Unofficial_Keycodes.end()) {
   9.810 -            scancode = WinRT_Unofficial_Keycodes[keycode];
   9.811 -        }
   9.812 -    }
   9.813 -    if (scancode == SDL_SCANCODE_UNKNOWN) {
   9.814 -        if (keycode < SDL_arraysize(windows_scancode_table)) {
   9.815 -            scancode = windows_scancode_table[keycode];
   9.816 -        }
   9.817 -    }
   9.818 -    if (scancode == SDL_SCANCODE_UNKNOWN) {
   9.819 -        SDL_Log("WinRT TranslateKeycode, unknown keycode=%d\n", (int)keycode);
   9.820 -    }
   9.821 -    return scancode;
   9.822 -}
   9.823 -
   9.824 -void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
   9.825 -{
   9.826 -    SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
   9.827 -#if 0
   9.828 -    SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
   9.829 -    SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n",
   9.830 -        (args->Handled ? "1" : "0"),
   9.831 -        (args->KeyStatus.IsExtendedKey ? "1" : "0"),
   9.832 -        (args->KeyStatus.IsKeyReleased ? "1" : "0"),
   9.833 -        (args->KeyStatus.IsMenuKeyDown ? "1" : "0"),
   9.834 -        args->KeyStatus.RepeatCount,
   9.835 -        args->KeyStatus.ScanCode,
   9.836 -        (args->KeyStatus.WasKeyDown ? "1" : "0"),
   9.837 -        args->VirtualKey,
   9.838 -        sdlScancode,
   9.839 -        SDL_GetScancodeName(sdlScancode),
   9.840 -        keycode,
   9.841 -        SDL_GetKeyName(keycode));
   9.842 -    //args->Handled = true;
   9.843 -    //VirtualKey vkey = args->VirtualKey;
   9.844 -#endif
   9.845 -    SDL_SendKeyboardKey(SDL_PRESSED, sdlScancode);
   9.846 -}
   9.847 -
   9.848 -void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
   9.849 -{
   9.850 -    SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey);
   9.851 -#if 0
   9.852 -    SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
   9.853 -    SDL_Log("key up, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n",
   9.854 -        (args->Handled ? "1" : "0"),
   9.855 -        (args->KeyStatus.IsExtendedKey ? "1" : "0"),
   9.856 -        (args->KeyStatus.IsKeyReleased ? "1" : "0"),
   9.857 -        (args->KeyStatus.IsMenuKeyDown ? "1" : "0"),
   9.858 -        args->KeyStatus.RepeatCount,
   9.859 -        args->KeyStatus.ScanCode,
   9.860 -        (args->KeyStatus.WasKeyDown ? "1" : "0"),
   9.861 -        args->VirtualKey,
   9.862 -        sdlScancode,
   9.863 -        SDL_GetScancodeName(sdlScancode),
   9.864 -        keycode,
   9.865 -        SDL_GetKeyName(keycode));
   9.866 -    //args->Handled = true;
   9.867 -#endif
   9.868 -    SDL_SendKeyboardKey(SDL_RELEASED, sdlScancode);
   9.869 -}
   9.870 -
   9.871 -void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
   9.872 -{
   9.873 -    CoreWindow::GetForCurrentThread()->Activate();
   9.874 -}
   9.875 -
   9.876 -static int SDLCALL RemoveAppSuspendAndResumeEvents(void * userdata, SDL_Event * event)
   9.877 -{
   9.878 -    if (event->type == SDL_WINDOWEVENT)
   9.879 -    {
   9.880 -        switch (event->window.event)
   9.881 -        {
   9.882 -            case SDL_WINDOWEVENT_MINIMIZED:
   9.883 -            case SDL_WINDOWEVENT_RESTORED:
   9.884 -                // Return 0 to indicate that the event should be removed from the
   9.885 -                // event queue:
   9.886 -                return 0;
   9.887 -            default:
   9.888 -                break;
   9.889 -        }
   9.890 -    }
   9.891 -
   9.892 -    // Return 1 to indicate that the event should stay in the event queue:
   9.893 -    return 1;
   9.894 -}
   9.895 -
   9.896 -void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
   9.897 -{
   9.898 -    // Save app state asynchronously after requesting a deferral. Holding a deferral
   9.899 -    // indicates that the application is busy performing suspending operations. Be
   9.900 -    // aware that a deferral may not be held indefinitely. After about five seconds,
   9.901 -    // the app will be forced to exit.
   9.902 -    SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
   9.903 -    create_task([this, deferral]()
   9.904 -    {
   9.905 -        // Send a window-minimized event immediately to observers.
   9.906 -        // CoreDispatcher::ProcessEvents, which is the backbone on which
   9.907 -        // SDL_WinRTApp::PumpEvents is built, will not return to its caller
   9.908 -        // once it sends out a suspend event.  Any events posted to SDL's
   9.909 -        // event queue won't get received until the WinRT app is resumed.
   9.910 -        // SDL_AddEventWatch() may be used to receive app-suspend events on
   9.911 -        // WinRT.
   9.912 -        //
   9.913 -        // In order to prevent app-suspend events from being received twice:
   9.914 -        // first via a callback passed to SDL_AddEventWatch, and second via
   9.915 -        // SDL's event queue, the event will be sent to SDL, then immediately
   9.916 -        // removed from the queue.
   9.917 -        if (m_sdlWindowData)
   9.918 -        {
   9.919 -            SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);   // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
   9.920 -            SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
   9.921 -        }
   9.922 -        deferral->Complete();
   9.923 -    });
   9.924 -}
   9.925 -
   9.926 -void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
   9.927 -{
   9.928 -    // Restore any data or state that was unloaded on suspend. By default, data
   9.929 -    // and state are persisted when resuming from suspend. Note that this event
   9.930 -    // does not occur if the app was previously terminated.
   9.931 -    if (m_sdlWindowData)
   9.932 -    {
   9.933 -        SDL_SendWindowEvent(m_sdlWindowData->sdlWindow, SDL_WINDOWEVENT_RESTORED, 0, 0);    // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
   9.934 -
   9.935 -        // Remove the app-resume event from the queue, as is done with the
   9.936 -        // app-suspend event.
   9.937 -        //
   9.938 -        // TODO, WinRT: consider posting this event to the queue even though
   9.939 -        // its counterpart, the app-suspend event, effectively has to be
   9.940 -        // processed immediately.
   9.941 -        SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
   9.942 -    }
   9.943 -}
   9.944 -
   9.945 -SDL_DisplayMode SDL_WinRTApp::GetMainDisplayMode()
   9.946 -{
   9.947 -    // Create an empty, zeroed-out display mode:
   9.948 -    SDL_DisplayMode mode;
   9.949 -    SDL_zero(mode);
   9.950 -
   9.951 -    // Fill in most fields:
   9.952 -    mode.format = SDL_PIXELFORMAT_RGB888;
   9.953 -    mode.refresh_rate = 0;  // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
   9.954 -    mode.driverdata = NULL;
   9.955 -
   9.956 -    // Calculate the display size given the window size, taking into account
   9.957 -    // the current display's DPI:
   9.958 -    const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi; 
   9.959 -    const float dipsPerInch = 96.0f;
   9.960 -    mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
   9.961 -    mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
   9.962 -
   9.963 -    return mode;
   9.964 -}
   9.965 -
   9.966 -const SDL_WindowData * SDL_WinRTApp::GetSDLWindowData() const
   9.967 -{
   9.968 -    return m_sdlWindowData;
   9.969 -}
   9.970 -
   9.971 -bool SDL_WinRTApp::HasSDLWindowData() const
   9.972 -{
   9.973 -    return (m_sdlWindowData != NULL);
   9.974 -}
   9.975 -
   9.976 -void SDL_WinRTApp::SetRelativeMouseMode(bool enable)
   9.977 -{
   9.978 -    m_useRelativeMouseMode = enable;
   9.979 -}
   9.980 -
   9.981 -void SDL_WinRTApp::SetSDLWindowData(const SDL_WindowData * windowData)
   9.982 -{
   9.983 -    m_sdlWindowData = windowData;
   9.984 -}
   9.985 -
   9.986 -void SDL_WinRTApp::SetSDLVideoDevice(const SDL_VideoDevice * videoDevice)
   9.987 -{
   9.988 -    m_sdlVideoDevice = videoDevice;
   9.989 -}
    10.1 --- a/src/video/windowsrt/SDL_WinRTApp.h	Tue Aug 13 20:33:15 2013 -0400
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,52 +0,0 @@
    10.4 -#pragma once
    10.5 -
    10.6 -struct SDL_WindowData;
    10.7 -
    10.8 -ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
    10.9 -{
   10.10 -public:
   10.11 -    SDL_WinRTApp();
   10.12 -    
   10.13 -    // IFrameworkView Methods.
   10.14 -    virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
   10.15 -    virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
   10.16 -    virtual void Load(Platform::String^ entryPoint);
   10.17 -    virtual void Run();
   10.18 -    virtual void Uninitialize();
   10.19 -
   10.20 -internal:
   10.21 -    // SDL-specific methods
   10.22 -    SDL_DisplayMode GetMainDisplayMode();
   10.23 -    void PumpEvents();
   10.24 -    const SDL_WindowData * GetSDLWindowData() const;
   10.25 -    bool HasSDLWindowData() const;
   10.26 -    void SetRelativeMouseMode(bool enable);
   10.27 -    void SetSDLWindowData(const SDL_WindowData * windowData);
   10.28 -    void SetSDLVideoDevice(const SDL_VideoDevice * videoDevice);
   10.29 -    Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
   10.30 -
   10.31 -protected:
   10.32 -    // Event Handlers.
   10.33 -    void OnOrientationChanged(Platform::Object^ sender);
   10.34 -    void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
   10.35 -    void OnLogicalDpiChanged(Platform::Object^ sender);
   10.36 -    void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
   10.37 -    void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
   10.38 -    void OnResuming(Platform::Object^ sender, Platform::Object^ args);
   10.39 -    void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
   10.40 -    void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
   10.41 -    void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
   10.42 -    void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
   10.43 -    void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
   10.44 -    void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
   10.45 -    void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args);
   10.46 -    void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
   10.47 -    void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
   10.48 -
   10.49 -private:
   10.50 -    bool m_windowClosed;
   10.51 -    bool m_windowVisible;
   10.52 -    const SDL_WindowData* m_sdlWindowData;
   10.53 -    const SDL_VideoDevice* m_sdlVideoDevice;
   10.54 -    bool m_useRelativeMouseMode;
   10.55 -};
    11.1 --- a/src/video/windowsrt/SDL_winrtevents.cpp	Tue Aug 13 20:33:15 2013 -0400
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,41 +0,0 @@
    11.4 -/*
    11.5 -  Simple DirectMedia Layer
    11.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    11.7 -
    11.8 -  This software is provided 'as-is', without any express or implied
    11.9 -  warranty.  In no event will the authors be held liable for any damages
   11.10 -  arising from the use of this software.
   11.11 -
   11.12 -  Permission is granted to anyone to use this software for any purpose,
   11.13 -  including commercial applications, and to alter it and redistribute it
   11.14 -  freely, subject to the following restrictions:
   11.15 -
   11.16 -  1. The origin of this software must not be misrepresented; you must not
   11.17 -     claim that you wrote the original software. If you use this software
   11.18 -     in a product, an acknowledgment in the product documentation would be
   11.19 -     appreciated but is not required.
   11.20 -  2. Altered source versions must be plainly marked as such, and must not be
   11.21 -     misrepresented as being the original software.
   11.22 -  3. This notice may not be removed or altered from any source distribution.
   11.23 -*/
   11.24 -#include "SDL_config.h"
   11.25 -
   11.26 -#if SDL_VIDEO_DRIVER_WINRT
   11.27 -
   11.28 -#include "../../events/SDL_events_c.h"
   11.29 -
   11.30 -#include "SDL_winrtvideo.h"
   11.31 -#include "SDL_winrtevents_c.h"
   11.32 -#include "SDL_WinRTApp.h"
   11.33 -
   11.34 -extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
   11.35 -
   11.36 -void
   11.37 -WINRT_PumpEvents(_THIS)
   11.38 -{
   11.39 -    SDL_WinRTGlobalApp->PumpEvents();
   11.40 -}
   11.41 -
   11.42 -#endif /* SDL_VIDEO_DRIVER_WINRT */
   11.43 -
   11.44 -/* vi: set ts=4 sw=4 expandtab: */
    12.1 --- a/src/video/windowsrt/SDL_winrtevents_c.h	Tue Aug 13 20:33:15 2013 -0400
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,27 +0,0 @@
    12.4 -/*
    12.5 -  Simple DirectMedia Layer
    12.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    12.7 -
    12.8 -  This software is provided 'as-is', without any express or implied
    12.9 -  warranty.  In no event will the authors be held liable for any damages
   12.10 -  arising from the use of this software.
   12.11 -
   12.12 -  Permission is granted to anyone to use this software for any purpose,
   12.13 -  including commercial applications, and to alter it and redistribute it
   12.14 -  freely, subject to the following restrictions:
   12.15 -
   12.16 -  1. The origin of this software must not be misrepresented; you must not
   12.17 -     claim that you wrote the original software. If you use this software
   12.18 -     in a product, an acknowledgment in the product documentation would be
   12.19 -     appreciated but is not required.
   12.20 -  2. Altered source versions must be plainly marked as such, and must not be
   12.21 -     misrepresented as being the original software.
   12.22 -  3. This notice may not be removed or altered from any source distribution.
   12.23 -*/
   12.24 -#include "SDL_config.h"
   12.25 -
   12.26 -#include "SDL_winrtvideo.h"
   12.27 -
   12.28 -extern void WINRT_PumpEvents(_THIS);
   12.29 -
   12.30 -/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/src/video/windowsrt/SDL_winrtmouse.cpp	Tue Aug 13 20:33:15 2013 -0400
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,149 +0,0 @@
    13.4 -/*
    13.5 -  Simple DirectMedia Layer
    13.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    13.7 -
    13.8 -  This software is provided 'as-is', without any express or implied
    13.9 -  warranty.  In no event will the authors be held liable for any damages
   13.10 -  arising from the use of this software.
   13.11 -
   13.12 -  Permission is granted to anyone to use this software for any purpose,
   13.13 -  including commercial applications, and to alter it and redistribute it
   13.14 -  freely, subject to the following restrictions:
   13.15 -
   13.16 -  1. The origin of this software must not be misrepresented; you must not
   13.17 -     claim that you wrote the original software. If you use this software
   13.18 -     in a product, an acknowledgment in the product documentation would be
   13.19 -     appreciated but is not required.
   13.20 -  2. Altered source versions must be plainly marked as such, and must not be
   13.21 -     misrepresented as being the original software.
   13.22 -  3. This notice may not be removed or altered from any source distribution.
   13.23 -*/
   13.24 -
   13.25 -#include "SDL_config.h"
   13.26 -
   13.27 -#if SDL_VIDEO_DRIVER_WINRT
   13.28 -
   13.29 -extern "C" {
   13.30 -#include "SDL_assert.h"
   13.31 -#include "../../events/SDL_mouse_c.h"
   13.32 -#include "../SDL_sysvideo.h"
   13.33 -}
   13.34 -
   13.35 -#include "SDL_WinRTApp.h"
   13.36 -#include "SDL_winrtmouse.h"
   13.37 -
   13.38 -using namespace Windows::UI::Core;
   13.39 -using Windows::UI::Core::CoreCursor;
   13.40 -
   13.41 -extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
   13.42 -
   13.43 -
   13.44 -static SDL_Cursor *
   13.45 -WINRT_CreateSystemCursor(SDL_SystemCursor id)
   13.46 -{
   13.47 -    SDL_Cursor *cursor;
   13.48 -    CoreCursorType cursorType = CoreCursorType::Arrow;
   13.49 -
   13.50 -    switch(id)
   13.51 -    {
   13.52 -    default:
   13.53 -        SDL_assert(0);
   13.54 -        return NULL;
   13.55 -    case SDL_SYSTEM_CURSOR_ARROW:     cursorType = CoreCursorType::Arrow; break;
   13.56 -    case SDL_SYSTEM_CURSOR_IBEAM:     cursorType = CoreCursorType::IBeam; break;
   13.57 -    case SDL_SYSTEM_CURSOR_WAIT:      cursorType = CoreCursorType::Wait; break;
   13.58 -    case SDL_SYSTEM_CURSOR_CROSSHAIR: cursorType = CoreCursorType::Cross; break;
   13.59 -    case SDL_SYSTEM_CURSOR_WAITARROW: cursorType = CoreCursorType::Wait; break;
   13.60 -    case SDL_SYSTEM_CURSOR_SIZENWSE:  cursorType = CoreCursorType::SizeNorthwestSoutheast; break;
   13.61 -    case SDL_SYSTEM_CURSOR_SIZENESW:  cursorType = CoreCursorType::SizeNortheastSouthwest; break;
   13.62 -    case SDL_SYSTEM_CURSOR_SIZEWE:    cursorType = CoreCursorType::SizeWestEast; break;
   13.63 -    case SDL_SYSTEM_CURSOR_SIZENS:    cursorType = CoreCursorType::SizeNorthSouth; break;
   13.64 -    case SDL_SYSTEM_CURSOR_SIZEALL:   cursorType = CoreCursorType::SizeAll; break;
   13.65 -    case SDL_SYSTEM_CURSOR_NO:        cursorType = CoreCursorType::UniversalNo; break;
   13.66 -    case SDL_SYSTEM_CURSOR_HAND:      cursorType = CoreCursorType::Hand; break;
   13.67 -    }
   13.68 -
   13.69 -    cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
   13.70 -    if (cursor) {
   13.71 -        /* Create a pointer to a COM reference to a cursor.  The extra
   13.72 -           pointer is used (on top of the COM reference) to allow the cursor
   13.73 -           to be referenced by the SDL_cursor's driverdata field, which is
   13.74 -           a void pointer.
   13.75 -        */
   13.76 -        CoreCursor ^* theCursor = new CoreCursor^(nullptr);
   13.77 -        *theCursor = ref new CoreCursor(cursorType, 0);
   13.78 -        cursor->driverdata = (void *) theCursor;
   13.79 -    } else {
   13.80 -        SDL_OutOfMemory();
   13.81 -    }
   13.82 -
   13.83 -    return cursor;
   13.84 -}
   13.85 -
   13.86 -static SDL_Cursor *
   13.87 -WINRT_CreateDefaultCursor()
   13.88 -{
   13.89 -    return WINRT_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
   13.90 -}
   13.91 -
   13.92 -static void
   13.93 -WINRT_FreeCursor(SDL_Cursor * cursor)
   13.94 -{
   13.95 -    if (cursor->driverdata) {
   13.96 -        CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
   13.97 -        *theCursor = nullptr;       // Release the COM reference to the CoreCursor
   13.98 -        delete theCursor;           // Delete the pointer to the COM reference
   13.99 -    }
  13.100 -    SDL_free(cursor);
  13.101 -}
  13.102 -
  13.103 -static int
  13.104 -WINRT_ShowCursor(SDL_Cursor * cursor)
  13.105 -{
  13.106 -    if (cursor) {
  13.107 -        CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
  13.108 -        CoreWindow::GetForCurrentThread()->PointerCursor = *theCursor;
  13.109 -    } else {
  13.110 -        CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
  13.111 -    }
  13.112 -    return 0;
  13.113 -}
  13.114 -
  13.115 -static int
  13.116 -WINRT_SetRelativeMouseMode(SDL_bool enabled)
  13.117 -{
  13.118 -    SDL_WinRTGlobalApp->SetRelativeMouseMode(enabled ? true : false);
  13.119 -    return 0;
  13.120 -}
  13.121 -
  13.122 -void
  13.123 -WINRT_InitMouse(_THIS)
  13.124 -{
  13.125 -    SDL_Mouse *mouse = SDL_GetMouse();
  13.126 -
  13.127 -    /* DLudwig, Dec 3, 2012: Windows RT does not currently provide APIs for
  13.128 -       the following features, AFAIK:
  13.129 -        - custom cursors  (multiple system cursors are, however, available)
  13.130 -        - programmatically moveable cursors
  13.131 -    */
  13.132 -
  13.133 -#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
  13.134 -    //mouse->CreateCursor = WINRT_CreateCursor;
  13.135 -    mouse->CreateSystemCursor = WINRT_CreateSystemCursor;
  13.136 -    mouse->ShowCursor = WINRT_ShowCursor;
  13.137 -    mouse->FreeCursor = WINRT_FreeCursor;
  13.138 -    //mouse->WarpMouse = WINRT_WarpMouse;
  13.139 -    mouse->SetRelativeMouseMode = WINRT_SetRelativeMouseMode;
  13.140 -
  13.141 -    SDL_SetDefaultCursor(WINRT_CreateDefaultCursor());
  13.142 -#endif
  13.143 -}
  13.144 -
  13.145 -void
  13.146 -WINRT_QuitMouse(_THIS)
  13.147 -{
  13.148 -}
  13.149 -
  13.150 -#endif /* SDL_VIDEO_DRIVER_WINRT */
  13.151 -
  13.152 -/* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/src/video/windowsrt/SDL_winrtmouse.h	Tue Aug 13 20:33:15 2013 -0400
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,31 +0,0 @@
    14.4 -/*
    14.5 -  Simple DirectMedia Layer
    14.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    14.7 -
    14.8 -  This software is provided 'as-is', without any express or implied
    14.9 -  warranty.  In no event will the authors be held liable for any damages
   14.10 -  arising from the use of this software.
   14.11 -
   14.12 -  Permission is granted to anyone to use this software for any purpose,
   14.13 -  including commercial applications, and to alter it and redistribute it
   14.14 -  freely, subject to the following restrictions:
   14.15 -
   14.16 -  1. The origin of this software must not be misrepresented; you must not
   14.17 -     claim that you wrote the original software. If you use this software
   14.18 -     in a product, an acknowledgment in the product documentation would be
   14.19 -     appreciated but is not required.
   14.20 -  2. Altered source versions must be plainly marked as such, and must not be
   14.21 -     misrepresented as being the original software.
   14.22 -  3. This notice may not be removed or altered from any source distribution.
   14.23 -*/
   14.24 -#include "SDL_config.h"
   14.25 -
   14.26 -#ifndef _SDL_windowsmouse_h
   14.27 -#define _SDL_windowsmouse_h
   14.28 -
   14.29 -extern void WINRT_InitMouse(_THIS);
   14.30 -extern void WINRT_QuitMouse(_THIS);
   14.31 -
   14.32 -#endif /* _SDL_windowsmouse_h */
   14.33 -
   14.34 -/* vi: set ts=4 sw=4 expandtab: */
    15.1 --- a/src/video/windowsrt/SDL_winrtvideo.cpp	Tue Aug 13 20:33:15 2013 -0400
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,262 +0,0 @@
    15.4 -/*
    15.5 -  Simple DirectMedia Layer
    15.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    15.7 -
    15.8 -  This software is provided 'as-is', without any express or implied
    15.9 -  warranty.  In no event will the authors be held liable for any damages
   15.10 -  arising from the use of this software.
   15.11 -
   15.12 -  Permission is granted to anyone to use this software for any purpose,
   15.13 -  including commercial applications, and to alter it and redistribute it
   15.14 -  freely, subject to the following restrictions:
   15.15 -
   15.16 -  1. The origin of this software must not be misrepresented; you must not
   15.17 -     claim that you wrote the original software. If you use this software
   15.18 -     in a product, an acknowledgment in the product documentation would be
   15.19 -     appreciated but is not required.
   15.20 -  2. Altered source versions must be plainly marked as such, and must not be
   15.21 -     misrepresented as being the original software.
   15.22 -  3. This notice may not be removed or altered from any source distribution.
   15.23 -*/
   15.24 -#include "SDL_config.h"
   15.25 -
   15.26 -#if SDL_VIDEO_DRIVER_WINRT
   15.27 -
   15.28 -/* WinRT SDL video driver implementation
   15.29 -
   15.30 -   Initial work on this was done by David Ludwig (dludwig@pobox.com), and
   15.31 -   was based off of SDL's "dummy" video driver.
   15.32 - */
   15.33 -
   15.34 -extern "C" {
   15.35 -#include "SDL_video.h"
   15.36 -#include "SDL_mouse.h"
   15.37 -#include "../SDL_sysvideo.h"
   15.38 -#include "../SDL_pixels_c.h"
   15.39 -#include "../../events/SDL_events_c.h"
   15.40 -#include "../../render/SDL_sysrender.h"
   15.41 -#include "SDL_syswm.h"
   15.42 -}
   15.43 -
   15.44 -#include "SDL_WinRTApp.h"
   15.45 -#include "SDL_winrtvideo.h"
   15.46 -#include "SDL_winrtevents_c.h"
   15.47 -#include "SDL_winrtmouse.h"
   15.48 -
   15.49 -using namespace Windows::UI::Core;
   15.50 -
   15.51 -/* On Windows, windows.h defines CreateWindow */
   15.52 -#ifdef CreateWindow
   15.53 -#undef CreateWindow
   15.54 -#endif
   15.55 -
   15.56 -extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
   15.57 -
   15.58 -#define WINRTVID_DRIVER_NAME "winrt"
   15.59 -
   15.60 -/* Initialization/Query functions */
   15.61 -static int WINRT_VideoInit(_THIS);
   15.62 -static int WINRT_InitModes(_THIS);
   15.63 -static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   15.64 -static void WINRT_VideoQuit(_THIS);
   15.65 -
   15.66 -/* Window functions */
   15.67 -static int WINRT_CreateWindow(_THIS, SDL_Window * window);
   15.68 -static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
   15.69 -static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
   15.70 -
   15.71 -/* WinRT driver bootstrap functions */
   15.72 -
   15.73 -static int
   15.74 -WINRT_Available(void)
   15.75 -{
   15.76 -    return (1);
   15.77 -}
   15.78 -
   15.79 -static void
   15.80 -WINRT_DeleteDevice(SDL_VideoDevice * device)
   15.81 -{
   15.82 -    SDL_WinRTGlobalApp->SetSDLVideoDevice(NULL);
   15.83 -    SDL_free(device);
   15.84 -}
   15.85 -
   15.86 -static SDL_VideoDevice *
   15.87 -WINRT_CreateDevice(int devindex)
   15.88 -{
   15.89 -    SDL_VideoDevice *device;
   15.90 -
   15.91 -    /* Initialize all variables that we clean on shutdown */
   15.92 -    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   15.93 -    if (!device) {
   15.94 -        SDL_OutOfMemory();
   15.95 -        if (device) {
   15.96 -            SDL_free(device);
   15.97 -        }
   15.98 -        return (0);
   15.99 -    }
  15.100 -
  15.101 -    /* Set the function pointers */
  15.102 -    device->VideoInit = WINRT_VideoInit;
  15.103 -    device->VideoQuit = WINRT_VideoQuit;
  15.104 -    device->CreateWindow = WINRT_CreateWindow;
  15.105 -    device->DestroyWindow = WINRT_DestroyWindow;
  15.106 -    device->SetDisplayMode = WINRT_SetDisplayMode;
  15.107 -    device->PumpEvents = WINRT_PumpEvents;
  15.108 -    //device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
  15.109 -    //device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
  15.110 -    //device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
  15.111 -    device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
  15.112 -    device->free = WINRT_DeleteDevice;
  15.113 -
  15.114 -    SDL_WinRTGlobalApp->SetSDLVideoDevice(device);
  15.115 -
  15.116 -    return device;
  15.117 -}
  15.118 -
  15.119 -VideoBootStrap WINRT_bootstrap = {
  15.120 -    WINRTVID_DRIVER_NAME, "SDL Windows RT video driver",
  15.121 -    WINRT_Available, WINRT_CreateDevice
  15.122 -};
  15.123 -
  15.124 -int
  15.125 -WINRT_VideoInit(_THIS)
  15.126 -{
  15.127 -    // TODO, WinRT: consider adding a hack to wait (here) for the app's orientation to finish getting set (before the initial display mode is set up)
  15.128 -
  15.129 -    if (WINRT_InitModes(_this) < 0) {
  15.130 -        return -1;
  15.131 -    }
  15.132 -    WINRT_InitMouse(_this);
  15.133 -
  15.134 -    return 0;
  15.135 -}
  15.136 -
  15.137 -static int
  15.138 -WINRT_InitModes(_THIS)
  15.139 -{
  15.140 -    SDL_DisplayMode mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
  15.141 -    if (SDL_AddBasicVideoDisplay(&mode) < 0) {
  15.142 -        return -1;
  15.143 -    }
  15.144 -
  15.145 -    SDL_AddDisplayMode(&_this->displays[0], &mode);
  15.146 -    return 0;
  15.147 -}
  15.148 -
  15.149 -static int
  15.150 -WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
  15.151 -{
  15.152 -    return 0;
  15.153 -}
  15.154 -
  15.155 -void
  15.156 -WINRT_VideoQuit(_THIS)
  15.157 -{
  15.158 -    WINRT_QuitMouse(_this);
  15.159 -}
  15.160 -
  15.161 -int
  15.162 -WINRT_CreateWindow(_THIS, SDL_Window * window)
  15.163 -{
  15.164 -    // Make sure that only one window gets created, at least until multimonitor
  15.165 -    // support is added.
  15.166 -    if (SDL_WinRTGlobalApp->HasSDLWindowData())
  15.167 -    {
  15.168 -        SDL_SetError("WinRT only supports one window");
  15.169 -        return -1;
  15.170 -    }
  15.171 -
  15.172 -    SDL_WindowData *data = new SDL_WindowData;
  15.173 -    if (!data) {
  15.174 -        SDL_OutOfMemory();
  15.175 -        return -1;
  15.176 -    }
  15.177 -    window->driverdata = data;
  15.178 -    data->sdlWindow = window;
  15.179 -    data->coreWindow = CoreWindow::GetForCurrentThread();
  15.180 -
  15.181 -    /* Make sure the window is considered to be positioned at {0,0},
  15.182 -       and is considered fullscreen, shown, and the like.
  15.183 -    */
  15.184 -    window->x = 0;
  15.185 -    window->y = 0;
  15.186 -    window->flags =
  15.187 -        SDL_WINDOW_FULLSCREEN |
  15.188 -        SDL_WINDOW_SHOWN |
  15.189 -        SDL_WINDOW_BORDERLESS |
  15.190 -        SDL_WINDOW_MAXIMIZED |
  15.191 -        SDL_WINDOW_INPUT_GRABBED;
  15.192 -
  15.193 -    /* HACK from DLudwig: The following line of code prevents
  15.194 -       SDL_CreateWindow and SDL_UpdateFullscreenMode from trying to resize
  15.195 -       the window after the call to WINRT_CreateWindow returns.
  15.196 -       
  15.197 -       This hack should allow a window to be created in virtually any size,
  15.198 -       and more importantly, it allows a window's framebuffer, as created and
  15.199 -       retrieved via SDL_GetWindowSurface, to be in any size.  This can be
  15.200 -       utilized by apps centered around software rendering, such as ports
  15.201 -       of older apps.  The app can have SDL create a framebuffer in any size
  15.202 -       it chooses.  SDL will scale the framebuffer to the native
  15.203 -       screen size on the GPU (via SDL_UpdateWindowSurface).
  15.204 -    */
  15.205 -    _this->displays[0].fullscreen_window = window;
  15.206 -
  15.207 -    /* Further prevent any display resizing, and make sure SDL_GetWindowDisplayMode
  15.208 -       can report the correct size of windows, by creating a new display
  15.209 -       mode in the requested size.  To note, if the window is being created in
  15.210 -       the device's native screen size, SDL_AddDisplayMode will do nothing.
  15.211 -    */
  15.212 -    window->fullscreen_mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
  15.213 -    window->fullscreen_mode.w = window->w;
  15.214 -    window->fullscreen_mode.h = window->h;
  15.215 -    SDL_AddDisplayMode(&_this->displays[0], &window->fullscreen_mode);
  15.216 -
  15.217 -    /* TODO: Consider removing custom display modes in WINRT_DestroyWindow. */
  15.218 - 
  15.219 -    /* Make sure the WinRT app's IFramworkView can post events on
  15.220 -       behalf of SDL:
  15.221 -    */
  15.222 -    SDL_WinRTGlobalApp->SetSDLWindowData(data);
  15.223 -
  15.224 -    /* All done! */
  15.225 -    return 0;
  15.226 -}
  15.227 -
  15.228 -void
  15.229 -WINRT_DestroyWindow(_THIS, SDL_Window * window)
  15.230 -{
  15.231 -    SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
  15.232 -
  15.233 -    if (SDL_WinRTGlobalApp->HasSDLWindowData() &&
  15.234 -        SDL_WinRTGlobalApp->GetSDLWindowData()->sdlWindow == window)
  15.235 -    {
  15.236 -        SDL_WinRTGlobalApp->SetSDLWindowData(NULL);
  15.237 -    }
  15.238 -
  15.239 -    if (data) {
  15.240 -        // Delete the internal window data:
  15.241 -        delete data;
  15.242 -        data = NULL;
  15.243 -    }
  15.244 -}
  15.245 -
  15.246 -SDL_bool
  15.247 -WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
  15.248 -{
  15.249 -    SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
  15.250 -
  15.251 -    if (info->version.major <= SDL_MAJOR_VERSION) {
  15.252 -        info->subsystem = SDL_SYSWM_WINDOWSRT;
  15.253 -        info->info.winrt.window = reinterpret_cast<IUnknown *>(data->coreWindow.Get());
  15.254 -        return SDL_TRUE;
  15.255 -    } else {
  15.256 -        SDL_SetError("Application not compiled with SDL %d.%d\n",
  15.257 -                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
  15.258 -        return SDL_FALSE;
  15.259 -    }
  15.260 -    return SDL_FALSE;
  15.261 -}
  15.262 -
  15.263 -#endif /* SDL_VIDEO_DRIVER_WINRT */
  15.264 -
  15.265 -/* vi: set ts=4 sw=4 expandtab: */
    16.1 --- a/src/video/windowsrt/SDL_winrtvideo.h	Tue Aug 13 20:33:15 2013 -0400
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,40 +0,0 @@
    16.4 -/*
    16.5 -  Simple DirectMedia Layer
    16.6 -  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    16.7 -
    16.8 -  This software is provided 'as-is', without any express or implied
    16.9 -  warranty.  In no event will the authors be held liable for any damages
   16.10 -  arising from the use of this software.
   16.11 -
   16.12 -  Permission is granted to anyone to use this software for any purpose,
   16.13 -  including commercial applications, and to alter it and redistribute it
   16.14 -  freely, subject to the following restrictions:
   16.15 -
   16.16 -  1. The origin of this software must not be misrepresented; you must not
   16.17 -     claim that you wrote the original software. If you use this software
   16.18 -     in a product, an acknowledgment in the product documentation would be
   16.19 -     appreciated but is not required.
   16.20 -  2. Altered source versions must be plainly marked as such, and must not be
   16.21 -     misrepresented as being the original software.
   16.22 -  3. This notice may not be removed or altered from any source distribution.
   16.23 -*/
   16.24 -#include "SDL_config.h"
   16.25 -
   16.26 -#ifndef _SDL_winrtvideo_h
   16.27 -#define _SDL_winrtvideo_h
   16.28 -
   16.29 -extern "C" {
   16.30 -#include "../SDL_sysvideo.h"
   16.31 -}
   16.32 -
   16.33 -#include <agile.h>
   16.34 -
   16.35 -struct SDL_WindowData
   16.36 -{
   16.37 -    SDL_Window *sdlWindow;
   16.38 -    Platform::Agile<Windows::UI::Core::CoreWindow> coreWindow;
   16.39 -};
   16.40 -
   16.41 -#endif /* _SDL_winrtvideo_h */
   16.42 -
   16.43 -/* vi: set ts=4 sw=4 expandtab: */
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/src/video/winrt/SDL_winrtevents.cpp	Tue Aug 20 21:22:32 2013 -0400
    17.3 @@ -0,0 +1,41 @@
    17.4 +/*
    17.5 +  Simple DirectMedia Layer
    17.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    17.7 +
    17.8 +  This software is provided 'as-is', without any express or implied
    17.9 +  warranty.  In no event will the authors be held liable for any damages
   17.10 +  arising from the use of this software.
   17.11 +
   17.12 +  Permission is granted to anyone to use this software for any purpose,
   17.13 +  including commercial applications, and to alter it and redistribute it
   17.14 +  freely, subject to the following restrictions:
   17.15 +
   17.16 +  1. The origin of this software must not be misrepresented; you must not
   17.17 +     claim that you wrote the original software. If you use this software
   17.18 +     in a product, an acknowledgment in the product documentation would be
   17.19 +     appreciated but is not required.
   17.20 +  2. Altered source versions must be plainly marked as such, and must not be
   17.21 +     misrepresented as being the original software.
   17.22 +  3. This notice may not be removed or altered from any source distribution.
   17.23 +*/
   17.24 +#include "SDL_config.h"
   17.25 +
   17.26 +#if SDL_VIDEO_DRIVER_WINRT
   17.27 +
   17.28 +#include "../../events/SDL_events_c.h"
   17.29 +
   17.30 +#include "SDL_winrtvideo.h"
   17.31 +#include "SDL_winrtevents_c.h"
   17.32 +#include "../../core/winrt/SDL_winrtapp.h"
   17.33 +
   17.34 +extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
   17.35 +
   17.36 +void
   17.37 +WINRT_PumpEvents(_THIS)
   17.38 +{
   17.39 +    SDL_WinRTGlobalApp->PumpEvents();
   17.40 +}
   17.41 +
   17.42 +#endif /* SDL_VIDEO_DRIVER_WINRT */
   17.43 +
   17.44 +/* vi: set ts=4 sw=4 expandtab: */
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/src/video/winrt/SDL_winrtevents_c.h	Tue Aug 20 21:22:32 2013 -0400
    18.3 @@ -0,0 +1,27 @@
    18.4 +/*
    18.5 +  Simple DirectMedia Layer
    18.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    18.7 +
    18.8 +  This software is provided 'as-is', without any express or implied
    18.9 +  warranty.  In no event will the authors be held liable for any damages
   18.10 +  arising from the use of this software.
   18.11 +
   18.12 +  Permission is granted to anyone to use this software for any purpose,
   18.13 +  including commercial applications, and to alter it and redistribute it
   18.14 +  freely, subject to the following restrictions:
   18.15 +
   18.16 +  1. The origin of this software must not be misrepresented; you must not
   18.17 +     claim that you wrote the original software. If you use this software
   18.18 +     in a product, an acknowledgment in the product documentation would be
   18.19 +     appreciated but is not required.
   18.20 +  2. Altered source versions must be plainly marked as such, and must not be
   18.21 +     misrepresented as being the original software.
   18.22 +  3. This notice may not be removed or altered from any source distribution.
   18.23 +*/
   18.24 +#include "SDL_config.h"
   18.25 +
   18.26 +#include "SDL_winrtvideo.h"
   18.27 +
   18.28 +extern void WINRT_PumpEvents(_THIS);
   18.29 +
   18.30 +/* vi: set ts=4 sw=4 expandtab: */
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/src/video/winrt/SDL_winrtmouse.cpp	Tue Aug 20 21:22:32 2013 -0400
    19.3 @@ -0,0 +1,149 @@
    19.4 +/*
    19.5 +  Simple DirectMedia Layer
    19.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    19.7 +
    19.8 +  This software is provided 'as-is', without any express or implied
    19.9 +  warranty.  In no event will the authors be held liable for any damages
   19.10 +  arising from the use of this software.
   19.11 +
   19.12 +  Permission is granted to anyone to use this software for any purpose,
   19.13 +  including commercial applications, and to alter it and redistribute it
   19.14 +  freely, subject to the following restrictions:
   19.15 +
   19.16 +  1. The origin of this software must not be misrepresented; you must not
   19.17 +     claim that you wrote the original software. If you use this software
   19.18 +     in a product, an acknowledgment in the product documentation would be
   19.19 +     appreciated but is not required.
   19.20 +  2. Altered source versions must be plainly marked as such, and must not be
   19.21 +     misrepresented as being the original software.
   19.22 +  3. This notice may not be removed or altered from any source distribution.
   19.23 +*/
   19.24 +
   19.25 +#include "SDL_config.h"
   19.26 +
   19.27 +#if SDL_VIDEO_DRIVER_WINRT
   19.28 +
   19.29 +extern "C" {
   19.30 +#include "SDL_assert.h"
   19.31 +#include "../../events/SDL_mouse_c.h"
   19.32 +#include "../SDL_sysvideo.h"
   19.33 +}
   19.34 +
   19.35 +#include "../../core/winrt/SDL_winrtapp.h"
   19.36 +#include "SDL_winrtmouse.h"
   19.37 +
   19.38 +using namespace Windows::UI::Core;
   19.39 +using Windows::UI::Core::CoreCursor;
   19.40 +
   19.41 +extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
   19.42 +
   19.43 +
   19.44 +static SDL_Cursor *
   19.45 +WINRT_CreateSystemCursor(SDL_SystemCursor id)
   19.46 +{
   19.47 +    SDL_Cursor *cursor;
   19.48 +    CoreCursorType cursorType = CoreCursorType::Arrow;
   19.49 +
   19.50 +    switch(id)
   19.51 +    {
   19.52 +    default:
   19.53 +        SDL_assert(0);
   19.54 +        return NULL;
   19.55 +    case SDL_SYSTEM_CURSOR_ARROW:     cursorType = CoreCursorType::Arrow; break;
   19.56 +    case SDL_SYSTEM_CURSOR_IBEAM:     cursorType = CoreCursorType::IBeam; break;
   19.57 +    case SDL_SYSTEM_CURSOR_WAIT:      cursorType = CoreCursorType::Wait; break;
   19.58 +    case SDL_SYSTEM_CURSOR_CROSSHAIR: cursorType = CoreCursorType::Cross; break;
   19.59 +    case SDL_SYSTEM_CURSOR_WAITARROW: cursorType = CoreCursorType::Wait; break;
   19.60 +    case SDL_SYSTEM_CURSOR_SIZENWSE:  cursorType = CoreCursorType::SizeNorthwestSoutheast; break;
   19.61 +    case SDL_SYSTEM_CURSOR_SIZENESW:  cursorType = CoreCursorType::SizeNortheastSouthwest; break;
   19.62 +    case SDL_SYSTEM_CURSOR_SIZEWE:    cursorType = CoreCursorType::SizeWestEast; break;
   19.63 +    case SDL_SYSTEM_CURSOR_SIZENS:    cursorType = CoreCursorType::SizeNorthSouth; break;
   19.64 +    case SDL_SYSTEM_CURSOR_SIZEALL:   cursorType = CoreCursorType::SizeAll; break;
   19.65 +    case SDL_SYSTEM_CURSOR_NO:        cursorType = CoreCursorType::UniversalNo; break;
   19.66 +    case SDL_SYSTEM_CURSOR_HAND:      cursorType = CoreCursorType::Hand; break;
   19.67 +    }
   19.68 +
   19.69 +    cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
   19.70 +    if (cursor) {
   19.71 +        /* Create a pointer to a COM reference to a cursor.  The extra
   19.72 +           pointer is used (on top of the COM reference) to allow the cursor
   19.73 +           to be referenced by the SDL_cursor's driverdata field, which is
   19.74 +           a void pointer.
   19.75 +        */
   19.76 +        CoreCursor ^* theCursor = new CoreCursor^(nullptr);
   19.77 +        *theCursor = ref new CoreCursor(cursorType, 0);
   19.78 +        cursor->driverdata = (void *) theCursor;
   19.79 +    } else {
   19.80 +        SDL_OutOfMemory();
   19.81 +    }
   19.82 +
   19.83 +    return cursor;
   19.84 +}
   19.85 +
   19.86 +static SDL_Cursor *
   19.87 +WINRT_CreateDefaultCursor()
   19.88 +{
   19.89 +    return WINRT_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
   19.90 +}
   19.91 +
   19.92 +static void
   19.93 +WINRT_FreeCursor(SDL_Cursor * cursor)
   19.94 +{
   19.95 +    if (cursor->driverdata) {
   19.96 +        CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
   19.97 +        *theCursor = nullptr;       // Release the COM reference to the CoreCursor
   19.98 +        delete theCursor;           // Delete the pointer to the COM reference
   19.99 +    }
  19.100 +    SDL_free(cursor);
  19.101 +}
  19.102 +
  19.103 +static int
  19.104 +WINRT_ShowCursor(SDL_Cursor * cursor)
  19.105 +{
  19.106 +    if (cursor) {
  19.107 +        CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata;
  19.108 +        CoreWindow::GetForCurrentThread()->PointerCursor = *theCursor;
  19.109 +    } else {
  19.110 +        CoreWindow::GetForCurrentThread()->PointerCursor = nullptr;
  19.111 +    }
  19.112 +    return 0;
  19.113 +}
  19.114 +
  19.115 +static int
  19.116 +WINRT_SetRelativeMouseMode(SDL_bool enabled)
  19.117 +{
  19.118 +    SDL_WinRTGlobalApp->SetRelativeMouseMode(enabled ? true : false);
  19.119 +    return 0;
  19.120 +}
  19.121 +
  19.122 +void
  19.123 +WINRT_InitMouse(_THIS)
  19.124 +{
  19.125 +    SDL_Mouse *mouse = SDL_GetMouse();
  19.126 +
  19.127 +    /* DLudwig, Dec 3, 2012: Windows RT does not currently provide APIs for
  19.128 +       the following features, AFAIK:
  19.129 +        - custom cursors  (multiple system cursors are, however, available)
  19.130 +        - programmatically moveable cursors
  19.131 +    */
  19.132 +
  19.133 +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
  19.134 +    //mouse->CreateCursor = WINRT_CreateCursor;
  19.135 +    mouse->CreateSystemCursor = WINRT_CreateSystemCursor;
  19.136 +    mouse->ShowCursor = WINRT_ShowCursor;
  19.137 +    mouse->FreeCursor = WINRT_FreeCursor;
  19.138 +    //mouse->WarpMouse = WINRT_WarpMouse;
  19.139 +    mouse->SetRelativeMouseMode = WINRT_SetRelativeMouseMode;
  19.140 +
  19.141 +    SDL_SetDefaultCursor(WINRT_CreateDefaultCursor());
  19.142 +#endif
  19.143 +}
  19.144 +
  19.145 +void
  19.146 +WINRT_QuitMouse(_THIS)
  19.147 +{
  19.148 +}
  19.149 +
  19.150 +#endif /* SDL_VIDEO_DRIVER_WINRT */
  19.151 +
  19.152 +/* vi: set ts=4 sw=4 expandtab: */
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/src/video/winrt/SDL_winrtmouse.h	Tue Aug 20 21:22:32 2013 -0400
    20.3 @@ -0,0 +1,31 @@
    20.4 +/*
    20.5 +  Simple DirectMedia Layer
    20.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    20.7 +
    20.8 +  This software is provided 'as-is', without any express or implied
    20.9 +  warranty.  In no event will the authors be held liable for any damages
   20.10 +  arising from the use of this software.
   20.11 +
   20.12 +  Permission is granted to anyone to use this software for any purpose,
   20.13 +  including commercial applications, and to alter it and redistribute it
   20.14 +  freely, subject to the following restrictions:
   20.15 +
   20.16 +  1. The origin of this software must not be misrepresented; you must not
   20.17 +     claim that you wrote the original software. If you use this software
   20.18 +     in a product, an acknowledgment in the product documentation would be
   20.19 +     appreciated but is not required.
   20.20 +  2. Altered source versions must be plainly marked as such, and must not be
   20.21 +     misrepresented as being the original software.
   20.22 +  3. This notice may not be removed or altered from any source distribution.
   20.23 +*/
   20.24 +#include "SDL_config.h"
   20.25 +
   20.26 +#ifndef _SDL_windowsmouse_h
   20.27 +#define _SDL_windowsmouse_h
   20.28 +
   20.29 +extern void WINRT_InitMouse(_THIS);
   20.30 +extern void WINRT_QuitMouse(_THIS);
   20.31 +
   20.32 +#endif /* _SDL_windowsmouse_h */
   20.33 +
   20.34 +/* vi: set ts=4 sw=4 expandtab: */
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/src/video/winrt/SDL_winrtvideo.cpp	Tue Aug 20 21:22:32 2013 -0400
    21.3 @@ -0,0 +1,262 @@
    21.4 +/*
    21.5 +  Simple DirectMedia Layer
    21.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    21.7 +
    21.8 +  This software is provided 'as-is', without any express or implied
    21.9 +  warranty.  In no event will the authors be held liable for any damages
   21.10 +  arising from the use of this software.
   21.11 +
   21.12 +  Permission is granted to anyone to use this software for any purpose,
   21.13 +  including commercial applications, and to alter it and redistribute it
   21.14 +  freely, subject to the following restrictions:
   21.15 +
   21.16 +  1. The origin of this software must not be misrepresented; you must not
   21.17 +     claim that you wrote the original software. If you use this software
   21.18 +     in a product, an acknowledgment in the product documentation would be
   21.19 +     appreciated but is not required.
   21.20 +  2. Altered source versions must be plainly marked as such, and must not be
   21.21 +     misrepresented as being the original software.
   21.22 +  3. This notice may not be removed or altered from any source distribution.
   21.23 +*/
   21.24 +#include "SDL_config.h"
   21.25 +
   21.26 +#if SDL_VIDEO_DRIVER_WINRT
   21.27 +
   21.28 +/* WinRT SDL video driver implementation
   21.29 +
   21.30 +   Initial work on this was done by David Ludwig (dludwig@pobox.com), and
   21.31 +   was based off of SDL's "dummy" video driver.
   21.32 + */
   21.33 +
   21.34 +extern "C" {
   21.35 +#include "SDL_video.h"
   21.36 +#include "SDL_mouse.h"
   21.37 +#include "../SDL_sysvideo.h"
   21.38 +#include "../SDL_pixels_c.h"
   21.39 +#include "../../events/SDL_events_c.h"
   21.40 +#include "../../render/SDL_sysrender.h"
   21.41 +#include "SDL_syswm.h"
   21.42 +}
   21.43 +
   21.44 +#include "../../core/winrt/SDL_winrtapp.h"
   21.45 +#include "SDL_winrtvideo.h"
   21.46 +#include "SDL_winrtevents_c.h"
   21.47 +#include "SDL_winrtmouse.h"
   21.48 +
   21.49 +using namespace Windows::UI::Core;
   21.50 +
   21.51 +/* On Windows, windows.h defines CreateWindow */
   21.52 +#ifdef CreateWindow
   21.53 +#undef CreateWindow
   21.54 +#endif
   21.55 +
   21.56 +extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
   21.57 +
   21.58 +#define WINRTVID_DRIVER_NAME "winrt"
   21.59 +
   21.60 +/* Initialization/Query functions */
   21.61 +static int WINRT_VideoInit(_THIS);
   21.62 +static int WINRT_InitModes(_THIS);
   21.63 +static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
   21.64 +static void WINRT_VideoQuit(_THIS);
   21.65 +
   21.66 +/* Window functions */
   21.67 +static int WINRT_CreateWindow(_THIS, SDL_Window * window);
   21.68 +static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
   21.69 +static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
   21.70 +
   21.71 +/* WinRT driver bootstrap functions */
   21.72 +
   21.73 +static int
   21.74 +WINRT_Available(void)
   21.75 +{
   21.76 +    return (1);
   21.77 +}
   21.78 +
   21.79 +static void
   21.80 +WINRT_DeleteDevice(SDL_VideoDevice * device)
   21.81 +{
   21.82 +    SDL_WinRTGlobalApp->SetSDLVideoDevice(NULL);
   21.83 +    SDL_free(device);
   21.84 +}
   21.85 +
   21.86 +static SDL_VideoDevice *
   21.87 +WINRT_CreateDevice(int devindex)
   21.88 +{
   21.89 +    SDL_VideoDevice *device;
   21.90 +
   21.91 +    /* Initialize all variables that we clean on shutdown */
   21.92 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   21.93 +    if (!device) {
   21.94 +        SDL_OutOfMemory();
   21.95 +        if (device) {
   21.96 +            SDL_free(device);
   21.97 +        }
   21.98 +        return (0);
   21.99 +    }
  21.100 +
  21.101 +    /* Set the function pointers */
  21.102 +    device->VideoInit = WINRT_VideoInit;
  21.103 +    device->VideoQuit = WINRT_VideoQuit;
  21.104 +    device->CreateWindow = WINRT_CreateWindow;
  21.105 +    device->DestroyWindow = WINRT_DestroyWindow;
  21.106 +    device->SetDisplayMode = WINRT_SetDisplayMode;
  21.107 +    device->PumpEvents = WINRT_PumpEvents;
  21.108 +    //device->CreateWindowFramebuffer = SDL_WINRT_CreateWindowFramebuffer;
  21.109 +    //device->UpdateWindowFramebuffer = SDL_WINRT_UpdateWindowFramebuffer;
  21.110 +    //device->DestroyWindowFramebuffer = SDL_WINRT_DestroyWindowFramebuffer;
  21.111 +    device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
  21.112 +    device->free = WINRT_DeleteDevice;
  21.113 +
  21.114 +    SDL_WinRTGlobalApp->SetSDLVideoDevice(device);
  21.115 +
  21.116 +    return device;
  21.117 +}
  21.118 +
  21.119 +VideoBootStrap WINRT_bootstrap = {
  21.120 +    WINRTVID_DRIVER_NAME, "SDL Windows RT video driver",
  21.121 +    WINRT_Available, WINRT_CreateDevice
  21.122 +};
  21.123 +
  21.124 +int
  21.125 +WINRT_VideoInit(_THIS)
  21.126 +{
  21.127 +    // TODO, WinRT: consider adding a hack to wait (here) for the app's orientation to finish getting set (before the initial display mode is set up)
  21.128 +
  21.129 +    if (WINRT_InitModes(_this) < 0) {
  21.130 +        return -1;
  21.131 +    }
  21.132 +    WINRT_InitMouse(_this);
  21.133 +
  21.134 +    return 0;
  21.135 +}
  21.136 +
  21.137 +static int
  21.138 +WINRT_InitModes(_THIS)
  21.139 +{
  21.140 +    SDL_DisplayMode mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
  21.141 +    if (SDL_AddBasicVideoDisplay(&mode) < 0) {
  21.142 +        return -1;
  21.143 +    }
  21.144 +
  21.145 +    SDL_AddDisplayMode(&_this->displays[0], &mode);
  21.146 +    return 0;
  21.147 +}
  21.148 +
  21.149 +static int
  21.150 +WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
  21.151 +{
  21.152 +    return 0;
  21.153 +}
  21.154 +
  21.155 +void
  21.156 +WINRT_VideoQuit(_THIS)
  21.157 +{
  21.158 +    WINRT_QuitMouse(_this);
  21.159 +}
  21.160 +
  21.161 +int
  21.162 +WINRT_CreateWindow(_THIS, SDL_Window * window)
  21.163 +{
  21.164 +    // Make sure that only one window gets created, at least until multimonitor
  21.165 +    // support is added.
  21.166 +    if (SDL_WinRTGlobalApp->HasSDLWindowData())
  21.167 +    {
  21.168 +        SDL_SetError("WinRT only supports one window");
  21.169 +        return -1;
  21.170 +    }
  21.171 +
  21.172 +    SDL_WindowData *data = new SDL_WindowData;
  21.173 +    if (!data) {
  21.174 +        SDL_OutOfMemory();
  21.175 +        return -1;
  21.176 +    }
  21.177 +    window->driverdata = data;
  21.178 +    data->sdlWindow = window;
  21.179 +    data->coreWindow = CoreWindow::GetForCurrentThread();
  21.180 +
  21.181 +    /* Make sure the window is considered to be positioned at {0,0},
  21.182 +       and is considered fullscreen, shown, and the like.
  21.183 +    */
  21.184 +    window->x = 0;
  21.185 +    window->y = 0;
  21.186 +    window->flags =
  21.187 +        SDL_WINDOW_FULLSCREEN |
  21.188 +        SDL_WINDOW_SHOWN |
  21.189 +        SDL_WINDOW_BORDERLESS |
  21.190 +        SDL_WINDOW_MAXIMIZED |
  21.191 +        SDL_WINDOW_INPUT_GRABBED;
  21.192 +
  21.193 +    /* HACK from DLudwig: The following line of code prevents
  21.194 +       SDL_CreateWindow and SDL_UpdateFullscreenMode from trying to resize
  21.195 +       the window after the call to WINRT_CreateWindow returns.
  21.196 +       
  21.197 +       This hack should allow a window to be created in virtually any size,
  21.198 +       and more importantly, it allows a window's framebuffer, as created and
  21.199 +       retrieved via SDL_GetWindowSurface, to be in any size.  This can be
  21.200 +       utilized by apps centered around software rendering, such as ports
  21.201 +       of older apps.  The app can have SDL create a framebuffer in any size
  21.202 +       it chooses.  SDL will scale the framebuffer to the native
  21.203 +       screen size on the GPU (via SDL_UpdateWindowSurface).
  21.204 +    */
  21.205 +    _this->displays[0].fullscreen_window = window;
  21.206 +
  21.207 +    /* Further prevent any display resizing, and make sure SDL_GetWindowDisplayMode
  21.208 +       can report the correct size of windows, by creating a new display
  21.209 +       mode in the requested size.  To note, if the window is being created in
  21.210 +       the device's native screen size, SDL_AddDisplayMode will do nothing.
  21.211 +    */
  21.212 +    window->fullscreen_mode = SDL_WinRTGlobalApp->GetMainDisplayMode();
  21.213 +    window->fullscreen_mode.w = window->w;
  21.214 +    window->fullscreen_mode.h = window->h;
  21.215 +    SDL_AddDisplayMode(&_this->displays[0], &window->fullscreen_mode);
  21.216 +
  21.217 +    /* TODO: Consider removing custom display modes in WINRT_DestroyWindow. */
  21.218 + 
  21.219 +    /* Make sure the WinRT app's IFramworkView can post events on
  21.220 +       behalf of SDL:
  21.221 +    */
  21.222 +    SDL_WinRTGlobalApp->SetSDLWindowData(data);
  21.223 +
  21.224 +    /* All done! */
  21.225 +    return 0;
  21.226 +}
  21.227 +
  21.228 +void
  21.229 +WINRT_DestroyWindow(_THIS, SDL_Window * window)
  21.230 +{
  21.231 +    SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
  21.232 +
  21.233 +    if (SDL_WinRTGlobalApp->HasSDLWindowData() &&
  21.234 +        SDL_WinRTGlobalApp->GetSDLWindowData()->sdlWindow == window)
  21.235 +    {
  21.236 +        SDL_WinRTGlobalApp->SetSDLWindowData(NULL);
  21.237 +    }
  21.238 +
  21.239 +    if (data) {
  21.240 +        // Delete the internal window data:
  21.241 +        delete data;
  21.242 +        data = NULL;
  21.243 +    }
  21.244 +}
  21.245 +
  21.246 +SDL_bool
  21.247 +WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
  21.248 +{
  21.249 +    SDL_WindowData * data = (SDL_WindowData *) window->driverdata;
  21.250 +
  21.251 +    if (info->version.major <= SDL_MAJOR_VERSION) {
  21.252 +        info->subsystem = SDL_SYSWM_WINDOWSRT;
  21.253 +        info->info.winrt.window = reinterpret_cast<IUnknown *>(data->coreWindow.Get());
  21.254 +        return SDL_TRUE;
  21.255 +    } else {
  21.256 +        SDL_SetError("Application not compiled with SDL %d.%d\n",
  21.257 +                     SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
  21.258 +        return SDL_FALSE;
  21.259 +    }
  21.260 +    return SDL_FALSE;
  21.261 +}
  21.262 +
  21.263 +#endif /* SDL_VIDEO_DRIVER_WINRT */
  21.264 +
  21.265 +/* vi: set ts=4 sw=4 expandtab: */
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/src/video/winrt/SDL_winrtvideo.h	Tue Aug 20 21:22:32 2013 -0400
    22.3 @@ -0,0 +1,40 @@
    22.4 +/*
    22.5 +  Simple DirectMedia Layer
    22.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
    22.7 +
    22.8 +  This software is provided 'as-is', without any express or implied
    22.9 +  warranty.  In no event will the authors be held liable for any damages
   22.10 +  arising from the use of this software.
   22.11 +
   22.12 +  Permission is granted to anyone to use this software for any purpose,
   22.13 +  including commercial applications, and to alter it and redistribute it
   22.14 +  freely, subject to the following restrictions:
   22.15 +
   22.16 +  1. The origin of this software must not be misrepresented; you must not
   22.17 +     claim that you wrote the original software. If you use this software
   22.18 +     in a product, an acknowledgment in the product documentation would be
   22.19 +     appreciated but is not required.
   22.20 +  2. Altered source versions must be plainly marked as such, and must not be
   22.21 +     misrepresented as being the original software.
   22.22 +  3. This notice may not be removed or altered from any source distribution.
   22.23 +*/
   22.24 +#include "SDL_config.h"
   22.25 +
   22.26 +#ifndef _SDL_winrtvideo_h
   22.27 +#define _SDL_winrtvideo_h
   22.28 +
   22.29 +extern "C" {
   22.30 +#include "../SDL_sysvideo.h"
   22.31 +}
   22.32 +
   22.33 +#include <agile.h>
   22.34 +
   22.35 +struct SDL_WindowData
   22.36 +{
   22.37 +    SDL_Window *sdlWindow;
   22.38 +    Platform::Agile<Windows::UI::Core::CoreWindow> coreWindow;
   22.39 +};
   22.40 +
   22.41 +#endif /* _SDL_winrtvideo_h */
   22.42 +
   22.43 +/* vi: set ts=4 sw=4 expandtab: */