Event.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * Copyright (c) 2006-2009 LOVE Development Team
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. *
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute it
  10. * freely, subject to the following restrictions:
  11. *
  12. * 1. The origin of this software must not be misrepresented; you must not
  13. * claim that you wrote the original software. If you use this software
  14. * in a product, an acknowledgment in the product documentation would be
  15. * appreciated but is not required.
  16. * 2. Altered source versions must be plainly marked as such, and must not be
  17. * misrepresented as being the original software.
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. **/
  20. #ifndef LOVE_EVENT_SDL_EVENT_H
  21. #define LOVE_EVENT_SDL_EVENT_H
  22. // LOVE
  23. #include <event/Event.h>
  24. #include <common/runtime.h>
  25. // SDL
  26. #include <SDL.h>
  27. namespace love
  28. {
  29. namespace event
  30. {
  31. namespace sdl
  32. {
  33. class Event : public event::Event
  34. {
  35. public:
  36. // Implements Module.
  37. const char * getName() const;
  38. /**
  39. * Pumps the event queue. This function gathers all the pending input information
  40. * from devices and places it on the event queue. Normally not needed if you poll
  41. * for events.
  42. **/
  43. void pump();
  44. /**
  45. * Returns an iterator function for iterating over pending events.
  46. **/
  47. int poll(lua_State * L);
  48. /**
  49. * Waits for the next event (indefinitely). Useful for creating games where
  50. * the screen and game state only needs updating when the user interacts with
  51. * the window.
  52. **/
  53. int wait(lua_State * L);
  54. /**
  55. * Push a quit event. Calling this does not mean the application
  56. * will exit immediately, it just means an quit event will be issued.
  57. * How to respond to the quit event is up the application.
  58. **/
  59. void quit();
  60. /**
  61. * Pushes an event into the queue.
  62. **/
  63. int push(lua_State * L);
  64. /**
  65. * The iterator function.
  66. **/
  67. static int poll_i(lua_State * L);
  68. static int wait_i(lua_State * L);
  69. private:
  70. static int pushEvent(lua_State * L, SDL_Event & e);
  71. static int getEvent(lua_State * L, SDL_Event & e);
  72. }; // System
  73. } // sdl
  74. } // event
  75. } // love
  76. #endif // LOVE_EVENT_SDL_EVENT_H