Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
WinRT: got timers working
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLudwig committed Nov 24, 2012
1 parent 4cf5dbc commit caefb64
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VisualC/SDL/SDL_VS2012_WinRT.vcxproj
Expand Up @@ -94,8 +94,8 @@
<ClCompile Include="..\..\src\thread\stdcpp\SDL_syscond.cpp" />
<ClCompile Include="..\..\src\thread\stdcpp\SDL_sysmutex.cpp" />
<ClCompile Include="..\..\src\thread\stdcpp\SDL_systhread.cpp" />
<ClCompile Include="..\..\src\timer\dummy\SDL_systimer.c" />
<ClCompile Include="..\..\src\timer\SDL_timer.c" />
<ClCompile Include="..\..\src\timer\windows\SDL_systimer.c" />
<ClCompile Include="..\..\src\video\dummy\SDL_nullevents.c" />
<ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c" />
<ClCompile Include="..\..\src\video\dummy\SDL_nullvideo.c" />
Expand Down
5 changes: 1 addition & 4 deletions include/SDL_config_windowsrt.h
Expand Up @@ -154,10 +154,7 @@ typedef unsigned int uintptr_t;
#define SDL_THREAD_STDCPP 1

/* Enable various timer systems */
// TODO, WinRT: look into getting SDL's pre-WinRT timers working.
// Some functions there are supported in WinRT, others are not.
//#define SDL_TIMER_WINDOWS 1
#define SDL_TIMERS_DISABLED 1
#define SDL_TIMER_WINDOWS 1

/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_WINRT 1
Expand Down
23 changes: 22 additions & 1 deletion src/timer/windows/SDL_systimer.c
Expand Up @@ -48,16 +48,20 @@ SDL_StartTicks(void)
#ifdef USE_GETTICKCOUNT
start = GetTickCount();
#else
#if 0 /* Apparently there are problems with QPC on Win2K */
#ifdef __WINRT__ /* Apparently there are problems with QPC on Win2K */
if (QueryPerformanceFrequency(&hires_ticks_per_second) == TRUE) {
hires_timer_available = TRUE;
QueryPerformanceCounter(&hires_start_ticks);
} else
#endif
{
hires_timer_available = FALSE;
#ifdef __WINRT__
start = 0; /* the timer failed to start! */
#else
timeBeginPeriod(1); /* use 1 ms timer precision */
start = timeGetTime();
#endif
}
#endif
}
Expand All @@ -82,7 +86,11 @@ SDL_GetTicks(void)

return (DWORD) hires_now.QuadPart;
} else {
#ifdef __WINRT__
now = 0;
#else
now = timeGetTime();
#endif
}
#endif

Expand Down Expand Up @@ -116,6 +124,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)
{
Expand Down

0 comments on commit caefb64

Please sign in to comment.