Pyrogenesis  trunk
Globals.h
Go to the documentation of this file.
1 /* Copyright (C) 2012 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_PS_GLOBALS
19 #define INCLUDED_PS_GLOBALS
20 
21 #include "lib/input.h"
22 #include "lib/frequency_filter.h"
23 
24 #include <map>
25 
26 // thin abstraction layer on top of SDL.
27 // game code should use it instead of SDL_GetMouseState etc. because
28 // Atlas does not completely emulate SDL (it can only send events).
29 
30 extern bool g_app_minimized;
31 extern bool g_app_has_focus;
32 
33 extern int g_mouse_x, g_mouse_y;
34 
35 /**
36  * Indicates whether the mouse is focused on the game window (mouse positions
37  * should usually be considered inaccurate if this is false)
38  */
39 extern bool g_mouse_active;
40 
41 /**
42  * g_keys: Key states, indexed by SDLK* constants. If an entry is true,
43  * it represents a pressed key.
44  * Updated by GlobalsInputHandler in response to key press/release events.
45  */
46 extern std::map<int32_t, bool> g_keys;
47 
48 /**
49  * g_mouse_buttons: Mouse buttons states, indexed by SDL_BUTTON_* constants.
50  * If an entry is true, it represents a pressed button.
51  * Updated by GlobalsInputHandler in response to mouse button up/down events.
52  *
53  * Be aware that SDL_BUTTON_* constants start at 1. Therefore,
54  * g_mouse_buttons[0] is unused. The order of entries is:
55  * { unused, left, right, middle, wheel up, wheel down }
56  */
57 extern bool g_mouse_buttons[6];
58 
59 extern InReaction GlobalsInputHandler(const SDL_Event_* ev);
60 
62 
63 #endif // INCLUDED_PS_GLOBALS
bool g_app_minimized
Definition: Globals.cpp:26
Definition: libsdl.h:51
shared_ptr< IFrequencyFilter > PIFrequencyFilter
Definition: frequency_filter.h:40
bool g_app_has_focus
Definition: Globals.cpp:27
std::map< int32_t, bool > g_keys
g_keys: Key states, indexed by SDLK* constants.
Definition: Globals.cpp:29
InReaction GlobalsInputHandler(const SDL_Event_ *ev)
Definition: Globals.cpp:40
InReaction
Definition: input.h:34
PIFrequencyFilter g_frequencyFilter
Definition: Globals.cpp:37
bool g_mouse_buttons[6]
g_mouse_buttons: Mouse buttons states, indexed by SDL_BUTTON_* constants.
Definition: Globals.cpp:35
int g_mouse_x
Definition: Globals.cpp:30
bool g_mouse_active
Indicates whether the mouse is focused on the game window (mouse positions should usually be consider...
Definition: Globals.cpp:31
int g_mouse_y
Definition: Globals.cpp:30