1 /**
2  * Copyright (c) 2006-2016 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 
21 #ifndef LOVE_EVENT_SDL_EVENT_H
22 #define LOVE_EVENT_SDL_EVENT_H
23 
24 // LOVE
25 #include "event/Event.h"
26 
27 // SDL
28 #include <SDL_events.h>
29 
30 // STL
31 #include <map>
32 
33 namespace love
34 {
35 namespace event
36 {
37 namespace sdl
38 {
39 
40 class Event : public love::event::Event
41 {
42 public:
43 
44 	// Implements Module.
45 	const char *getName() const;
46 
47 	Event();
48 	virtual ~Event();
49 
50 	/**
51 	 * Pumps the event queue. This function gathers all the pending input information
52 	 * from devices and places it on the event queue. Normally not needed if you poll
53 	 * for events.
54 	 **/
55 	void pump();
56 
57 	/**
58 	 * Waits for the next event (indefinitely). Useful for creating games where
59 	 * the screen and game state only needs updating when the user interacts with
60 	 * the window.
61 	 **/
62 	Message *wait();
63 
64 	/**
65 	 * Clears the event queue.
66 	 */
67 	void clear();
68 
69 private:
70 
71 	Message *convert(const SDL_Event &e) const;
72 	Message *convertJoystickEvent(const SDL_Event &e) const;
73 	Message *convertWindowEvent(const SDL_Event &e) const;
74 
75 	static std::map<SDL_Keycode, love::keyboard::Keyboard::Key> createKeyMap();
76 	static std::map<SDL_Keycode, love::keyboard::Keyboard::Key> keys;
77 
78 }; // Event
79 
80 } // sdl
81 } // event
82 } // love
83 
84 #endif // LOVE_EVENT_SDL_EVENT_H
85