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