Pyrogenesis  trunk
Hotkey.h
Go to the documentation of this file.
1 /* Copyright (C) 2014 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_HOTKEY
19 #define INCLUDED_HOTKEY
20 
21 /**
22  * @file
23  * Hotkey system.
24  *
25  * Hotkeys consist of a name (an arbitrary string), and a key mapping.
26  * The names and mappings are loaded from the config system (any
27  * config setting with the name prefix "hotkey.").
28  * When a hotkey is pressed or released, SDL_HOTKEYDOWN and SDL_HOTKEYUP
29  * events are triggered, with the hotkey name stored in ev.user.data1
30  * as a const char*.
31  */
32 
33 #include "CStr.h"
34 #include "lib/input.h"
35 #include "lib/external_libraries/libsdl.h" // see note below
36 
37 // note: we need the real SDL header - it defines SDL_USEREVENT, which is
38 // required for our HOTKEY event type definition. this is OK since
39 // hotkey.h is not included from any headers.
40 
41 const int SDL_HOTKEYDOWN = SDL_USEREVENT;
42 const int SDL_HOTKEYUP = SDL_USEREVENT + 1;
43 
44 extern void LoadHotkeys();
45 extern void UnloadHotkeys();
46 extern InReaction HotkeyInputHandler(const SDL_Event_* ev);
47 
48 extern bool HotkeyIsPressed(const CStr& keyname);
49 
50 #endif // INCLUDED_HOTKEY
InReaction HotkeyInputHandler(const SDL_Event_ *ev)
Definition: Hotkey.cpp:154
Definition: libsdl.h:51
const int SDL_HOTKEYUP
Definition: Hotkey.h:42
InReaction
Definition: input.h:34
const int SDL_HOTKEYDOWN
Definition: Hotkey.h:41
void UnloadHotkeys()
Definition: Hotkey.cpp:133
bool HotkeyIsPressed(const CStr &keyname)
Definition: Hotkey.cpp:344
void LoadHotkeys()
Definition: Hotkey.cpp:107