46 #define TIMER_RESOLUTION 10 /* Experimentally determined */ |
46 #define TIMER_RESOLUTION 10 /* Experimentally determined */ |
47 |
47 |
48 /* Get the number of milliseconds since the SDL library initialization. |
48 /* Get the number of milliseconds since the SDL library initialization. |
49 * Note that this value wraps if the program runs for more than ~49 days. |
49 * Note that this value wraps if the program runs for more than ~49 days. |
50 */ |
50 */ |
51 extern DECLSPEC Uint32 SDL_GetTicks(void); |
51 extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); |
52 |
52 |
53 /* Wait a specified number of milliseconds before returning */ |
53 /* Wait a specified number of milliseconds before returning */ |
54 extern DECLSPEC void SDL_Delay(Uint32 ms); |
54 extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); |
55 |
55 |
56 /* Function prototype for the timer callback function */ |
56 /* Function prototype for the timer callback function */ |
57 typedef Uint32 (*SDL_TimerCallback)(Uint32 interval); |
57 typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval); |
58 |
58 |
59 /* Set a callback to run after the specified number of milliseconds has |
59 /* Set a callback to run after the specified number of milliseconds has |
60 * elapsed. The callback function is passed the current timer interval |
60 * elapsed. The callback function is passed the current timer interval |
61 * and returns the next timer interval. If the returned value is the |
61 * and returns the next timer interval. If the returned value is the |
62 * same as the one passed in, the periodic alarm continues, otherwise a |
62 * same as the one passed in, the periodic alarm continues, otherwise a |
80 * Under UNIX, you should not use raise or use SIGALRM and this function |
80 * Under UNIX, you should not use raise or use SIGALRM and this function |
81 * in the same program, as it is implemented using setitimer(). You also |
81 * in the same program, as it is implemented using setitimer(). You also |
82 * should not use this function in multi-threaded applications as signals |
82 * should not use this function in multi-threaded applications as signals |
83 * to multi-threaded apps have undefined behavior in some implementations. |
83 * to multi-threaded apps have undefined behavior in some implementations. |
84 */ |
84 */ |
85 extern DECLSPEC int SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback); |
85 extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback); |
86 |
86 |
87 /* New timer API, supports multiple timers |
87 /* New timer API, supports multiple timers |
88 * Written by Stephane Peter <megastep@lokigames.com> |
88 * Written by Stephane Peter <megastep@lokigames.com> |
89 */ |
89 */ |
90 |
90 |
92 * The callback function is passed the current timer interval and returns |
92 * The callback function is passed the current timer interval and returns |
93 * the next timer interval. If the returned value is the same as the one |
93 * the next timer interval. If the returned value is the same as the one |
94 * passed in, the periodic alarm continues, otherwise a new alarm is |
94 * passed in, the periodic alarm continues, otherwise a new alarm is |
95 * scheduled. If the callback returns 0, the periodic alarm is cancelled. |
95 * scheduled. If the callback returns 0, the periodic alarm is cancelled. |
96 */ |
96 */ |
97 typedef Uint32 (*SDL_NewTimerCallback)(Uint32 interval, void *param); |
97 typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param); |
98 |
98 |
99 /* Definition of the timer ID type */ |
99 /* Definition of the timer ID type */ |
100 typedef struct _SDL_TimerID *SDL_TimerID; |
100 typedef struct _SDL_TimerID *SDL_TimerID; |
101 |
101 |
102 /* Add a new timer to the pool of timers already running. |
102 /* Add a new timer to the pool of timers already running. |
103 Returns a timer ID, or NULL when an error occurs. |
103 Returns a timer ID, or NULL when an error occurs. |
104 */ |
104 */ |
105 extern DECLSPEC SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); |
105 extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); |
106 |
106 |
107 /* Remove one of the multiple timers knowing its ID. |
107 /* Remove one of the multiple timers knowing its ID. |
108 * Returns a boolean value indicating success. |
108 * Returns a boolean value indicating success. |
109 */ |
109 */ |
110 extern DECLSPEC SDL_bool SDL_RemoveTimer(SDL_TimerID t); |
110 extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); |
111 |
111 |
112 /* Ends C function definitions when using C++ */ |
112 /* Ends C function definitions when using C++ */ |
113 #ifdef __cplusplus |
113 #ifdef __cplusplus |
114 } |
114 } |
115 #endif |
115 #endif |