WinRT: build fixes and additional WinRT-related integrations with SDL 2.0.0
parent
f7049b93d5
commit
d41fdc94d6
|
@ -100,11 +100,11 @@
|
||||||
<ClCompile Include="..\..\src\SDL.c" />
|
<ClCompile Include="..\..\src\SDL.c" />
|
||||||
<ClCompile Include="..\..\src\SDL_assert.c" />
|
<ClCompile Include="..\..\src\SDL_assert.c" />
|
||||||
<ClCompile Include="..\..\src\SDL_error.c" />
|
<ClCompile Include="..\..\src\SDL_error.c" />
|
||||||
<ClCompile Include="..\..\src\SDL_fatal.c" />
|
|
||||||
<ClCompile Include="..\..\src\SDL_hints.c" />
|
<ClCompile Include="..\..\src\SDL_hints.c" />
|
||||||
<ClCompile Include="..\..\src\SDL_log.c" />
|
<ClCompile Include="..\..\src\SDL_log.c" />
|
||||||
<ClCompile Include="..\..\src\stdlib\SDL_getenv.c" />
|
<ClCompile Include="..\..\src\stdlib\SDL_getenv.c" />
|
||||||
<ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
|
<ClCompile Include="..\..\src\stdlib\SDL_iconv.c" />
|
||||||
|
<ClCompile Include="..\..\src\stdlib\SDL_malloc.c" />
|
||||||
<ClCompile Include="..\..\src\stdlib\SDL_qsort.c" />
|
<ClCompile Include="..\..\src\stdlib\SDL_qsort.c" />
|
||||||
<ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
|
<ClCompile Include="..\..\src\stdlib\SDL_stdlib.c" />
|
||||||
<ClCompile Include="..\..\src\stdlib\SDL_string.c" />
|
<ClCompile Include="..\..\src\stdlib\SDL_string.c" />
|
||||||
|
@ -239,6 +239,7 @@
|
||||||
<ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
|
<ClInclude Include="..\..\src\events\SDL_windowevents_c.h" />
|
||||||
<ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
|
<ClInclude Include="..\..\src\haptic\SDL_haptic_c.h" />
|
||||||
<ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
|
<ClInclude Include="..\..\src\haptic\SDL_syshaptic.h" />
|
||||||
|
<ClInclude Include="..\..\src\joystick\SDL_gamecontrollerdb.h" />
|
||||||
<ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
|
<ClInclude Include="..\..\src\joystick\SDL_joystick_c.h" />
|
||||||
<ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
|
<ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
|
||||||
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h" />
|
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h" />
|
||||||
|
|
|
@ -96,9 +96,6 @@
|
||||||
<ClCompile Include="..\..\src\events\SDL_events.c">
|
<ClCompile Include="..\..\src\events\SDL_events.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\SDL_fatal.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\video\SDL_fillrect.c">
|
<ClCompile Include="..\..\src\video\SDL_fillrect.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -267,6 +264,9 @@
|
||||||
<ClCompile Include="..\..\src\joystick\windowsrt\SDL_xinputjoystick.c">
|
<ClCompile Include="..\..\src\joystick\windowsrt\SDL_xinputjoystick.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\stdlib\SDL_malloc.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\include\begin_code.h">
|
<ClInclude Include="..\..\include\begin_code.h">
|
||||||
|
@ -593,6 +593,9 @@
|
||||||
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h">
|
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_d3d11_cpp.h">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\joystick\SDL_gamecontrollerdb.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Header Files">
|
<Filter Include="Header Files">
|
||||||
|
|
|
@ -83,6 +83,7 @@ typedef unsigned int uintptr_t;
|
||||||
#define HAVE_STRING_H 1
|
#define HAVE_STRING_H 1
|
||||||
#define HAVE_CTYPE_H 1
|
#define HAVE_CTYPE_H 1
|
||||||
#define HAVE_MATH_H 1
|
#define HAVE_MATH_H 1
|
||||||
|
#define HAVE_FLOAT_H 1
|
||||||
#define HAVE_SIGNAL_H 1
|
#define HAVE_SIGNAL_H 1
|
||||||
|
|
||||||
/* C library functions */
|
/* C library functions */
|
||||||
|
@ -123,7 +124,7 @@ typedef unsigned int uintptr_t;
|
||||||
#define HAVE_ATAN 1
|
#define HAVE_ATAN 1
|
||||||
#define HAVE_ATAN2 1
|
#define HAVE_ATAN2 1
|
||||||
#define HAVE_CEIL 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_COS 1
|
||||||
#define HAVE_COSF 1
|
#define HAVE_COSF 1
|
||||||
#define HAVE_FABS 1
|
#define HAVE_FABS 1
|
||||||
|
@ -131,6 +132,7 @@ typedef unsigned int uintptr_t;
|
||||||
#define HAVE_LOG 1
|
#define HAVE_LOG 1
|
||||||
#define HAVE_POW 1
|
#define HAVE_POW 1
|
||||||
//#define HAVE_SCALBN 1
|
//#define HAVE_SCALBN 1
|
||||||
|
#define HAVE__SCALB 1
|
||||||
#define HAVE_SIN 1
|
#define HAVE_SIN 1
|
||||||
#define HAVE_SINF 1
|
#define HAVE_SINF 1
|
||||||
#define HAVE_SQRT 1
|
#define HAVE_SQRT 1
|
||||||
|
|
|
@ -120,10 +120,27 @@
|
||||||
#undef __SOLARIS__
|
#undef __SOLARIS__
|
||||||
#define __SOLARIS__ 1
|
#define __SOLARIS__ 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
|
#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 <winapifamily.h>
|
||||||
|
#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__
|
#undef __WIN32__
|
||||||
#define __WIN32__ 1
|
#define __WIN32__ 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(__PSP__)
|
#if defined(__PSP__)
|
||||||
#undef __PSP__
|
#undef __PSP__
|
||||||
#define __PSP__ 1
|
#define __PSP__ 1
|
||||||
|
|
|
@ -80,6 +80,9 @@
|
||||||
# endif
|
# endif
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_FLOAT_H
|
||||||
|
# include <float.h>
|
||||||
|
#endif
|
||||||
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
|
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
|
||||||
# include <iconv.h>
|
# include <iconv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -322,6 +322,8 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
|
||||||
char *output;
|
char *output;
|
||||||
size_t length;
|
size_t length;
|
||||||
LPTSTR tstr;
|
LPTSTR tstr;
|
||||||
|
|
||||||
|
#ifndef __WINRT__
|
||||||
BOOL attachResult;
|
BOOL attachResult;
|
||||||
DWORD attachError;
|
DWORD attachError;
|
||||||
unsigned long charsWritten;
|
unsigned long charsWritten;
|
||||||
|
@ -353,6 +355,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
|
||||||
stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
|
stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* ifndef __WINRT__ */
|
||||||
|
|
||||||
length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1;
|
length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1;
|
||||||
output = SDL_stack_alloc(char, length);
|
output = SDL_stack_alloc(char, length);
|
||||||
|
@ -362,6 +365,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
|
||||||
/* Output to debugger */
|
/* Output to debugger */
|
||||||
OutputDebugString(tstr);
|
OutputDebugString(tstr);
|
||||||
|
|
||||||
|
#ifndef __WINRT__
|
||||||
/* Screen output to stderr, if console was attached. */
|
/* Screen output to stderr, if console was attached. */
|
||||||
if (consoleAttached == 1) {
|
if (consoleAttached == 1) {
|
||||||
if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) {
|
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"));
|
OutputDebugString(TEXT("Insufficient heap memory to write message"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* ifndef __WINRT__ */
|
||||||
|
|
||||||
SDL_free(tstr);
|
SDL_free(tstr);
|
||||||
SDL_stack_free(output);
|
SDL_stack_free(output);
|
||||||
|
|
|
@ -91,15 +91,11 @@ extern "C" {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WINRT__)
|
|
||||||
# define SDL_XAUDIO2_HAS_SDK 1
|
|
||||||
#endif
|
|
||||||
#if defined(__WIN32__)
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
/* The configure script already did any necessary checking */
|
/* The configure script already did any necessary checking */
|
||||||
# define SDL_XAUDIO2_HAS_SDK 1
|
# define SDL_XAUDIO2_HAS_SDK 1
|
||||||
#elif defined(__WINRT__)
|
#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
|
# define SDL_XAUDIO2_HAS_SDK
|
||||||
#else
|
#else
|
||||||
#include <dxsdkver.h> /* XAudio2 exists as of the March 2008 DirectX SDK */
|
#include <dxsdkver.h> /* XAudio2 exists as of the March 2008 DirectX SDK */
|
||||||
|
|
|
@ -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,",
|
"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,",
|
"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,",
|
"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__)
|
#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,",
|
"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. */
|
"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. */
|
||||||
|
|
|
@ -49,6 +49,9 @@ static const SDL_RenderDriver *render_drivers[] = {
|
||||||
#if SDL_VIDEO_RENDER_D3D
|
#if SDL_VIDEO_RENDER_D3D
|
||||||
&D3D_RenderDriver,
|
&D3D_RenderDriver,
|
||||||
#endif
|
#endif
|
||||||
|
#if SDL_VIDEO_RENDER_D3D11
|
||||||
|
&D3D11_RenderDriver,
|
||||||
|
#endif
|
||||||
#if SDL_VIDEO_RENDER_OGL
|
#if SDL_VIDEO_RENDER_OGL
|
||||||
&GL_RenderDriver,
|
&GL_RenderDriver,
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -61,6 +61,8 @@ SDL_copysign(double x, double y)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_COPYSIGN)
|
#if defined(HAVE_COPYSIGN)
|
||||||
return copysign(x, y);
|
return copysign(x, y);
|
||||||
|
#elif defined(HAVE__COPYSIGN)
|
||||||
|
return _copysign(x, y);
|
||||||
#else
|
#else
|
||||||
return SDL_uclibc_copysign(x, y);
|
return SDL_uclibc_copysign(x, y);
|
||||||
#endif /* HAVE_COPYSIGN */
|
#endif /* HAVE_COPYSIGN */
|
||||||
|
@ -131,6 +133,8 @@ SDL_scalbn(double x, int n)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_SCALBN)
|
#if defined(HAVE_SCALBN)
|
||||||
return scalbn(x, n);
|
return scalbn(x, n);
|
||||||
|
#elif defined(HAVE__SCALB)
|
||||||
|
return _scalb(x, n);
|
||||||
#else
|
#else
|
||||||
return SDL_uclibc_scalbn(x, n);
|
return SDL_uclibc_scalbn(x, n);
|
||||||
#endif /* HAVE_SCALBN */
|
#endif /* HAVE_SCALBN */
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "SDL_thread.h"
|
#include "SDL_thread.h"
|
||||||
#include "../SDL_systhread.h"
|
|
||||||
#include "../SDL_thread_c.h"
|
#include "../SDL_thread_c.h"
|
||||||
|
#include "../SDL_systhread.h"
|
||||||
#include "SDL_log.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: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -41,6 +41,7 @@ static LARGE_INTEGER hires_start_ticks;
|
||||||
static LARGE_INTEGER hires_ticks_per_second;
|
static LARGE_INTEGER hires_ticks_per_second;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __WINRT__
|
||||||
static void
|
static void
|
||||||
timeSetPeriod(UINT uPeriod)
|
timeSetPeriod(UINT uPeriod)
|
||||||
{
|
{
|
||||||
|
@ -74,6 +75,7 @@ SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValu
|
||||||
timeSetPeriod(uPeriod);
|
timeSetPeriod(uPeriod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* ifndef __WINRT__ */
|
||||||
|
|
||||||
void
|
void
|
||||||
SDL_StartTicks(void)
|
SDL_StartTicks(void)
|
||||||
|
@ -90,13 +92,19 @@ SDL_StartTicks(void)
|
||||||
QueryPerformanceCounter(&hires_start_ticks);
|
QueryPerformanceCounter(&hires_start_ticks);
|
||||||
} else {
|
} else {
|
||||||
hires_timer_available = FALSE;
|
hires_timer_available = FALSE;
|
||||||
|
#ifdef __WINRT__
|
||||||
|
start = 0; /* the timer failed to start! */
|
||||||
|
#else
|
||||||
timeSetPeriod(1); /* use 1 ms timer precision */
|
timeSetPeriod(1); /* use 1 ms timer precision */
|
||||||
start = timeGetTime();
|
start = timeGetTime();
|
||||||
|
#endif /* ifdef __WINRT__ */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __WINRT__
|
||||||
SDL_AddHintCallback(SDL_HINT_TIMER_RESOLUTION,
|
SDL_AddHintCallback(SDL_HINT_TIMER_RESOLUTION,
|
||||||
SDL_TimerResolutionChanged, NULL);
|
SDL_TimerResolutionChanged, NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32
|
Uint32
|
||||||
|
@ -119,7 +127,11 @@ SDL_GetTicks(void)
|
||||||
|
|
||||||
return (DWORD) hires_now.QuadPart;
|
return (DWORD) hires_now.QuadPart;
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef __WINRT__
|
||||||
|
now = 0;
|
||||||
|
#else
|
||||||
now = timeGetTime();
|
now = timeGetTime();
|
||||||
|
#endif // ifdef __WINRT__
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -148,6 +160,19 @@ SDL_GetPerformanceFrequency(void)
|
||||||
return frequency.QuadPart;
|
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
|
void
|
||||||
SDL_Delay(Uint32 ms)
|
SDL_Delay(Uint32 ms)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@ extern "C" {
|
||||||
#include "SDL_stdinc.h"
|
#include "SDL_stdinc.h"
|
||||||
#include "SDL_render.h"
|
#include "SDL_render.h"
|
||||||
#include "../SDL_sysvideo.h"
|
#include "../SDL_sysvideo.h"
|
||||||
#include "../../SDL_hints_c.h"
|
//#include "../../SDL_hints_c.h"
|
||||||
#include "../../events/scancodes_windows.h"
|
#include "../../events/scancodes_windows.h"
|
||||||
#include "../../events/SDL_mouse_c.h"
|
#include "../../events/SDL_mouse_c.h"
|
||||||
#include "../../events/SDL_keyboard_c.h"
|
#include "../../events/SDL_keyboard_c.h"
|
||||||
|
@ -86,7 +86,7 @@ __declspec(dllexport) int SDL_WinRT_RunApplication(SDL_WinRT_MainFunction mainFu
|
||||||
return 0;
|
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);
|
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.
|
// 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.
|
// 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_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight Portrait PortraitUpsideDown"); // DavidL: this is no longer needed (for SDL_AddHintCallback)
|
||||||
SDL_RegisterHintChangedCb(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference);
|
SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
|
void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
|
||||||
|
@ -316,15 +316,19 @@ void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEven
|
||||||
// Windows device.
|
// Windows device.
|
||||||
//
|
//
|
||||||
// Commencing hack in 3... 2... 1...
|
// 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:
|
// For now, limit the hack to when the Direct3D 11.1 is getting used:
|
||||||
const bool usingD3D11Renderer = \
|
//const bool usingD3D11Renderer = \
|
||||||
(rendererForMainWindow != NULL) &&
|
// (rendererForMainWindow != NULL) &&
|
||||||
(SDL_strcmp(rendererForMainWindow->info.name, "direct3d 11.1") == 0);
|
// (SDL_strcmp(rendererForMainWindow->info.name, "direct3d 11.1") == 0);
|
||||||
SDL_bool wasD3D11RendererResized = SDL_FALSE;
|
//SDL_bool wasD3D11RendererResized = SDL_FALSE;
|
||||||
if (usingD3D11Renderer) {
|
//if (usingD3D11Renderer) {
|
||||||
wasD3D11RendererResized = rendererForMainWindow->resized;
|
// wasD3D11RendererResized = rendererForMainWindow->resized;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Send the window-resize event to the rest of SDL, and to apps:
|
// Send the window-resize event to the rest of SDL, and to apps:
|
||||||
const int windowWidth = (int) ceil(args->Size.Width);
|
const int windowWidth = (int) ceil(args->Size.Width);
|
||||||
|
@ -335,10 +339,10 @@ void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEven
|
||||||
windowWidth,
|
windowWidth,
|
||||||
windowHeight);
|
windowHeight);
|
||||||
|
|
||||||
// Viewport hack, part two:
|
//// Viewport hack, part two:
|
||||||
if (usingD3D11Renderer) {
|
//if (usingD3D11Renderer) {
|
||||||
rendererForMainWindow->resized = wasD3D11RendererResized;
|
// rendererForMainWindow->resized = wasD3D11RendererResized;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue