diff --git a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj
index 40a8ffd9e..3a770d61e 100644
--- a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj
+++ b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj
@@ -100,11 +100,11 @@
-
+
@@ -239,6 +239,7 @@
+
diff --git a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters
index 74dd2dc86..9e8007cf2 100644
--- a/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters
+++ b/VisualC-WinRT/SDL/SDL_VS2012-WinRT.vcxproj.filters
@@ -96,9 +96,6 @@
Source Files
-
- Source Files
-
Source Files
@@ -267,6 +264,9 @@
Source Files
+
+ Source Files
+
@@ -593,6 +593,9 @@
Source Files
+
+ Header Files
+
diff --git a/include/SDL_config_windowsrt.h b/include/SDL_config_windowsrt.h
index b6ecc00fe..712a9149f 100644
--- a/include/SDL_config_windowsrt.h
+++ b/include/SDL_config_windowsrt.h
@@ -83,6 +83,7 @@ typedef unsigned int uintptr_t;
#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 */
@@ -123,7 +124,7 @@ typedef unsigned int uintptr_t;
#define HAVE_ATAN 1
#define HAVE_ATAN2 1
#define HAVE_CEIL 1
-//#define HAVE_COPYSIGN 1 // TODO, WinRT: consider using _copysign instead
+#define HAVE__COPYSIGN 1
#define HAVE_COS 1
#define HAVE_COSF 1
#define HAVE_FABS 1
@@ -131,6 +132,7 @@ typedef unsigned int uintptr_t;
#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
diff --git a/include/SDL_platform.h b/include/SDL_platform.h
index 1e8e0d9f4..419b6336c 100644
--- a/include/SDL_platform.h
+++ b/include/SDL_platform.h
@@ -120,10 +120,27 @@
#undef __SOLARIS__
#define __SOLARIS__ 1
#endif
-#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
-#undef __WIN32__
-#define __WIN32__ 1
-#endif
+
+#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
+/* Try to find out what version of Windows we are compiling for */
+#if defined(_MSC_VER) && (_MSC_VER >= 1700) /* _MSC_VER==1700 for MSVC 2012 */
+#include
+#endif
+/* Default to classic, Win32 / 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, see if we're compiling for WinRT.
+ */
+#if ! defined(WINAPI_FAMILY_PARTITION) || WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#undef __WIN32__
+#define __WIN32__ 1
+/* 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(__PSP__)
#undef __PSP__
#define __PSP__ 1
diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h
index bc39c2a90..bfd6bb8bc 100644
--- a/include/SDL_stdinc.h
+++ b/include/SDL_stdinc.h
@@ -80,6 +80,9 @@
# endif
# include
#endif
+#ifdef HAVE_FLOAT_H
+# include
+#endif
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
# include
#endif
diff --git a/src/SDL_log.c b/src/SDL_log.c
index a19a2c425..1bd8ae69d 100644
--- a/src/SDL_log.c
+++ b/src/SDL_log.c
@@ -322,6 +322,8 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
char *output;
size_t length;
LPTSTR tstr;
+
+#ifndef __WINRT__
BOOL attachResult;
DWORD attachError;
unsigned long charsWritten;
@@ -353,6 +355,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;
output = SDL_stack_alloc(char, length);
@@ -362,6 +365,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)) {
@@ -371,6 +375,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
OutputDebugString(TEXT("Insufficient heap memory to write message"));
}
}
+#endif /* ifndef __WINRT__ */
SDL_free(tstr);
SDL_stack_free(output);
diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c
index 19f7cdc5c..2816e6c77 100644
--- a/src/audio/xaudio2/SDL_xaudio2.c
+++ b/src/audio/xaudio2/SDL_xaudio2.c
@@ -91,15 +91,11 @@ extern "C" {
}
#endif
-#if defined(__WINRT__)
-# define SDL_XAUDIO2_HAS_SDK 1
-#endif
-#if defined(__WIN32__)
#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 SD
+/* WinRT always has access to the .the XAudio 2 SDK */
# define SDL_XAUDIO2_HAS_SDK
#else
#include /* XAudio2 exists as of the March 2008 DirectX SDK */
diff --git a/src/joystick/SDL_gamecontrollerdb.h b/src/joystick/SDL_gamecontrollerdb.h
index 7f6c7b29f..dcdbafb17 100644
--- a/src/joystick/SDL_gamecontrollerdb.h
+++ b/src/joystick/SDL_gamecontrollerdb.h
@@ -38,6 +38,8 @@ static const char *s_ControllerMappings [] =
"4c056802000000000000504944564944,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
"25090500000000000000504944564944,PS3 DualShock,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,",
"xinput,X360 Controller,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,",
+#elif defined(SDL_JOYSTICK_XINPUT)
+ "xinput,X360 Controller,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,",
#elif defined(__MACOSX__)
"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
"6d0400000000000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 5dfc38dcb..5827a55e1 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -49,6 +49,9 @@ static const SDL_RenderDriver *render_drivers[] = {
#if SDL_VIDEO_RENDER_D3D
&D3D_RenderDriver,
#endif
+#if SDL_VIDEO_RENDER_D3D11
+ &D3D11_RenderDriver,
+#endif
#if SDL_VIDEO_RENDER_OGL
&GL_RenderDriver,
#endif
diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c
index 2ee62beee..f5ea27d3f 100644
--- a/src/stdlib/SDL_stdlib.c
+++ b/src/stdlib/SDL_stdlib.c
@@ -61,6 +61,8 @@ SDL_copysign(double x, double y)
{
#if defined(HAVE_COPYSIGN)
return copysign(x, y);
+#elif defined(HAVE__COPYSIGN)
+ return _copysign(x, y);
#else
return SDL_uclibc_copysign(x, y);
#endif /* HAVE_COPYSIGN */
@@ -131,6 +133,8 @@ SDL_scalbn(double x, int n)
{
#if defined(HAVE_SCALBN)
return scalbn(x, n);
+#elif defined(HAVE__SCALB)
+ return _scalb(x, n);
#else
return SDL_uclibc_scalbn(x, n);
#endif /* HAVE_SCALBN */
diff --git a/src/thread/stdcpp/SDL_systhread.cpp b/src/thread/stdcpp/SDL_systhread.cpp
index fd4cdafb3..fb1ca31b5 100644
--- a/src/thread/stdcpp/SDL_systhread.cpp
+++ b/src/thread/stdcpp/SDL_systhread.cpp
@@ -24,8 +24,8 @@
extern "C" {
#include "SDL_thread.h"
-#include "../SDL_systhread.h"
#include "../SDL_thread_c.h"
+#include "../SDL_systhread.h"
#include "SDL_log.h"
}
@@ -121,4 +121,18 @@ SDL_SYS_WaitThread(SDL_Thread * thread)
}
}
+extern "C"
+SDL_TLSData *
+SDL_SYS_GetTLSData()
+{
+ return SDL_Generic_GetTLSData();
+}
+
+extern "C"
+int
+SDL_SYS_SetTLSData(SDL_TLSData *data)
+{
+ return SDL_Generic_SetTLSData(data);
+}
+
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/timer/windows/SDL_systimer.c b/src/timer/windows/SDL_systimer.c
index ce6bd7a70..f71aecf35 100644
--- a/src/timer/windows/SDL_systimer.c
+++ b/src/timer/windows/SDL_systimer.c
@@ -41,6 +41,7 @@ static LARGE_INTEGER hires_start_ticks;
static LARGE_INTEGER hires_ticks_per_second;
#endif
+#ifndef __WINRT__
static void
timeSetPeriod(UINT uPeriod)
{
@@ -74,6 +75,7 @@ SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValu
timeSetPeriod(uPeriod);
}
}
+#endif /* ifndef __WINRT__ */
void
SDL_StartTicks(void)
@@ -90,13 +92,19 @@ SDL_StartTicks(void)
QueryPerformanceCounter(&hires_start_ticks);
} else {
hires_timer_available = FALSE;
+#ifdef __WINRT__
+ start = 0; /* the timer failed to start! */
+#else
timeSetPeriod(1); /* use 1 ms timer precision */
start = timeGetTime();
+#endif /* ifdef __WINRT__ */
}
#endif
+#ifndef __WINRT__
SDL_AddHintCallback(SDL_HINT_TIMER_RESOLUTION,
SDL_TimerResolutionChanged, NULL);
+#endif
}
Uint32
@@ -119,7 +127,11 @@ SDL_GetTicks(void)
return (DWORD) hires_now.QuadPart;
} else {
+#ifdef __WINRT__
+ now = 0;
+#else
now = timeGetTime();
+#endif // ifdef __WINRT__
}
#endif
@@ -148,6 +160,19 @@ SDL_GetPerformanceFrequency(void)
return frequency.QuadPart;
}
+#ifdef __WINRT__
+static void
+Sleep(DWORD timeout)
+{
+ static HANDLE mutex = 0;
+ if ( ! mutex )
+ {
+ mutex = CreateEventEx(0, 0, 0, EVENT_ALL_ACCESS);
+ }
+ WaitForSingleObjectEx(mutex, timeout, FALSE);
+}
+#endif
+
void
SDL_Delay(Uint32 ms)
{
diff --git a/src/video/windowsrt/SDL_WinRTApp.cpp b/src/video/windowsrt/SDL_WinRTApp.cpp
index a807bda7f..bac38e447 100644
--- a/src/video/windowsrt/SDL_WinRTApp.cpp
+++ b/src/video/windowsrt/SDL_WinRTApp.cpp
@@ -13,7 +13,7 @@ extern "C" {
#include "SDL_stdinc.h"
#include "SDL_render.h"
#include "../SDL_sysvideo.h"
-#include "../../SDL_hints_c.h"
+//#include "../../SDL_hints_c.h"
#include "../../events/scancodes_windows.h"
#include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_keyboard_c.h"
@@ -86,7 +86,7 @@ __declspec(dllexport) int SDL_WinRT_RunApplication(SDL_WinRT_MainFunction mainFu
return 0;
}
-static void WINRT_SetDisplayOrientationsPreference(const char *name, const char *oldValue, const char *newValue)
+static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
{
SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
@@ -163,8 +163,8 @@ void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
// otherwise the hint callback won't get registered.
//
// WinRT, TODO: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly.
- SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight Portrait PortraitUpsideDown");
- SDL_RegisterHintChangedCb(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference);
+ //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)
@@ -316,15 +316,19 @@ void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEven
// Windows device.
//
// Commencing hack in 3... 2... 1...
- SDL_Renderer * rendererForMainWindow = SDL_GetRenderer(m_sdlWindowData->sdlWindow);
+ //
+ // UPDATE, SDL 2.0.0 update: the 'resized' flag is now gone. This
+ // hack might not be necessary any more.
+ //
+ //SDL_Renderer * rendererForMainWindow = SDL_GetRenderer(m_sdlWindowData->sdlWindow);
// For now, limit the hack to when the Direct3D 11.1 is getting used:
- const bool usingD3D11Renderer = \
- (rendererForMainWindow != NULL) &&
- (SDL_strcmp(rendererForMainWindow->info.name, "direct3d 11.1") == 0);
- SDL_bool wasD3D11RendererResized = SDL_FALSE;
- if (usingD3D11Renderer) {
- wasD3D11RendererResized = rendererForMainWindow->resized;
- }
+ //const bool usingD3D11Renderer = \
+ // (rendererForMainWindow != NULL) &&
+ // (SDL_strcmp(rendererForMainWindow->info.name, "direct3d 11.1") == 0);
+ //SDL_bool wasD3D11RendererResized = SDL_FALSE;
+ //if (usingD3D11Renderer) {
+ // wasD3D11RendererResized = rendererForMainWindow->resized;
+ //}
// Send the window-resize event to the rest of SDL, and to apps:
const int windowWidth = (int) ceil(args->Size.Width);
@@ -335,10 +339,10 @@ void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEven
windowWidth,
windowHeight);
- // Viewport hack, part two:
- if (usingD3D11Renderer) {
- rendererForMainWindow->resized = wasD3D11RendererResized;
- }
+ //// Viewport hack, part two:
+ //if (usingD3D11Renderer) {
+ // rendererForMainWindow->resized = wasD3D11RendererResized;
+ //}
}
}