diff --git a/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj b/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj
new file mode 100644
index 000000000..4eaeca36b
--- /dev/null
+++ b/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj
@@ -0,0 +1,404 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ ARM
+
+
+ Release
+ Win32
+
+
+ Release
+ ARM
+
+
+
+ {33048af1-031a-4ce6-b61e-fad2db832e9e}
+ SDL
+ en-US
+ 11.0
+ SDL-WinPhone
+
+
+
+ DynamicLibrary
+ true
+ v110_wp80
+ false
+
+
+ DynamicLibrary
+ true
+ v110_wp80
+ false
+
+
+ DynamicLibrary
+ false
+ true
+ v110_wp80
+ false
+
+
+ DynamicLibrary
+ false
+ true
+ v110_wp80
+ false
+
+
+
+
+
+
+
+ false
+
+
+
+ _USRDLL;UNICODE;%(PreprocessorDefinitions)
+ NotUsing
+ pch.h
+ false
+ $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)
+ ..\..\include
+ false
+
+
+ Console
+ false
+ false
+ true
+ d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)
+
+
+
+
+ _USRDLL;UNICODE;NDEBUG;%(PreprocessorDefinitions)
+ NotUsing
+ pch.h
+ false
+ $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)
+ ..\..\include
+
+
+ Console
+ false
+ false
+ true
+ d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)
+
+
+
+
+ _USRDLL;UNICODE;%(PreprocessorDefinitions)
+ NotUsing
+ pch.h
+ false
+ $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)
+ ..\..\include
+ false
+
+
+ Console
+ false
+ false
+ true
+ d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)
+
+
+
+
+ _USRDLL;UNICODE;NDEBUG;%(PreprocessorDefinitions)
+ NotUsing
+ pch.h
+ false
+ $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)
+ ..\..\include
+
+
+ Console
+ false
+ false
+ true
+ d3d11.lib;xaudio2.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)
+
+
+
+
+ true
+
+
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ true
+
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj.filters b/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj.filters
new file mode 100644
index 000000000..9535fe759
--- /dev/null
+++ b/VisualC-WinPhone/SDL/SDL-WinPhone_VS2012.vcxproj.filters
@@ -0,0 +1,612 @@
+
+
+
+
+ {02b21b9a-45a7-41ee-a8a6-e45d14aa28da}
+
+
+ {abc3a7e6-f955-4cb5-8340-fae0f653e9c1}
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
\ No newline at end of file
diff --git a/VisualC-WinRT/SDL-WinRT_VS2012.sln b/VisualC-WinRT/SDL-WinRT_VS2012.sln
new file mode 100644
index 000000000..921cebd6d
--- /dev/null
+++ b/VisualC-WinRT/SDL-WinRT_VS2012.sln
@@ -0,0 +1,32 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL-WinRT", "SDL\SDL-WinRT_VS2012.vcxproj", "{AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM = Debug|ARM
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|ARM = Release|ARM
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|ARM.ActiveCfg = Debug|ARM
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|ARM.Build.0 = Debug|ARM
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|Win32.ActiveCfg = Debug|Win32
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|Win32.Build.0 = Debug|Win32
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|x64.ActiveCfg = Debug|x64
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Debug|x64.Build.0 = Debug|x64
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|ARM.ActiveCfg = Release|ARM
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|ARM.Build.0 = Release|ARM
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|Win32.ActiveCfg = Release|Win32
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|Win32.Build.0 = Release|Win32
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|x64.ActiveCfg = Release|x64
+ {AEAEA3A2-D4E6-45B1-8EC6-53D84287FC14}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj
new file mode 100644
index 000000000..a63bbc8cd
--- /dev/null
+++ b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj
@@ -0,0 +1,508 @@
+
+
+
+
+ Debug
+ ARM
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ ARM
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}
+ Win32Proj
+ SDL-WinRT
+ SDL_VS2012_WinRT
+ en-US
+ 11.0
+ true
+
+
+
+ DynamicLibrary
+ true
+ v110
+
+
+ DynamicLibrary
+ true
+ v110
+
+
+ DynamicLibrary
+ true
+ v110
+
+
+ DynamicLibrary
+ false
+ true
+ v110
+
+
+ DynamicLibrary
+ false
+ true
+ v110
+
+
+ DynamicLibrary
+ false
+ true
+ v110
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+ false
+ SDL
+
+
+ false
+ false
+ SDL
+
+
+ false
+ false
+ SDL
+
+
+ false
+ false
+ SDL
+
+
+ false
+ false
+ SDL
+
+
+ false
+ false
+ SDL
+
+
+
+ NotUsing
+ false
+ ..\..\include;%(AdditionalIncludeDirectories)
+ _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+ xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)
+
+
+
+
+ NotUsing
+ false
+ ..\..\include;%(AdditionalIncludeDirectories)
+ _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+ xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)
+
+
+
+
+ NotUsing
+ false
+ ..\..\include;%(AdditionalIncludeDirectories)
+ _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+ xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)
+
+
+
+
+ NotUsing
+ false
+ ..\..\include;%(AdditionalIncludeDirectories)
+ _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+ xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)
+
+
+
+
+ NotUsing
+ false
+ ..\..\include;%(AdditionalIncludeDirectories)
+ _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+ xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)
+
+
+
+
+ NotUsing
+ false
+ ..\..\include;%(AdditionalIncludeDirectories)
+ _WINDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+ xinput.lib;xaudio2.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies)
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters
new file mode 100644
index 000000000..21ec9bb9d
--- /dev/null
+++ b/VisualC-WinRT/SDL/SDL-WinRT_VS2012.vcxproj.filters
@@ -0,0 +1,645 @@
+
+
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Source Files
+
+
+ Source Files
+
+
+
+
+ {20773b57-7034-4c24-af5a-334844585f1b}
+
+
+ {ddf04d85-6a87-4c5a-bc52-869b38f45a61}
+
+
+
\ No newline at end of file
diff --git a/VisualC-WinRT/tests/loopwave/Assets/Logo.png b/VisualC-WinRT/tests/loopwave/Assets/Logo.png
new file mode 100644
index 000000000..e26771cb3
Binary files /dev/null and b/VisualC-WinRT/tests/loopwave/Assets/Logo.png differ
diff --git a/VisualC-WinRT/tests/loopwave/Assets/SmallLogo.png b/VisualC-WinRT/tests/loopwave/Assets/SmallLogo.png
new file mode 100644
index 000000000..1eb0d9d52
Binary files /dev/null and b/VisualC-WinRT/tests/loopwave/Assets/SmallLogo.png differ
diff --git a/VisualC-WinRT/tests/loopwave/Assets/SplashScreen.png b/VisualC-WinRT/tests/loopwave/Assets/SplashScreen.png
new file mode 100644
index 000000000..c951e031b
Binary files /dev/null and b/VisualC-WinRT/tests/loopwave/Assets/SplashScreen.png differ
diff --git a/VisualC-WinRT/tests/loopwave/Assets/StoreLogo.png b/VisualC-WinRT/tests/loopwave/Assets/StoreLogo.png
new file mode 100644
index 000000000..dcb672712
Binary files /dev/null and b/VisualC-WinRT/tests/loopwave/Assets/StoreLogo.png differ
diff --git a/VisualC-WinRT/tests/loopwave/Package.appxmanifest b/VisualC-WinRT/tests/loopwave/Package.appxmanifest
new file mode 100644
index 000000000..3b62bf1b1
--- /dev/null
+++ b/VisualC-WinRT/tests/loopwave/Package.appxmanifest
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+ loopwave_VS2012_WinRT
+ David
+ Assets\StoreLogo.png
+
+
+
+ 6.2.1
+ 6.2.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualC-WinRT/tests/loopwave/loopwave_VS2012.vcxproj b/VisualC-WinRT/tests/loopwave/loopwave_VS2012.vcxproj
new file mode 100644
index 000000000..bd1750942
--- /dev/null
+++ b/VisualC-WinRT/tests/loopwave/loopwave_VS2012.vcxproj
@@ -0,0 +1,170 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+ Debug
+ ARM
+
+
+ Release
+ ARM
+
+
+
+ {03fcc293-9406-49c2-acf6-6e7d460c3239}
+ loopwave_VS2012
+ en-US
+ 11.0
+ true
+ loopwave
+
+
+
+ Application
+ true
+ v110
+
+
+ Application
+ true
+ v110
+
+
+ Application
+ true
+ v110
+
+
+ Application
+ false
+ true
+ v110
+
+
+ Application
+ false
+ true
+ v110
+
+
+ Application
+ false
+ true
+ v110
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ loopwave_VS2012_TemporaryKey.pfx
+
+
+
+ d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies)
+
+
+ pch.h
+ $(IntDir)pch.pch
+ $(ProjectDir);$(IntermediateOutputPath);$(ProjectDir)..\..\..\include;%(AdditionalIncludeDirectories)
+ 4453
+
+
+
+
+ NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ NotUsing
+ NotUsing
+ NotUsing
+ false
+ false
+ false
+
+
+
+
+ _DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ NotUsing
+ NotUsing
+ NotUsing
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+ Designer
+
+
+
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+ false
+ false
+ false
+ false
+ false
+ false
+
+
+
+
+
+
+
+ {aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualC-WinRT/tests/loopwave/loopwave_VS2012_TemporaryKey.pfx b/VisualC-WinRT/tests/loopwave/loopwave_VS2012_TemporaryKey.pfx
new file mode 100644
index 000000000..3c07b779f
Binary files /dev/null and b/VisualC-WinRT/tests/loopwave/loopwave_VS2012_TemporaryKey.pfx differ
diff --git a/VisualC-WinRT/tests/testthread/Assets/Logo.png b/VisualC-WinRT/tests/testthread/Assets/Logo.png
new file mode 100644
index 000000000..e26771cb3
Binary files /dev/null and b/VisualC-WinRT/tests/testthread/Assets/Logo.png differ
diff --git a/VisualC-WinRT/tests/testthread/Assets/SmallLogo.png b/VisualC-WinRT/tests/testthread/Assets/SmallLogo.png
new file mode 100644
index 000000000..1eb0d9d52
Binary files /dev/null and b/VisualC-WinRT/tests/testthread/Assets/SmallLogo.png differ
diff --git a/VisualC-WinRT/tests/testthread/Assets/SplashScreen.png b/VisualC-WinRT/tests/testthread/Assets/SplashScreen.png
new file mode 100644
index 000000000..c951e031b
Binary files /dev/null and b/VisualC-WinRT/tests/testthread/Assets/SplashScreen.png differ
diff --git a/VisualC-WinRT/tests/testthread/Assets/StoreLogo.png b/VisualC-WinRT/tests/testthread/Assets/StoreLogo.png
new file mode 100644
index 000000000..dcb672712
Binary files /dev/null and b/VisualC-WinRT/tests/testthread/Assets/StoreLogo.png differ
diff --git a/VisualC-WinRT/tests/testthread/Package.appxmanifest b/VisualC-WinRT/tests/testthread/Package.appxmanifest
new file mode 100644
index 000000000..f02b3a173
--- /dev/null
+++ b/VisualC-WinRT/tests/testthread/Package.appxmanifest
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+ testthread_VS2012_WinRT
+ David
+ Assets\StoreLogo.png
+
+
+
+ 6.2.1
+ 6.2.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualC-WinRT/tests/testthread/testthread_VS2012.vcxproj b/VisualC-WinRT/tests/testthread/testthread_VS2012.vcxproj
new file mode 100644
index 000000000..eb2558fa4
--- /dev/null
+++ b/VisualC-WinRT/tests/testthread/testthread_VS2012.vcxproj
@@ -0,0 +1,160 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+ Debug
+ ARM
+
+
+ Release
+ ARM
+
+
+
+ {a8705bee-d01d-46a4-b2ab-feedfb5fdd11}
+ testthread_VS2012
+ en-US
+ 11.0
+ true
+ testthread
+
+
+
+ Application
+ true
+ v110
+
+
+ Application
+ true
+ v110
+
+
+ Application
+ true
+ v110
+
+
+ Application
+ false
+ true
+ v110
+
+
+ Application
+ false
+ true
+ v110
+
+
+ Application
+ false
+ true
+ v110
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ testthread_VS2012_TemporaryKey.pfx
+
+
+
+ d2d1.lib; d3d11.lib; dxgi.lib; ole32.lib; windowscodecs.lib; dwrite.lib; %(AdditionalDependencies)
+
+
+ pch.h
+ $(IntDir)pch.pch
+ $(ProjectDir);$(IntermediateOutputPath);$(ProjectDir)..\..\..\include;%(AdditionalIncludeDirectories)
+ 4453
+
+
+
+
+ NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ NotUsing
+ NotUsing
+ NotUsing
+ false
+ false
+ false
+
+
+
+
+ _DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ NotUsing
+ NotUsing
+ NotUsing
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+ Designer
+
+
+
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
+
+
+ {aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualC-WinRT/tests/testthread/testthread_VS2012_TemporaryKey.pfx b/VisualC-WinRT/tests/testthread/testthread_VS2012_TemporaryKey.pfx
new file mode 100644
index 000000000..97fd1e190
Binary files /dev/null and b/VisualC-WinRT/tests/testthread/testthread_VS2012_TemporaryKey.pfx differ
diff --git a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
index 8541fa343..c4b95a36c 100755
--- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
@@ -561,6 +561,7 @@
);
name = CustomTemplate;
sourceTree = "";
+ usesTabs = 0;
};
56A6702F18565E4F0007D20F /* dynapi */ = {
isa = PBXGroup;
diff --git a/include/SDL_config.h b/include/SDL_config.h
index d46573ba4..9a2e51c55 100644
--- a/include/SDL_config.h
+++ b/include/SDL_config.h
@@ -33,6 +33,8 @@
#include "SDL_config_premake.h"
#elif defined(__WIN32__)
#include "SDL_config_windows.h"
+#elif defined(__WINRT__)
+#include "SDL_config_winrt.h"
#elif defined(__MACOSX__)
#include "SDL_config_macosx.h"
#elif defined(__IPHONEOS__)
diff --git a/include/SDL_config_winrt.h b/include/SDL_config_winrt.h
new file mode 100644
index 000000000..2d9258132
--- /dev/null
+++ b/include/SDL_config_winrt.h
@@ -0,0 +1,191 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef _SDL_config_windows_h
+#define _SDL_config_windows_h
+
+#include "SDL_platform.h"
+
+/* This is a set of defines to configure the SDL features */
+
+#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H)
+#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
+#define HAVE_STDINT_H 1
+#elif defined(_MSC_VER)
+typedef signed __int8 int8_t;
+typedef unsigned __int8 uint8_t;
+typedef signed __int16 int16_t;
+typedef unsigned __int16 uint16_t;
+typedef signed __int32 int32_t;
+typedef unsigned __int32 uint32_t;
+typedef signed __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#ifndef _UINTPTR_T_DEFINED
+#ifdef _WIN64
+typedef unsigned __int64 uintptr_t;
+#else
+typedef unsigned int uintptr_t;
+#endif
+#define _UINTPTR_T_DEFINED
+#endif
+/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
+#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
+#define DWORD_PTR DWORD
+#endif
+#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
+#define LONG_PTR LONG
+#endif
+#else /* !__GNUC__ && !_MSC_VER */
+typedef signed char int8_t;
+typedef unsigned char uint8_t;
+typedef signed short int16_t;
+typedef unsigned short uint16_t;
+typedef signed int int32_t;
+typedef unsigned int uint32_t;
+typedef signed long long int64_t;
+typedef unsigned long long uint64_t;
+#ifndef _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED_
+typedef unsigned int size_t;
+#endif
+typedef unsigned int uintptr_t;
+#endif /* __GNUC__ || _MSC_VER */
+#endif /* !_STDINT_H_ && !HAVE_STDINT_H */
+
+#ifdef _WIN64
+# define SIZEOF_VOIDP 8
+#else
+# define SIZEOF_VOIDP 4
+#endif
+
+/* Useful headers */
+#define HAVE_LIBC 1
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS 1
+#define HAVE_STRING_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_MATH_H 1
+#define HAVE_FLOAT_H 1
+#define HAVE_SIGNAL_H 1
+
+/* C library functions */
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#define HAVE_ALLOCA 1
+#define HAVE_QSORT 1
+#define HAVE_ABS 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_STRLEN 1
+#define HAVE__STRREV 1
+#define HAVE__STRUPR 1
+//#define HAVE__STRLWR 1 // TODO, WinRT: consider using _strlwr_s instead
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRSTR 1
+//#define HAVE_ITOA 1 // TODO, WinRT: consider using _itoa_s instead
+//#define HAVE__LTOA 1 // TODO, WinRT: consider using _ltoa_s instead
+//#define HAVE__ULTOA 1 // TODO, WinRT: consider using _ultoa_s instead
+#define HAVE_STRTOL 1
+#define HAVE_STRTOUL 1
+//#define HAVE_STRTOLL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+#define HAVE__STRICMP 1
+#define HAVE__STRNICMP 1
+#define HAVE_VSNPRINTF 1
+//#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead
+#define HAVE_M_PI 1
+#define HAVE_ATAN 1
+#define HAVE_ATAN2 1
+#define HAVE_CEIL 1
+#define HAVE__COPYSIGN 1
+#define HAVE_COS 1
+#define HAVE_COSF 1
+#define HAVE_FABS 1
+#define HAVE_FLOOR 1
+#define HAVE_LOG 1
+#define HAVE_POW 1
+//#define HAVE_SCALBN 1
+#define HAVE__SCALB 1
+#define HAVE_SIN 1
+#define HAVE_SINF 1
+#define HAVE_SQRT 1
+#define HAVE__FSEEKI64 1
+
+/* Enable various audio drivers */
+#define SDL_AUDIO_DRIVER_XAUDIO2 1
+#define SDL_AUDIO_DRIVER_DISK 1
+#define SDL_AUDIO_DRIVER_DUMMY 1
+
+/* Enable various input drivers */
+// TODO, WinRT: Get haptic support working
+#define SDL_HAPTIC_DISABLED 1
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+#define SDL_JOYSTICK_DISABLED 1
+#else
+#define SDL_JOYSTICK_XINPUT 1
+#endif
+
+/* Enable various shared object loading systems */
+#define SDL_LOADSO_WINDOWS 1
+
+/* Enable various threading systems */
+#define SDL_THREAD_STDCPP 1
+
+/* Enable various timer systems */
+#define SDL_TIMER_WINDOWS 1
+
+/* Enable various video drivers */
+#define SDL_VIDEO_DRIVER_WINRT 1
+#define SDL_VIDEO_DRIVER_DUMMY 1
+
+/* Enable OpenGL ES 2.0 (via a modified ANGLE library) */
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP /* TODO, WinRT: try adding OpenGL ES 2 support for Windows Phone 8 */
+#define SDL_VIDEO_OPENGL_ES2 1
+#define SDL_VIDEO_OPENGL_EGL 1
+#endif
+
+/* Enable appropriate renderer(s) */
+#define SDL_VIDEO_RENDER_D3D11 1
+
+#if SDL_VIDEO_OPENGL_ES2
+#define SDL_VIDEO_RENDER_OGL_ES2 1
+#endif
+
+/* Enable system power support */
+// TODO, WinRT: investigate system power support. The Win32-based APIs don't work on WinRT.
+#define SDL_POWER_DISABLED 1
+
+/* Enable assembly routines (Win64 doesn't have inline asm) */
+#ifndef _WIN64
+#define SDL_ASSEMBLY_ROUTINES 1
+#endif
+
+#endif /* _SDL_config_windows_h */
diff --git a/include/SDL_cpuinfo.h b/include/SDL_cpuinfo.h
index b8eb27855..1f6efd384 100644
--- a/include/SDL_cpuinfo.h
+++ b/include/SDL_cpuinfo.h
@@ -32,7 +32,7 @@
/* Need to do this here because intrin.h has C++ code in it */
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
-#if defined(_MSC_VER) && (_MSC_VER >= 1500)
+#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
#include
#ifndef _WIN64
#define __MMX__
diff --git a/include/SDL_egl.h b/include/SDL_egl.h
index bda7c5046..d312f0425 100644
--- a/include/SDL_egl.h
+++ b/include/SDL_egl.h
@@ -391,9 +391,16 @@ typedef enum {
#endif
#include
+#if __WINRT__
+#include
+typedef IUnknown * EGLNativeWindowType;
+typedef int EGLNativeDisplayType;
+typedef HBITMAP EGLNativePixmapType;
+#else
typedef HDC EGLNativeDisplayType;
typedef HBITMAP EGLNativePixmapType;
typedef HWND EGLNativeWindowType;
+#endif
#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
diff --git a/include/SDL_hints.h b/include/SDL_hints.h
index a7c016208..b98ce6834 100644
--- a/include/SDL_hints.h
+++ b/include/SDL_hints.h
@@ -105,6 +105,19 @@ extern "C" {
*/
#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE"
+/**
+ * \brief A variable controlling whether to enable Direct3D 11+'s Debug Layer.
+ *
+ * This variable does not have any effect on the Direct3D 9 based renderer.
+ *
+ * This variable can be set to the following values:
+ * "0" - Disable Debug Layer use
+ * "1" - Enable Debug Layer use
+ *
+ * By default, SDL does not use Direct3D Debug Layer.
+ */
+#define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_HINT_RENDER_DIRECT3D11_DEBUG"
+
/**
* \brief A variable controlling the scaling quality
*
@@ -334,7 +347,7 @@ extern "C" {
* If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has
* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly
* created SDL_Window:
-
+*
* 1. Its pixel format will be set to the same pixel format as this SDL_Window. This is
* needed for example when sharing an OpenGL context across multiple windows.
*
@@ -347,6 +360,62 @@ extern "C" {
*/
#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"
+/*
+ * \brief A URL to a WinRT app's privacy policy
+ *
+ * All network-enabled WinRT apps must make a privacy policy available to its
+ * users. On Windows 8, 8.1, and RT, Microsoft mandates that this policy be
+ * be available in the Windows Settings charm, as accessed from within the app.
+ * SDL provides code to add a URL-based link there, which can point to the app's
+ * privacy policy.
+ *
+ * To setup a URL to an app's privacy policy, set SDL_HINT_WINRT_PRIVACY_POLICY_URL
+ * before calling any SDL_Init functions. The contents of the hint should
+ * be a valid URL. For example, "http://www.example.com".
+ *
+ * The default value is "", which will prevent SDL from adding a privacy policy
+ * link to the Settings charm. This hint should only be set during app init.
+ *
+ * The label text of an app's "Privacy Policy" link may be customized via another
+ * hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL.
+ *
+ * Please note that on Windows Phone, Microsoft does not provide standard UI
+ * for displaying a privacy policy link, and as such, SDL_HINT_WINRT_PRIVACY_POLICY_URL
+ * will not get used on that platform. Network-enabled phone apps should display
+ * their privacy policy through some other, in-app means.
+ */
+#define SDL_HINT_WINRT_PRIVACY_POLICY_URL "SDL_HINT_WINRT_PRIVACY_POLICY_URL"
+
+/** \brief Label text for a WinRT app's privacy policy link
+ *
+ * Network-enabled WinRT apps must include a privacy policy. On Windows 8, 8.1, and RT,
+ * Microsoft mandates that this policy be available via the Windows Settings charm.
+ * SDL provides code to add a link there, with it's label text being set via the
+ * optional hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL.
+ *
+ * Please note that a privacy policy's contents are not set via this hint. A separate
+ * hint, SDL_HINT_WINRT_PRIVACY_POLICY_URL, is used to link to the actual text of the
+ * policy.
+ *
+ * The contents of this hint should be encoded as a UTF8 string.
+ *
+ * The default value is "Privacy Policy". This hint should only be set during app
+ * initialization, preferably before any calls to SDL_Init.
+ *
+ * For additional information on linking to a privacy policy, see the documentation for
+ * SDL_HINT_WINRT_PRIVACY_POLICY_URL.
+ */
+#define SDL_HINT_WINRT_PRIVACY_POLICY_LABEL "SDL_HINT_WINRT_PRIVACY_POLICY_LABEL"
+
+/** \brief If set to 1, back button press events on Windows Phone 8+ will be marked as handled.
+ *
+ * TODO, WinRT: document SDL_HINT_WINRT_HANDLE_BACK_BUTTON need and use
+ * For now, more details on why this is needed can be found at the
+ * beginning of the following web page:
+ * http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247550(v=vs.105).aspx
+ */
+#define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_HINT_WINRT_HANDLE_BACK_BUTTON"
+
/**
* \brief A variable that dictates policy for fullscreen Spaces on Mac OS X.
*
diff --git a/include/SDL_main.h b/include/SDL_main.h
index 1f2bad3fb..2e8fae95e 100644
--- a/include/SDL_main.h
+++ b/include/SDL_main.h
@@ -39,6 +39,18 @@
*/
#define SDL_MAIN_AVAILABLE
+#elif defined(__WINRT__)
+/* On WinRT, SDL provides a main function that initializes CoreApplication,
+ creating an instance of IFrameworkView in the process.
+
+ Please note that #include'ing SDL_main.h is not enough to get a main()
+ function working. In non-XAML apps, the file,
+ src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled
+ into the app itself. In XAML apps, the function, SDL_WinRTRunApp must be
+ called, with a pointer to the Direct3D-hosted XAML control passed in.
+*/
+#define SDL_MAIN_NEEDED
+
#elif defined(__IPHONEOS__)
/* On iOS SDL provides a main function that creates an application delegate
and starts the iOS application run loop.
@@ -115,6 +127,24 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
#endif /* __WIN32__ */
+#ifdef __WINRT__
+
+/**
+ * \brief Initializes and launches an SDL/WinRT application.
+ *
+ * \param mainFunction The SDL app's C-style main().
+ * \param xamlBackgroundPanel An optional, XAML-based, background panel.
+ * For Non-XAML apps, this value must be set to NULL. For XAML apps,
+ * pass in a pointer to a SwapChainBackgroundPanel, casted to an
+ * IInspectable (via reinterpret_cast).
+ * \ret 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more
+ * information on the failure.
+ */
+extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel);
+
+#endif /* __WINRT__ */
+
+
#ifdef __cplusplus
}
#endif
diff --git a/include/SDL_platform.h b/include/SDL_platform.h
index afe338913..ace93a427 100644
--- a/include/SDL_platform.h
+++ b/include/SDL_platform.h
@@ -113,10 +113,27 @@
#undef __SOLARIS__
#define __SOLARIS__ 1
#endif
+
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
+/* Try to find out if we're compiling for WinRT or non-WinRT */
+#if defined(_MSC_VER) && (_MSC_VER >= 1700) /* _MSC_VER==1700 for MSVC 2012 */
+#include
+#endif /* _MSC_VER >= 1700 */
+/* Default to classic, Win32/Win64/Desktop compilation either if:
+ 1. the version of Windows is explicity set to a 'Desktop' (non-Metro) app
+ 2. the version of Windows cannot be determined via winapifamily.h
+ If neither is true, then see if we're compiling for WinRT.
+ */
+#if ! defined(WINAPI_FAMILY_PARTITION) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#undef __WINDOWS__
#define __WINDOWS__ 1
-#endif
+/* See if we're compiling for WinRT: */
+#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+#undef __WINRT__
+#define __WINRT__ 1
+#endif /* ! defined(WINAPI_FAMILY_PARTITION) */
+#endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */
+
#if defined(__WINDOWS__)
#undef __WIN32__
#define __WIN32__ 1
diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h
index 6de724e9a..31b343d30 100644
--- a/include/SDL_stdinc.h
+++ b/include/SDL_stdinc.h
@@ -71,8 +71,18 @@
# include
#endif
#ifdef HAVE_MATH_H
+# if defined(__WINRT__)
+/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on
+ WinRT. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
+ for more information.
+*/
+# define _USE_MATH_DEFINES
+# endif
# include
#endif
+#ifdef HAVE_FLOAT_H
+# include
+#endif
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
# include
#endif
diff --git a/include/SDL_system.h b/include/SDL_system.h
index 99ef8223e..fd929f7f9 100644
--- a/include/SDL_system.h
+++ b/include/SDL_system.h
@@ -116,6 +116,70 @@ extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath();
#endif /* __ANDROID__ */
+/* Platform specific functions for WinRT */
+#if defined(__WINRT__) && __WINRT__
+
+/**
+ * \brief WinRT / Windows Phone path types
+ */
+typedef enum
+{
+ /** \brief The installed app's root directory.
+ Files here are likely to be read-only. */
+ SDL_WINRT_PATH_INSTALLED_LOCATION,
+
+ /** \brief The app's local data store. Files may be written here */
+ SDL_WINRT_PATH_LOCAL_FOLDER,
+
+ /** \brief The app's roaming data store. Unsupported on Windows Phone.
+ Files written here may be copied to other machines via a network
+ connection.
+ */
+ SDL_WINRT_PATH_ROAMING_FOLDER,
+
+ /** \brief The app's temporary data store. Unsupported on Windows Phone.
+ Files written here may be deleted at any time. */
+ SDL_WINRT_PATH_TEMP_FOLDER
+} SDL_WinRT_Path;
+
+
+/**
+ * \brief Retrieves a WinRT defined path on the local file system
+ *
+ * \note Documentation on most app-specific path types on WinRT
+ * can be found on MSDN, at the URL:
+ * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
+ *
+ * \param pathType The type of path to retrieve.
+ * \ret A UCS-2 string (16-bit, wide-char) containing the path, or NULL
+ * if the path is not available for any reason. Not all paths are
+ * available on all versions of Windows. This is especially true on
+ * Windows Phone. Check the documentation for the given
+ * SDL_WinRT_Path for more information on which path types are
+ * supported where.
+ */
+extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType);
+
+/**
+ * \brief Retrieves a WinRT defined path on the local file system
+ *
+ * \note Documentation on most app-specific path types on WinRT
+ * can be found on MSDN, at the URL:
+ * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
+ *
+ * \param pathType The type of path to retrieve.
+ * \ret A UTF-8 string (8-bit, multi-byte) containing the path, or NULL
+ * if the path is not available for any reason. Not all paths are
+ * available on all versions of Windows. This is especially true on
+ * Windows Phone. Check the documentation for the given
+ * SDL_WinRT_Path for more information on which path types are
+ * supported where.
+ */
+extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
+
+#endif /* __WINRT__ */
+
+
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h
index 40e8ca7c6..857fc75a4 100644
--- a/include/SDL_syswm.h
+++ b/include/SDL_syswm.h
@@ -56,6 +56,10 @@ struct SDL_SysWMinfo;
#include
#endif
+#if defined(SDL_VIDEO_DRIVER_WINRT)
+#include
+#endif
+
/* This is the structure for custom window manager events */
#if defined(SDL_VIDEO_DRIVER_X11)
#if defined(__APPLE__) && defined(__MACH__)
@@ -90,6 +94,7 @@ typedef struct _NSWindow NSWindow;
#include
#else
typedef struct _UIWindow UIWindow;
+typedef struct _UIViewController UIViewController;
#endif
#endif
@@ -105,6 +110,7 @@ typedef enum
{
SDL_SYSWM_UNKNOWN,
SDL_SYSWM_WINDOWS,
+ SDL_SYSWM_WINRT,
SDL_SYSWM_X11,
SDL_SYSWM_DIRECTFB,
SDL_SYSWM_COCOA,
@@ -175,6 +181,12 @@ struct SDL_SysWMinfo
HWND window; /**< The window handle */
} win;
#endif
+#if defined(SDL_VIDEO_DRIVER_WINRT)
+ struct
+ {
+ IInspectable * window; /**< The WinRT CoreWindow */
+ } winrt;
+#endif
#if defined(SDL_VIDEO_DRIVER_X11)
struct
{
diff --git a/include/begin_code.h b/include/begin_code.h
index fbed7d4a5..f37ee3696 100644
--- a/include/begin_code.h
+++ b/include/begin_code.h
@@ -43,7 +43,7 @@
/* Some compilers use a special export keyword */
#ifndef DECLSPEC
-# if defined(__WIN32__)
+# if defined(__WIN32__) || defined(__WINRT__)
# ifdef __BORLANDC__
# ifdef BUILD_SDL
# define DECLSPEC
@@ -66,7 +66,7 @@
/* By default SDL uses the C calling convention */
#ifndef SDLCALL
-#if defined(__WIN32__) && !defined(__GNUC__)
+#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
#define SDLCALL __cdecl
#else
#define SDLCALL
diff --git a/src/SDL_assert.c b/src/SDL_assert.c
index 6a6bf8361..98e758447 100644
--- a/src/SDL_assert.c
+++ b/src/SDL_assert.c
@@ -39,8 +39,10 @@
#else /* fprintf, _exit(), etc. */
#include
#include
+#if ! defined(__WINRT__)
#include
#endif
+#endif
static SDL_assert_state
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
diff --git a/src/SDL_log.c b/src/SDL_log.c
index 8cd2483cf..39aa3e4bf 100644
--- a/src/SDL_log.c
+++ b/src/SDL_log.c
@@ -20,7 +20,7 @@
*/
#include "./SDL_internal.h"
-#if defined(__WIN32__)
+#if defined(__WIN32__) || defined(__WINRT__)
#include "core/windows/SDL_windows.h"
#endif
@@ -318,13 +318,15 @@ static void
SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
const char *message)
{
-#if defined(__WIN32__)
+#if defined(__WIN32__) || defined(__WINRT__)
/* Way too many allocations here, urgh */
/* Note: One can't call SDL_SetError here, since that function itself logs. */
{
char *output;
size_t length;
LPTSTR tstr;
+
+#ifndef __WINRT__
BOOL attachResult;
DWORD attachError;
unsigned long charsWritten;
@@ -356,6 +358,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
}
}
+#endif /* ifndef __WINRT__ */
length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1;
output = SDL_stack_alloc(char, length);
@@ -365,6 +368,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
/* Output to debugger */
OutputDebugString(tstr);
+#ifndef __WINRT__
/* Screen output to stderr, if console was attached. */
if (consoleAttached == 1) {
if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) {
@@ -374,6 +378,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
OutputDebugString(TEXT("Insufficient heap memory to write message\r\n"));
}
}
+#endif /* ifndef __WINRT__ */
SDL_free(tstr);
SDL_stack_free(output);
diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c
index 5edeb1d73..2d8446dc5 100644
--- a/src/atomic/SDL_spinlock.c
+++ b/src/atomic/SDL_spinlock.c
@@ -20,7 +20,7 @@
*/
#include "../SDL_internal.h"
-#ifdef __WIN32__
+#if defined(__WIN32__) || defined(__WINRT__)
#include "../core/windows/SDL_windows.h"
#endif
diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c
index a2ac16db2..a1a18df6d 100644
--- a/src/audio/xaudio2/SDL_xaudio2.c
+++ b/src/audio/xaudio2/SDL_xaudio2.c
@@ -18,6 +18,32 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
+
+/* WinRT NOTICE:
+
+ A few changes to SDL's XAudio2 backend were warranted by API
+ changes to Windows. Many, but not all of these are documented by Microsoft
+ at:
+ http://blogs.msdn.com/b/chuckw/archive/2012/04/02/xaudio2-and-windows-8-consumer-preview.aspx
+
+ 1. Windows' thread synchronization function, CreateSemaphore, was removed
+ from WinRT. SDL's semaphore API was substituted instead.
+ 2. The method calls, IXAudio2::GetDeviceCount and IXAudio2::GetDeviceDetails
+ were removed from the XAudio2 API. Microsoft is telling developers to
+ use APIs in Windows::Foundation instead.
+ For SDL, the missing methods were reimplemented using the APIs Microsoft
+ said to use.
+ 3. CoInitialize and CoUninitialize are not available in WinRT.
+ These calls were removed, as COM will have been initialized earlier,
+ at least by the call to the WinRT app's main function
+ (aka 'int main(Platform::Array^)). (DLudwig:
+ This was my understanding of how WinRT: the 'main' function uses
+ a tag of [MTAThread], which should initialize COM. My understanding
+ of COM is somewhat limited, and I may be incorrect here.)
+ 4. IXAudio2::CreateMasteringVoice changed its integer-based 'DeviceIndex'
+ argument to a string-based one, 'szDeviceId'. In WinRT, the
+ string-based argument will be used.
+*/
#include "../../SDL_internal.h"
#if SDL_AUDIO_DRIVER_XAUDIO2
@@ -31,6 +57,9 @@
#ifdef __GNUC__
/* The configure script already did any necessary checking */
# define SDL_XAUDIO2_HAS_SDK 1
+#elif defined(__WINRT__)
+/* WinRT always has access to the .the XAudio 2 SDK */
+# define SDL_XAUDIO2_HAS_SDK
#else
/* XAudio2 exists as of the March 2008 DirectX SDK
The XAudio2 implementation available in the Windows 8 SDK targets Windows 8 and newer.
@@ -42,16 +71,36 @@
#else
# define SDL_XAUDIO2_HAS_SDK 1
#endif
-#endif /* __GNUC__ */
+#endif
#ifdef SDL_XAUDIO2_HAS_SDK
+/* Check to see if we're compiling for XAudio 2.8, or higher. */
+#ifdef WINVER
+#if WINVER >= 0x0602 /* Windows 8 SDK or higher? */
+#define SDL_XAUDIO2_WIN8 1
+#endif
+#endif
+
+/* The XAudio header file, when #include'd on WinRT, will only compile in C++
+ files, but not C. A few preprocessor-based hacks are defined below in order
+ to get xaudio2.h to compile in the C/non-C++ file, SDL_xaudio2.c.
+ */
+#ifdef __WINRT__
+#define uuid(x)
+#define DX_BUILD
+#endif
+
#define INITGUID 1
#include
/* Hidden "this" pointer for the audio functions */
#define _THIS SDL_AudioDevice *this
+#ifdef __WINRT__
+#include "SDL_xaudio2_winrthelpers.h"
+#endif
+
/* Fixes bug 1210 where some versions of gcc need named parameters */
#ifdef __GNUC__
#ifdef THIS
@@ -69,7 +118,7 @@ struct SDL_PrivateAudioData
IXAudio2 *ixa2;
IXAudio2SourceVoice *source;
IXAudio2MasteringVoice *mastering;
- HANDLE semaphore;
+ SDL_sem * semaphore;
Uint8 *mixbuf;
int mixlen;
Uint8 *nextbuf;
@@ -114,7 +163,7 @@ VoiceCBOnBufferEnd(THIS_ void *data)
{
/* Just signal the SDL audio thread and get out of XAudio2's way. */
SDL_AudioDevice *this = (SDL_AudioDevice *) data;
- ReleaseSemaphore(this->hidden->semaphore, 1, NULL);
+ SDL_SemPost(this->hidden->semaphore);
}
static void STDMETHODCALLTYPE
@@ -180,7 +229,7 @@ static void
XAUDIO2_WaitDevice(_THIS)
{
if (this->enabled) {
- WaitForSingleObject(this->hidden->semaphore, INFINITE);
+ SDL_SemWait(this->hidden->semaphore);
}
}
@@ -191,10 +240,18 @@ XAUDIO2_WaitDone(_THIS)
XAUDIO2_VOICE_STATE state;
SDL_assert(!this->enabled); /* flag that stops playing. */
IXAudio2SourceVoice_Discontinuity(source);
+#if SDL_XAUDIO2_WIN8
+ IXAudio2SourceVoice_GetState(source, &state, 0);
+#else
IXAudio2SourceVoice_GetState(source, &state);
+#endif
while (state.BuffersQueued > 0) {
- WaitForSingleObject(this->hidden->semaphore, INFINITE);
+ SDL_SemWait(this->hidden->semaphore);
+#if SDL_XAUDIO2_WIN8
+ IXAudio2SourceVoice_GetState(source, &state, 0);
+#else
IXAudio2SourceVoice_GetState(source, &state);
+#endif
}
}
@@ -223,7 +280,7 @@ XAUDIO2_CloseDevice(_THIS)
}
SDL_free(this->hidden->mixbuf);
if (this->hidden->semaphore != NULL) {
- CloseHandle(this->hidden->semaphore);
+ SDL_DestroySemaphore(this->hidden->semaphore);
}
SDL_free(this->hidden);
@@ -240,7 +297,11 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
IXAudio2 *ixa2 = NULL;
IXAudio2SourceVoice *source = NULL;
+#if defined(SDL_XAUDIO2_WIN8)
+ LPCWSTR devId = NULL;
+#else
UINT32 devId = 0; /* 0 == system default device. */
+#endif
static IXAudio2VoiceCallbackVtbl callbacks_vtable = {
VoiceCBOnVoiceProcessPassStart,
@@ -260,6 +321,18 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
return SDL_SetError("XAudio2: XAudio2Create() failed at open.");
}
+ /*
+ XAUDIO2_DEBUG_CONFIGURATION debugConfig;
+ debugConfig.TraceMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS | XAUDIO2_LOG_DETAIL | XAUDIO2_LOG_FUNC_CALLS | XAUDIO2_LOG_TIMING | XAUDIO2_LOG_LOCKS | XAUDIO2_LOG_MEMORY | XAUDIO2_LOG_STREAMING;
+ debugConfig.BreakMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS;
+ debugConfig.LogThreadID = TRUE;
+ debugConfig.LogFileline = TRUE;
+ debugConfig.LogFunctionName = TRUE;
+ debugConfig.LogTiming = TRUE;
+ ixa2->SetDebugConfiguration(&debugConfig);
+ */
+
+#if ! defined(__WINRT__)
if (devname != NULL) {
UINT32 devcount = 0;
UINT32 i = 0;
@@ -288,6 +361,7 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
return SDL_SetError("XAudio2: Requested device not found.");
}
}
+#endif
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
@@ -299,7 +373,7 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
this->hidden->ixa2 = ixa2;
- this->hidden->semaphore = CreateSemaphore(NULL, 1, 2, NULL);
+ this->hidden->semaphore = SDL_CreateSemaphore(1);
if (this->hidden->semaphore == NULL) {
XAUDIO2_CloseDevice(this);
return SDL_SetError("XAudio2: CreateSemaphore() failed!");
@@ -342,9 +416,15 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
stereo output to appropriate surround sound configurations
instead of clamping to 2 channels, even though we'll configure the
Source Voice for whatever number of channels you supply. */
+#if SDL_XAUDIO2_WIN8
+ result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering,
+ XAUDIO2_DEFAULT_CHANNELS,
+ this->spec.freq, 0, devId, NULL, AudioCategory_GameEffects);
+#else
result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering,
XAUDIO2_DEFAULT_CHANNELS,
this->spec.freq, 0, devId, NULL);
+#endif
if (result != S_OK) {
XAUDIO2_CloseDevice(this);
return SDL_SetError("XAudio2: Couldn't create mastering voice");
@@ -363,11 +443,23 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
waveformat.nChannels * (waveformat.wBitsPerSample / 8);
waveformat.nAvgBytesPerSec =
waveformat.nSamplesPerSec * waveformat.nBlockAlign;
+ waveformat.cbSize = sizeof(waveformat);
+#ifdef __WINRT__
+ // DLudwig: for now, make XAudio2 do sample rate conversion, just to
+ // get the loopwave test to work.
+ //
+ // TODO, WinRT: consider removing WinRT-specific source-voice creation code from SDL_xaudio2.c
+ result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat,
+ 0,
+ 1.0f, &callbacks, NULL, NULL);
+#else
result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat,
XAUDIO2_VOICE_NOSRC |
XAUDIO2_VOICE_NOPITCH,
1.0f, &callbacks, NULL, NULL);
+
+#endif
if (result != S_OK) {
XAUDIO2_CloseDevice(this);
return SDL_SetError("XAudio2: Couldn't create source voice");
@@ -393,7 +485,9 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
static void
XAUDIO2_Deinitialize(void)
{
+#if defined(__WIN32__)
WIN_CoUninitialize();
+#endif
}
#endif /* SDL_XAUDIO2_HAS_SDK */
@@ -408,13 +502,18 @@ XAUDIO2_Init(SDL_AudioDriverImpl * impl)
#else
/* XAudio2Create() is a macro that uses COM; we don't load the .dll */
IXAudio2 *ixa2 = NULL;
+#if defined(__WIN32__)
+ // TODO, WinRT: Investigate using CoInitializeEx here
if (FAILED(WIN_CoInitialize())) {
SDL_SetError("XAudio2: CoInitialize() failed");
return 0;
}
+#endif
if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) {
+#if defined(__WIN32__)
WIN_CoUninitialize();
+#endif
SDL_SetError("XAudio2: XAudio2Create() failed at initialization");
return 0; /* not available. */
}
diff --git a/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp b/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
new file mode 100644
index 000000000..b27ee59b6
--- /dev/null
+++ b/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
@@ -0,0 +1,69 @@
+
+#include
+#include "SDL_xaudio2_winrthelpers.h"
+
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+using Windows::Devices::Enumeration::DeviceClass;
+using Windows::Devices::Enumeration::DeviceInformation;
+using Windows::Devices::Enumeration::DeviceInformationCollection;
+#endif
+
+extern "C" HRESULT __cdecl IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount)
+{
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ // There doesn't seem to be any audio device enumeration on Windows Phone.
+ // In lieu of this, just treat things as if there is one and only one
+ // audio device.
+ *devcount = 1;
+ return S_OK;
+#else
+ // TODO, WinRT: make xaudio2 device enumeration only happen once, and in the background
+ auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
+ while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
+ {
+ }
+
+ DeviceInformationCollection^ devices = operation->GetResults();
+ *devcount = devices->Size;
+ return S_OK;
+#endif
+}
+
+extern "C" HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details)
+{
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ // Windows Phone doesn't seem to have the same device enumeration APIs that
+ // Windows 8/RT has, or it doesn't have them at all. In lieu of this,
+ // just treat things as if there is one, and only one, default device.
+ if (index != 0)
+ {
+ return XAUDIO2_E_INVALID_CALL;
+ }
+
+ if (details)
+ {
+ wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), L"default", _TRUNCATE);
+ wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), L"default", _TRUNCATE);
+ }
+ return S_OK;
+#else
+ auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
+ while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
+ {
+ }
+
+ DeviceInformationCollection^ devices = operation->GetResults();
+ if (index >= devices->Size)
+ {
+ return XAUDIO2_E_INVALID_CALL;
+ }
+
+ DeviceInformation^ d = devices->GetAt(index);
+ if (details)
+ {
+ wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), d->Id->Data(), _TRUNCATE);
+ wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE);
+ }
+ return S_OK;
+#endif
+}
diff --git a/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h b/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h
new file mode 100644
index 000000000..0beaf8d1f
--- /dev/null
+++ b/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h
@@ -0,0 +1,52 @@
+
+#pragma once
+
+//
+// Re-implementation of methods removed from XAudio2 (in WinRT):
+//
+
+typedef struct XAUDIO2_DEVICE_DETAILS
+{
+ WCHAR DeviceID[256];
+ WCHAR DisplayName[256];
+ /* Other fields exist in the pre-Windows 8 version of this struct, however
+ they weren't used by SDL, so they weren't added.
+ */
+} XAUDIO2_DEVICE_DETAILS;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+HRESULT IXAudio2_GetDeviceCount(IXAudio2 * unused, UINT32 * devcount);
+HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+//
+// C-style macros to call XAudio2's methods in C++:
+//
+#ifdef __cplusplus
+/*
+#define IXAudio2_CreateMasteringVoice(A, B, C, D, E, F, G) (A)->CreateMasteringVoice((B), (C), (D), (E), (F), (G))
+#define IXAudio2_CreateSourceVoice(A, B, C, D, E, F, G, H) (A)->CreateSourceVoice((B), (C), (D), (E), (F), (G), (H))
+#define IXAudio2_QueryInterface(A, B, C) (A)->QueryInterface((B), (C))
+#define IXAudio2_Release(A) (A)->Release()
+#define IXAudio2_StartEngine(A) (A)->StartEngine()
+#define IXAudio2_StopEngine(A) (A)->StopEngine()
+
+#define IXAudio2MasteringVoice_DestroyVoice(A) (A)->DestroyVoice()
+
+#define IXAudio2SourceVoice_DestroyVoice(A) (A)->DestroyVoice()
+#define IXAudio2SourceVoice_Discontinuity(A) (A)->Discontinuity()
+#define IXAudio2SourceVoice_FlushSourceBuffers(A) (A)->FlushSourceBuffers()
+#define IXAudio2SourceVoice_GetState(A, B) (A)->GetState((B))
+#define IXAudio2SourceVoice_Start(A, B, C) (A)->Start((B), (C))
+#define IXAudio2SourceVoice_Stop(A, B, C) (A)->Stop((B), (C))
+#define IXAudio2SourceVoice_SubmitSourceBuffer(A, B, C) (A)->SubmitSourceBuffer((B), (C))
+*/
+#endif // ifdef __cplusplus
diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c
index 25a1c4f25..16934d5e1 100644
--- a/src/core/windows/SDL_windows.c
+++ b/src/core/windows/SDL_windows.c
@@ -20,21 +20,21 @@
*/
#include "../../SDL_internal.h"
-#ifdef __WIN32__
+#if defined(__WIN32__) || defined(__WINRT__)
#include "SDL_windows.h"
#include "SDL_error.h"
#include "SDL_assert.h"
-#include /* for CoInitialize/CoUninitialize */
+#include /* for CoInitialize/CoUninitialize (Win32 only) */
/* Sets an error message based on GetLastError() */
int
-WIN_SetError(const char *prefix)
+WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
{
TCHAR buffer[1024];
char *message;
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0,
buffer, SDL_arraysize(buffer), NULL);
message = WIN_StringToUTF8(buffer);
SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
@@ -42,6 +42,13 @@ WIN_SetError(const char *prefix)
return -1;
}
+/* Sets an error message based on GetLastError() */
+int
+WIN_SetError(const char *prefix)
+{
+ return WIN_SetErrorFromHRESULT(prefix, GetLastError());
+}
+
HRESULT
WIN_CoInitialize(void)
{
@@ -50,6 +57,14 @@ WIN_CoInitialize(void)
If you need multi-threaded mode, call CoInitializeEx() before SDL_Init()
*/
+#ifdef __WINRT__
+ /* DLudwig: On WinRT, it is assumed that COM was initialized in main().
+ CoInitializeEx is available (not CoInitialize though), however
+ on WinRT, main() is typically declared with the [MTAThread]
+ attribute, which, AFAIK, should initialize COM.
+ */
+ return S_OK;
+#else
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (hr == RPC_E_CHANGED_MODE) {
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
@@ -62,12 +77,15 @@ WIN_CoInitialize(void)
}
return hr;
+#endif
}
void
WIN_CoUninitialize(void)
{
+#ifndef __WINRT__
CoUninitialize();
+#endif
}
#endif /* __WIN32__ */
diff --git a/src/core/windows/SDL_windows.h b/src/core/windows/SDL_windows.h
index 4a24111a4..45c9d7347 100644
--- a/src/core/windows/SDL_windows.h
+++ b/src/core/windows/SDL_windows.h
@@ -24,6 +24,7 @@
#ifndef _INCLUDED_WINDOWS_H
#define _INCLUDED_WINDOWS_H
+#if defined(__WIN32__)
#define WIN32_LEAN_AND_MEAN
#define STRICT
#ifndef UNICODE
@@ -31,6 +32,7 @@
#endif
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
+#endif
#include
@@ -44,6 +46,9 @@
#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1)
#endif
+/* Sets an error message based on a given HRESULT */
+extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr);
+
/* Sets an error message based on GetLastError(). Always return -1. */
extern int WIN_SetError(const char *prefix);
diff --git a/src/core/winrt/SDL_winrtapp_common.cpp b/src/core/winrt/SDL_winrtapp_common.cpp
new file mode 100644
index 000000000..fb151f229
--- /dev/null
+++ b/src/core/winrt/SDL_winrtapp_common.cpp
@@ -0,0 +1,16 @@
+
+#include
+#include "SDL_winrtapp_direct3d.h"
+#include "SDL_winrtapp_xaml.h"
+
+int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL;
+
+extern "C" DECLSPEC int
+SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel)
+{
+ if (xamlBackgroundPanel) {
+ return SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel);
+ } else {
+ return SDL_WinRTInitNonXAMLApp(mainFunction);
+ }
+}
diff --git a/src/core/winrt/SDL_winrtapp_common.h b/src/core/winrt/SDL_winrtapp_common.h
new file mode 100644
index 000000000..d54a8ccdc
--- /dev/null
+++ b/src/core/winrt/SDL_winrtapp_common.h
@@ -0,0 +1,31 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_winrtapp_common_h
+#define _SDL_winrtapp_common_h
+
+/* A pointer to the app's C-style main() function (which is a different
+ function than the WinRT app's actual entry point).
+ */
+extern int (*WINRT_SDLAppEntryPoint)(int, char **);
+
+#endif // ifndef _SDL_winrtapp_common_h
diff --git a/src/core/winrt/SDL_winrtapp_direct3d.cpp b/src/core/winrt/SDL_winrtapp_direct3d.cpp
new file mode 100644
index 000000000..53c72bc4e
--- /dev/null
+++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp
@@ -0,0 +1,668 @@
+
+/* Standard C++11 includes */
+#include
+#include
+#include
+using namespace std;
+
+
+/* Windows includes */
+#include "ppltasks.h"
+using namespace concurrency;
+using namespace Windows::ApplicationModel;
+using namespace Windows::ApplicationModel::Core;
+using namespace Windows::ApplicationModel::Activation;
+using namespace Windows::Devices::Input;
+using namespace Windows::Graphics::Display;
+using namespace Windows::Foundation;
+using namespace Windows::System;
+using namespace Windows::UI::Core;
+using namespace Windows::UI::Input;
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+using namespace Windows::Phone::UI::Input;
+#endif
+
+
+/* SDL includes */
+extern "C" {
+#include "SDL_assert.h"
+#include "SDL_events.h"
+#include "SDL_hints.h"
+#include "SDL_log.h"
+#include "SDL_main.h"
+#include "SDL_stdinc.h"
+#include "SDL_render.h"
+#include "../../video/SDL_sysvideo.h"
+//#include "../../SDL_hints_c.h"
+#include "../../events/SDL_events_c.h"
+#include "../../events/SDL_keyboard_c.h"
+#include "../../events/SDL_mouse_c.h"
+#include "../../events/SDL_windowevents_c.h"
+#include "../../render/SDL_sysrender.h"
+#include "../windows/SDL_windows.h"
+}
+
+#include "../../video/winrt/SDL_winrtevents_c.h"
+#include "../../video/winrt/SDL_winrtvideo_cpp.h"
+#include "SDL_winrtapp_common.h"
+#include "SDL_winrtapp_direct3d.h"
+
+
+// Compile-time debugging options:
+// To enable, uncomment; to disable, comment them out.
+//#define LOG_POINTER_EVENTS 1
+//#define LOG_WINDOW_EVENTS 1
+//#define LOG_ORIENTATION_EVENTS 1
+
+
+// HACK, DLudwig: record a reference to the global, WinRT 'app'/view.
+// SDL/WinRT will use this throughout its code.
+//
+// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something
+// non-global, such as something created inside
+// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside
+// SDL_CreateWindow().
+SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
+
+ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
+{
+public:
+ virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
+};
+
+IFrameworkView^ SDLApplicationSource::CreateView()
+{
+ // TODO, WinRT: see if this function (CreateView) can ever get called
+ // more than once. For now, just prevent it from ever assigning
+ // SDL_WinRTGlobalApp more than once.
+ SDL_assert(!SDL_WinRTGlobalApp);
+ SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
+ if (!SDL_WinRTGlobalApp)
+ {
+ SDL_WinRTGlobalApp = app;
+ }
+ return app;
+}
+
+int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **))
+{
+ WINRT_SDLAppEntryPoint = mainFunction;
+ auto direct3DApplicationSource = ref new SDLApplicationSource();
+ CoreApplication::Run(direct3DApplicationSource);
+ return 0;
+}
+
+static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
+{
+ SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
+
+ // Start with no orientation flags, then add each in as they're parsed
+ // from newValue.
+ unsigned int orientationFlags = 0;
+ if (newValue) {
+ std::istringstream tokenizer(newValue);
+ while (!tokenizer.eof()) {
+ std::string orientationName;
+ std::getline(tokenizer, orientationName, ' ');
+ if (orientationName == "LandscapeLeft") {
+ orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped;
+ } else if (orientationName == "LandscapeRight") {
+ orientationFlags |= (unsigned int) DisplayOrientations::Landscape;
+ } else if (orientationName == "Portrait") {
+ orientationFlags |= (unsigned int) DisplayOrientations::Portrait;
+ } else if (orientationName == "PortraitUpsideDown") {
+ orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped;
+ }
+ }
+ }
+
+ // If no valid orientation flags were specified, use a reasonable set of defaults:
+ if (!orientationFlags) {
+ // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s).
+ orientationFlags = (unsigned int) ( \
+ DisplayOrientations::Landscape |
+ DisplayOrientations::LandscapeFlipped |
+ DisplayOrientations::Portrait |
+ DisplayOrientations::PortraitFlipped);
+ }
+
+ // Set the orientation/rotation preferences. Please note that this does
+ // not constitute a 100%-certain lock of a given set of possible
+ // orientations. According to Microsoft's documentation on WinRT [1]
+ // when a device is not capable of being rotated, Windows may ignore
+ // the orientation preferences, and stick to what the device is capable of
+ // displaying.
+ //
+ // [1] Documentation on the 'InitialRotationPreference' setting for a
+ // Windows app's manifest file describes how some orientation/rotation
+ // preferences may be ignored. See
+ // http://msdn.microsoft.com/en-us/library/windows/apps/hh700343.aspx
+ // for details. Microsoft's "Display orientation sample" also gives an
+ // outline of how Windows treats device rotation
+ // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
+ DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
+}
+
+static void
+WINRT_ProcessWindowSizeChange()
+{
+ // Make the new window size be the one true fullscreen mode.
+ // This change was initially done, in part, to allow the Direct3D 11.1
+ // renderer to receive window-resize events as a device rotates.
+ // Before, rotating a device from landscape, to portrait, and then
+ // back to landscape would cause the Direct3D 11.1 swap buffer to
+ // not get resized appropriately. SDL would, on the rotation from
+ // landscape to portrait, re-resize the SDL window to it's initial
+ // size (landscape). On the subsequent rotation, SDL would drop the
+ // window-resize event as it appeared the SDL window didn't change
+ // size, and the Direct3D 11.1 renderer wouldn't resize its swap
+ // chain.
+ SDL_DisplayMode newDisplayMode;
+ if (WINRT_CalcDisplayModeUsingNativeWindow(&newDisplayMode) != 0) {
+ return;
+ }
+
+ // Make note of the old display mode, and it's old driverdata.
+ SDL_DisplayMode oldDisplayMode;
+ SDL_zero(oldDisplayMode);
+ if (WINRT_GlobalSDLVideoDevice) {
+ oldDisplayMode = WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode;
+ }
+
+ // Setup the new display mode in the appropriate spots.
+ if (WINRT_GlobalSDLVideoDevice) {
+ // Make a full copy of the display mode for display_modes[0],
+ // one with with a separately malloced 'driverdata' field.
+ // SDL_VideoQuit(), if called, will attempt to free the driverdata
+ // fields in 'desktop_mode' and each entry in the 'display_modes'
+ // array.
+ if (WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata) {
+ // Free the previous mode's memory
+ SDL_free(WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata);
+ WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata = NULL;
+ }
+ if (WINRT_DuplicateDisplayMode(&(WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0]), &newDisplayMode) != 0) {
+ // Uh oh, something went wrong. A malloc call probably failed.
+ SDL_free(newDisplayMode.driverdata);
+ return;
+ }
+
+ // Install 'newDisplayMode' into 'current_mode' and 'desktop_mode'.
+ WINRT_GlobalSDLVideoDevice->displays[0].current_mode = newDisplayMode;
+ WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode = newDisplayMode;
+ }
+
+ if (WINRT_GlobalSDLWindow) {
+ // Send a window-resize event to the rest of SDL, and to apps:
+ SDL_SendWindowEvent(
+ WINRT_GlobalSDLWindow,
+ SDL_WINDOWEVENT_RESIZED,
+ newDisplayMode.w,
+ newDisplayMode.h);
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ // HACK: On Windows Phone, make sure that orientation changes from
+ // Landscape to LandscapeFlipped, Portrait to PortraitFlipped,
+ // or vice-versa on either of those two, lead to the Direct3D renderer
+ // getting updated.
+ const DisplayOrientations oldOrientation = ((SDL_DisplayModeData *)oldDisplayMode.driverdata)->currentOrientation;
+ const DisplayOrientations newOrientation = ((SDL_DisplayModeData *)newDisplayMode.driverdata)->currentOrientation;
+
+ if ((oldOrientation == DisplayOrientations::Landscape && newOrientation == DisplayOrientations::LandscapeFlipped) ||
+ (oldOrientation == DisplayOrientations::LandscapeFlipped && newOrientation == DisplayOrientations::Landscape) ||
+ (oldOrientation == DisplayOrientations::Portrait && newOrientation == DisplayOrientations::PortraitFlipped) ||
+ (oldOrientation == DisplayOrientations::PortraitFlipped && newOrientation == DisplayOrientations::Portrait))
+ {
+ // One of the reasons this event is getting sent out is because SDL
+ // will ignore requests to send out SDL_WINDOWEVENT_RESIZED events
+ // if and when the event size doesn't change (and the Direct3D 11.1
+ // renderer doesn't get the memo).
+ //
+ // Make sure that the display/window size really didn't change. If
+ // it did, then a SDL_WINDOWEVENT_SIZE_CHANGED event got sent, and
+ // the Direct3D 11.1 renderer picked it up, presumably.
+ if (oldDisplayMode.w == newDisplayMode.w &&
+ oldDisplayMode.h == newDisplayMode.h)
+ {
+ SDL_SendWindowEvent(
+ WINRT_GlobalSDLWindow,
+ SDL_WINDOWEVENT_SIZE_CHANGED,
+ newDisplayMode.w,
+ newDisplayMode.h);
+ }
+ }
+#endif
+ }
+
+ // Finally, free the 'driverdata' field of the old 'desktop_mode'.
+ if (oldDisplayMode.driverdata) {
+ SDL_free(oldDisplayMode.driverdata);
+ oldDisplayMode.driverdata = NULL;
+ }
+}
+
+SDL_WinRTApp::SDL_WinRTApp() :
+ m_windowClosed(false),
+ m_windowVisible(true)
+{
+}
+
+void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
+{
+ applicationView->Activated +=
+ ref new TypedEventHandler(this, &SDL_WinRTApp::OnActivated);
+
+ CoreApplication::Suspending +=
+ ref new EventHandler(this, &SDL_WinRTApp::OnSuspending);
+
+ CoreApplication::Resuming +=
+ ref new EventHandler(this, &SDL_WinRTApp::OnResuming);
+
+ CoreApplication::Exiting +=
+ ref new EventHandler(this, &SDL_WinRTApp::OnExiting);
+
+ DisplayProperties::OrientationChanged +=
+ ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged);
+
+ // Register the hint, SDL_HINT_ORIENTATIONS, with SDL. This needs to be
+ // done before the hint's callback is registered (as of Feb 22, 2013),
+ // otherwise the hint callback won't get registered.
+ //
+ // TODO, WinRT: 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.
+ //SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight Portrait PortraitUpsideDown"); // DavidL: this is no longer needed (for SDL_AddHintCallback)
+ SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL);
+}
+
+void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
+{
+#if LOG_ORIENTATION_EVENTS==1
+ CoreWindow^ window = CoreWindow::GetForCurrentThread();
+ if (window) {
+ SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Size={%f,%f}\n",
+ __FUNCTION__,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences,
+ window->Bounds.Width,
+ window->Bounds.Height);
+ } else {
+ SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n",
+ __FUNCTION__,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences);
+ }
+#endif
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ // On Windows Phone, treat an orientation change as a change in window size.
+ // The native window's size doesn't seem to change, however SDL will simulate
+ // a window size change.
+ WINRT_ProcessWindowSizeChange();
+#endif
+}
+
+void SDL_WinRTApp::SetWindow(CoreWindow^ window)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window Size={%f,%f}\n",
+ __FUNCTION__,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences,
+ window->Bounds.Width,
+ window->Bounds.Height);
+#endif
+
+ window->SizeChanged +=
+ ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowSizeChanged);
+
+ window->VisibilityChanged +=
+ ref new TypedEventHandler(this, &SDL_WinRTApp::OnVisibilityChanged);
+
+ window->Closed +=
+ ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowClosed);
+
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+ window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
+#endif
+
+ window->PointerPressed +=
+ ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerPressed);
+
+ window->PointerMoved +=
+ ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerMoved);
+
+ window->PointerReleased +=
+ ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerReleased);
+
+ window->PointerWheelChanged +=
+ ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerWheelChanged);
+
+#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
+ // Retrieves relative-only mouse movements:
+ Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
+ ref new TypedEventHandler(this, &SDL_WinRTApp::OnMouseMoved);
+#endif
+
+ window->KeyDown +=
+ ref new TypedEventHandler(this, &SDL_WinRTApp::OnKeyDown);
+
+ window->KeyUp +=
+ ref new TypedEventHandler(this, &SDL_WinRTApp::OnKeyUp);
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ HardwareButtons::BackPressed +=
+ ref new EventHandler(this, &SDL_WinRTApp::OnBackButtonPressed);
+#endif
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP // for Windows 8/8.1/RT apps... (and not Phone apps)
+ // Make sure we know when a user has opened the app's settings pane.
+ // This is needed in order to display a privacy policy, which needs
+ // to be done for network-enabled apps, as per Windows Store requirements.
+ using namespace Windows::UI::ApplicationSettings;
+ SettingsPane::GetForCurrentView()->CommandsRequested +=
+ ref new TypedEventHandler
+ (this, &SDL_WinRTApp::OnSettingsPaneCommandsRequested);
+#endif
+}
+
+void SDL_WinRTApp::Load(Platform::String^ entryPoint)
+{
+}
+
+void SDL_WinRTApp::Run()
+{
+ SDL_SetMainReady();
+ if (WINRT_SDLAppEntryPoint)
+ {
+ // TODO, WinRT: pass the C-style main() a reasonably realistic
+ // representation of command line arguments.
+ int argc = 0;
+ char **argv = NULL;
+ WINRT_SDLAppEntryPoint(argc, argv);
+ }
+}
+
+void SDL_WinRTApp::PumpEvents()
+{
+ if (!m_windowClosed)
+ {
+ if (m_windowVisible)
+ {
+ CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
+ }
+ else
+ {
+ CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
+ }
+ }
+}
+
+void SDL_WinRTApp::Uninitialize()
+{
+}
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+void SDL_WinRTApp::OnSettingsPaneCommandsRequested(
+ Windows::UI::ApplicationSettings::SettingsPane ^p,
+ Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args)
+{
+ using namespace Platform;
+ using namespace Windows::UI::ApplicationSettings;
+ using namespace Windows::UI::Popups;
+
+ String ^privacyPolicyURL = nullptr; // a URL to an app's Privacy Policy
+ String ^privacyPolicyLabel = nullptr; // label/link text
+ const char *tmpHintValue = NULL; // SDL_GetHint-retrieved value, used immediately
+ wchar_t *tmpStr = NULL; // used for UTF8 to UCS2 conversion
+
+ // Setup a 'Privacy Policy' link, if one is available (via SDL_GetHint):
+ tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_URL);
+ if (tmpHintValue && tmpHintValue[0] != '\0') {
+ // Convert the privacy policy's URL to UCS2:
+ tmpStr = WIN_UTF8ToString(tmpHintValue);
+ privacyPolicyURL = ref new String(tmpStr);
+ SDL_free(tmpStr);
+
+ // Optionally retrieve custom label-text for the link. If this isn't
+ // available, a default value will be used instead.
+ tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_LABEL);
+ if (tmpHintValue && tmpHintValue[0] != '\0') {
+ tmpStr = WIN_UTF8ToString(tmpHintValue);
+ privacyPolicyLabel = ref new String(tmpStr);
+ SDL_free(tmpStr);
+ } else {
+ privacyPolicyLabel = ref new String(L"Privacy Policy");
+ }
+
+ // Register the link, along with a handler to be called if and when it is
+ // clicked:
+ auto cmd = ref new SettingsCommand(L"privacyPolicy", privacyPolicyLabel,
+ ref new UICommandInvokedHandler([=](IUICommand ^) {
+ Windows::System::Launcher::LaunchUriAsync(ref new Uri(privacyPolicyURL));
+ }));
+ args->Request->ApplicationCommands->Append(cmd);
+ }
+}
+#endif // if WINAPI_FAMILY == WINAPI_FAMILY_APP
+
+void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s, size={%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, WINRT_GlobalSDLWindow?=%s\n",
+ __FUNCTION__,
+ args->Size.Width, args->Size.Height,
+ (int)DisplayProperties::CurrentOrientation,
+ (int)DisplayProperties::NativeOrientation,
+ (int)DisplayProperties::AutoRotationPreferences,
+ (WINRT_GlobalSDLWindow ? "yes" : "no"));
+#endif
+
+ WINRT_ProcessWindowSizeChange();
+}
+
+void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s, visible?=%s, WINRT_GlobalSDLWindow?=%s\n",
+ __FUNCTION__,
+ (args->Visible ? "yes" : "no"),
+ (WINRT_GlobalSDLWindow ? "yes" : "no"));
+#endif
+
+ m_windowVisible = args->Visible;
+ if (WINRT_GlobalSDLWindow) {
+ SDL_bool wasSDLWindowSurfaceValid = WINRT_GlobalSDLWindow->surface_valid;
+
+ if (args->Visible) {
+ SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
+ } else {
+ SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
+ }
+
+ // HACK: Prevent SDL's window-hide handling code, which currently
+ // triggers a fake window resize (possibly erronously), from
+ // marking the SDL window's surface as invalid.
+ //
+ // A better solution to this probably involves figuring out if the
+ // fake window resize can be prevented.
+ WINRT_GlobalSDLWindow->surface_valid = wasSDLWindowSurfaceValid;
+ }
+}
+
+void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
+{
+#if LOG_WINDOW_EVENTS==1
+ SDL_Log("%s\n", __FUNCTION__);
+#endif
+ m_windowClosed = true;
+}
+
+void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
+{
+ CoreWindow::GetForCurrentThread()->Activate();
+}
+
+static int SDLCALL RemoveAppSuspendAndResumeEvents(void * userdata, SDL_Event * event)
+{
+ if (event->type == SDL_WINDOWEVENT)
+ {
+ switch (event->window.event)
+ {
+ case SDL_WINDOWEVENT_MINIMIZED:
+ case SDL_WINDOWEVENT_RESTORED:
+ // Return 0 to indicate that the event should be removed from the
+ // event queue:
+ return 0;
+ default:
+ break;
+ }
+ }
+
+ // Return 1 to indicate that the event should stay in the event queue:
+ return 1;
+}
+
+void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
+{
+ // Save app state asynchronously after requesting a deferral. Holding a deferral
+ // indicates that the application is busy performing suspending operations. Be
+ // aware that a deferral may not be held indefinitely. After about five seconds,
+ // the app will be forced to exit.
+ SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
+ create_task([this, deferral]()
+ {
+ // Send a window-minimized event immediately to observers.
+ // CoreDispatcher::ProcessEvents, which is the backbone on which
+ // SDL_WinRTApp::PumpEvents is built, will not return to its caller
+ // once it sends out a suspend event. Any events posted to SDL's
+ // event queue won't get received until the WinRT app is resumed.
+ // SDL_AddEventWatch() may be used to receive app-suspend events on
+ // WinRT.
+ //
+ // In order to prevent app-suspend events from being received twice:
+ // first via a callback passed to SDL_AddEventWatch, and second via
+ // SDL's event queue, the event will be sent to SDL, then immediately
+ // removed from the queue.
+ if (WINRT_GlobalSDLWindow)
+ {
+ SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
+ SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
+ }
+
+ SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND);
+ SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND);
+
+ deferral->Complete();
+ });
+}
+
+void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
+{
+ SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
+ SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
+
+ // Restore any data or state that was unloaded on suspend. By default, data
+ // and state are persisted when resuming from suspend. Note that this event
+ // does not occur if the app was previously terminated.
+ if (WINRT_GlobalSDLWindow)
+ {
+ SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_RESTORED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
+
+ // Remove the app-resume event from the queue, as is done with the
+ // app-suspend event.
+ //
+ // TODO, WinRT: consider posting this event to the queue even though
+ // its counterpart, the app-suspend event, effectively has to be
+ // processed immediately.
+ SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
+ }
+}
+
+void SDL_WinRTApp::OnExiting(Platform::Object^ sender, Platform::Object^ args)
+{
+ SDL_SendAppEvent(SDL_APP_TERMINATING);
+}
+
+static void
+WINRT_LogPointerEvent(const char * header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint)
+{
+ Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint;
+ SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, SDL button=%d\n",
+ header,
+ pt->Position.X, pt->Position.Y,
+ transformedPoint.X, transformedPoint.Y,
+ pt->Properties->MouseWheelDelta,
+ pt->FrameId,
+ pt->PointerId,
+ WINRT_GetSDLButtonForPointerPoint(pt));
+}
+
+void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("pointer pressed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
+#endif
+
+ WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("pointer moved", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
+#endif
+
+ WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("pointer released", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
+#endif
+
+ WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
+{
+#if LOG_POINTER_EVENTS
+ WINRT_LogPointerEvent("pointer wheel changed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
+#endif
+
+ WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
+}
+
+void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
+{
+ WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args);
+}
+
+void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
+{
+ WINRT_ProcessKeyDownEvent(args);
+}
+
+void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
+{
+ WINRT_ProcessKeyUpEvent(args);
+}
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args)
+{
+ SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_AC_BACK);
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_AC_BACK);
+
+ const char *hint = SDL_GetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON);
+ if (hint) {
+ if (*hint == '1') {
+ args->Handled = true;
+ }
+ }
+}
+#endif
+
diff --git a/src/core/winrt/SDL_winrtapp_direct3d.h b/src/core/winrt/SDL_winrtapp_direct3d.h
new file mode 100644
index 000000000..07e4a8048
--- /dev/null
+++ b/src/core/winrt/SDL_winrtapp_direct3d.h
@@ -0,0 +1,58 @@
+#pragma once
+
+#include
+
+extern int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **));
+
+ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
+{
+public:
+ SDL_WinRTApp();
+
+ // IFrameworkView Methods.
+ virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
+ virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
+ virtual void Load(Platform::String^ entryPoint);
+ virtual void Run();
+ virtual void Uninitialize();
+
+internal:
+ // SDL-specific methods
+ void PumpEvents();
+
+protected:
+ // Event Handlers.
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP // for Windows 8/8.1/RT apps... (and not Phone apps)
+ void OnSettingsPaneCommandsRequested(
+ Windows::UI::ApplicationSettings::SettingsPane ^p,
+ Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args);
+#endif // if WINAPI_FAMILY == WINAPI_FAMILY_APP
+
+ void OnOrientationChanged(Platform::Object^ sender);
+ void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
+ void OnLogicalDpiChanged(Platform::Object^ sender);
+ void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
+ void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
+ void OnResuming(Platform::Object^ sender, Platform::Object^ args);
+ void OnExiting(Platform::Object^ sender, Platform::Object^ args);
+ void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
+ void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
+ void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
+ void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args);
+ void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
+ void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args);
+#endif
+
+private:
+ bool m_windowClosed;
+ bool m_windowVisible;
+};
+
+extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
diff --git a/src/core/winrt/SDL_winrtapp_xaml.cpp b/src/core/winrt/SDL_winrtapp_xaml.cpp
new file mode 100644
index 000000000..8b8a8ee63
--- /dev/null
+++ b/src/core/winrt/SDL_winrtapp_xaml.cpp
@@ -0,0 +1,158 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/* Windows includes */
+#include
+#include
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+#include
+#endif
+
+
+/* SDL includes */
+#include "SDL.h"
+#include "../../video/winrt/SDL_winrtevents_c.h"
+#include "../../video/winrt/SDL_winrtvideo_cpp.h"
+#include "SDL_winrtapp_common.h"
+#include "SDL_winrtapp_xaml.h"
+
+
+
+/* SDL-internal globals: */
+SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE;
+
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative = NULL;
+static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken;
+#endif
+
+
+/*
+ * Input event handlers (XAML)
+ */
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+
+static void
+WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
+{
+ WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
+}
+
+static void
+WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
+{
+ WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
+}
+
+static void
+WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
+{
+ WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
+}
+
+static void
+WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
+{
+ WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
+}
+
+#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
+
+
+/*
+ * XAML-to-SDL Rendering Callback
+ */
+#if WINAPI_FAMILY == WINAPI_FAMILY_APP
+
+static void
+WINRT_OnRenderViaXAML(_In_ Platform::Object^ sender, _In_ Platform::Object^ args)
+{
+ WINRT_CycleXAMLThread();
+}
+
+#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
+
+
+/*
+ * SDL + XAML Initialization
+ */
+
+int
+SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAsIInspectable)
+{
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+ return SDL_SetError("XAML support is not yet available in Windows Phone.");
+#else
+ // Declare C++/CX namespaces:
+ using namespace Platform;
+ using namespace Windows::Foundation;
+ using namespace Windows::UI::Core;
+ using namespace Windows::UI::Xaml;
+ using namespace Windows::UI::Xaml::Controls;
+ using namespace Windows::UI::Xaml::Input;
+ using namespace Windows::UI::Xaml::Media;
+
+ // Make sure we have a valid XAML element (to draw onto):
+ if ( ! backgroundPanelAsIInspectable) {
+ return SDL_SetError("'backgroundPanelAsIInspectable' can't be NULL");
+ }
+
+ Platform::Object ^ backgroundPanel = reinterpret_cast