diff src/timer/wince/SDL_systimer.c @ 5131:2c500f37abcf

merged: might need to check main.c in the iOS template to make sure no changes were abandoned.
author Eric Wing <ewing . public |-at-| gmail . com>
date Tue, 01 Feb 2011 00:37:02 -0800
parents 481dabb098ef
children b530ef003506
line wrap: on
line diff
--- a/src/timer/wince/SDL_systimer.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/timer/wince/SDL_systimer.c	Tue Feb 01 00:37:02 2011 -0800
@@ -23,13 +23,9 @@
 
 #ifdef SDL_TIMER_WINCE
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <mmsystem.h>
+#include "../../core/windows/SDL_windows.h"
 
-#include "SDL_thread.h"
 #include "SDL_timer.h"
-#include "../SDL_timer_c.h"
 
 static Uint64 start_date;
 static Uint64 start_ticks;
@@ -70,6 +66,14 @@
     return ((Sint32) (wce_date() - start_date));
 }
 
+/* Recard start-time of application for reference */
+void
+SDL_StartTicks(void)
+{
+    start_date = wce_date();
+    start_ticks = wce_ticks();
+}
+
 /* Return time in ms relative to when SDL was started */
 Uint32
 SDL_GetTicks()
@@ -90,122 +94,6 @@
     Sleep(ms);
 }
 
-/* Recard start-time of application for reference */
-void
-SDL_StartTicks(void)
-{
-    start_date = wce_date();
-    start_ticks = wce_ticks();
-}
-
-static UINT WIN_timer;
-
-#if ( _WIN32_WCE <= 420 )
-
-static HANDLE timersThread = 0;
-static HANDLE timersQuitEvent = 0;
-
-DWORD
-TimersThreadProc(void *data)
-{
-    while (WaitForSingleObject(timersQuitEvent, 10) == WAIT_TIMEOUT) {
-        SDL_ThreadedTimerCheck();
-    }
-    return 0;
-}
-
-int
-SDL_SYS_TimerInit(void)
-{
-    // create a thread to process a threaded timers
-    // SetTimer does not suit the needs because 
-    // TimerCallbackProc will be called only when WM_TIMER occured
-
-    timersQuitEvent = CreateEvent(0, TRUE, FALSE, 0);
-    if (!timersQuitEvent) {
-        SDL_SetError("Cannot create event for timers thread");
-        return -1;
-    }
-    timersThread = CreateThread(NULL, 0, TimersThreadProc, 0, 0, 0);
-    if (!timersThread) {
-        SDL_SetError
-            ("Cannot create timers thread, check amount of RAM available");
-        return -1;
-    }
-    SetThreadPriority(timersThread, THREAD_PRIORITY_HIGHEST);
-
-    return (SDL_SetTimerThreaded(1));
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    SetEvent(timersQuitEvent);
-    if (WaitForSingleObject(timersThread, 2000) == WAIT_TIMEOUT)
-        TerminateThread(timersThread, 0);
-    CloseHandle(timersThread);
-    CloseHandle(timersQuitEvent);
-    return;
-}
-
-#else
+#endif /* SDL_TIMER_WINCE */
 
-#pragma comment(lib, "mmtimer.lib")
-
-/* Data to handle a single periodic alarm */
-static UINT timerID = 0;
-
-static void CALLBACK
-HandleAlarm(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
-{
-    SDL_ThreadedTimerCheck();
-}
-
-
-int
-SDL_SYS_TimerInit(void)
-{
-    MMRESULT result;
-
-    /* Set timer resolution */
-    result = timeBeginPeriod(TIMER_RESOLUTION);
-    if (result != TIMERR_NOERROR) {
-        SDL_SetError("Warning: Can't set %d ms timer resolution",
-                     TIMER_RESOLUTION);
-    }
-    /* Allow 10 ms of drift so we don't chew on CPU */
-    timerID =
-        timeSetEvent(TIMER_RESOLUTION, 1, HandleAlarm, 0, TIME_PERIODIC);
-    if (!timerID) {
-        SDL_SetError("timeSetEvent() failed");
-        return (-1);
-    }
-    return (SDL_SetTimerThreaded(1));
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    if (timerID) {
-        timeKillEvent(timerID);
-    }
-    timeEndPeriod(TIMER_RESOLUTION);
-}
-
-#endif
-
-int
-SDL_SYS_StartTimer(void)
-{
-    SDL_SetError("Internal logic error: WinCE uses threaded timer");
-    return (-1);
-}
-
-void
-SDL_SYS_StopTimer(void)
-{
-    return;
-}
-
-#endif /* SDL_TIMER_WINCE */
 /* vi: set ts=4 sw=4 expandtab: */