SDL_timer.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. SDL - Simple DirectMedia Layer
  3. Copyright (C) 1997-2011 Sam Lantinga
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. Sam Lantinga
  16. [email protected]
  17. */
  18. #ifndef _SDL_timer_h
  19. #define _SDL_timer_h
  20. /**
  21. * \file SDL_timer.h
  22. *
  23. * Header for the SDL time management routines.
  24. */
  25. #include "SDL_stdinc.h"
  26. #include "SDL_error.h"
  27. #include "begin_code.h"
  28. /* Set up for C function definitions, even when using C++ */
  29. #ifdef __cplusplus
  30. /* *INDENT-OFF* */
  31. extern "C" {
  32. /* *INDENT-ON* */
  33. #endif
  34. /**
  35. * \brief Get the number of milliseconds since the SDL library initialization.
  36. *
  37. * \note This value wraps if the program runs for more than ~49 days.
  38. */
  39. extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
  40. /**
  41. * \brief Wait a specified number of milliseconds before returning.
  42. */
  43. extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
  44. /**
  45. * Function prototype for the timer callback function.
  46. *
  47. * The callback function is passed the current timer interval and returns
  48. * the next timer interval. If the returned value is the same as the one
  49. * passed in, the periodic alarm continues, otherwise a new alarm is
  50. * scheduled. If the callback returns 0, the periodic alarm is cancelled.
  51. */
  52. typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param);
  53. /**
  54. * Definition of the timer ID type.
  55. */
  56. typedef int SDL_TimerID;
  57. /**
  58. * \brief Add a new timer to the pool of timers already running.
  59. *
  60. * \return A timer ID, or NULL when an error occurs.
  61. */
  62. extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
  63. SDL_TimerCallback callback,
  64. void *param);
  65. /**
  66. * \brief Remove a timer knowing its ID.
  67. *
  68. * \return A boolean value indicating success or failure.
  69. *
  70. * \warning It is not safe to remove a timer multiple times.
  71. */
  72. extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t);
  73. /* Ends C function definitions when using C++ */
  74. #ifdef __cplusplus
  75. /* *INDENT-OFF* */
  76. }
  77. /* *INDENT-ON* */
  78. #endif
  79. #include "close_code.h"
  80. #endif /* _SDL_timer_h */
  81. /* vi: set ts=4 sw=4 expandtab: */