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