Pyrogenesis trunk
Globals.h
Go to the documentation of this file.
1/* Copyright (C) 2017 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"
23#include "ps/KeyName.h"
24
25#include <unordered_map>
26
27// thin abstraction layer on top of SDL.
28// game code should use it instead of SDL_GetMouseState etc. because
29// Atlas does not completely emulate SDL (it can only send events).
30
31extern bool g_app_minimized;
32extern bool g_app_has_focus;
33
34extern int g_mouse_x, g_mouse_y;
35
36/**
37 * Indicates whether the mouse is focused on the game window (mouse positions
38 * should usually be considered inaccurate if this is false)
39 */
40extern bool g_mouse_active;
41
42/**
43 * g_scancodes: Key states, indexed by SDL_Scancode constants. If an entry is true,
44 * it represents a pressed key.
45 * Updated by GlobalsInputHandler in response to key press/release events.
46 */
47extern std::unordered_map<int32_t, bool> g_scancodes;
48
49/**
50 * g_mouse_buttons: Mouse buttons states, indexed by SDL_BUTTON_* constants.
51 * If an entry is true, it represents a pressed button.
52 * Updated by GlobalsInputHandler in response to mouse button up/down events.
53 *
54 * Be aware that SDL_BUTTON_* constants start at 1. Therefore,
55 * g_mouse_buttons[0] is unused. The order of entries is as in KeyName.h for MOUSE_*
56 */
58
60
62
63#endif // INCLUDED_PS_GLOBALS
bool g_mouse_buttons[MOUSE_LAST - MOUSE_BASE]
g_mouse_buttons: Mouse buttons states, indexed by SDL_BUTTON_* constants.
Definition: Globals.cpp:34
int g_mouse_y
Definition: Globals.h:34
std::unordered_map< int32_t, bool > g_scancodes
g_scancodes: Key states, indexed by SDL_Scancode constants.
Definition: Globals.cpp:28
int g_mouse_x
Definition: Globals.cpp:30
bool g_app_has_focus
Definition: Globals.cpp:26
PIFrequencyFilter g_frequencyFilter
Definition: Globals.cpp:36
bool g_app_minimized
Definition: Globals.cpp:25
bool g_mouse_active
Indicates whether the mouse is focused on the game window (mouse positions should usually be consider...
Definition: Globals.cpp:31
InReaction GlobalsInputHandler(const SDL_Event_ *ev)
Definition: Globals.cpp:39
@ MOUSE_LAST
Definition: KeyName.h:54
@ MOUSE_BASE
Definition: KeyName.h:45
std::shared_ptr< IFrequencyFilter > PIFrequencyFilter
Definition: frequency_filter.h:40
InReaction
Definition: input.h:35
Definition: libsdl.h:53