Pyrogenesis  trunk
KeyName.h
Go to the documentation of this file.
1 /* Copyright (C) 2015 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_KEYNAME
19 #define INCLUDED_KEYNAME
20 
21 // Need SDLK_* enum values.
23 
24 class CStr8;
25 
26 extern void InitKeyNameMap();
27 extern CStr8 FindKeyName(int keycode);
28 extern int FindKeyCode(const CStr8& keyname);
29 
30 enum {
31  // Start sequential IDs in the right place
32  // Pick a code which is greater than any keycodes used by SDL itself
33  EXTRA_KEYS_BASE = SDL_SCANCODE_TO_KEYCODE(SDL_NUM_SCANCODES),
34  // 'Keycodes' for the unified modifier keys
40  // 'Keycodes' for the mouse buttons
41  // Base for mouse buttons.
42  // Everything less than MOUSE_BASE is not reported by an SDL mouse button event.
43  // Everything greater than MOUSE_BASE is reported by an SDL mouse button event.
45  MOUSE_LEFT = MOUSE_BASE + SDL_BUTTON_LEFT,
46  MOUSE_MIDDLE = MOUSE_BASE + SDL_BUTTON_MIDDLE,
47  MOUSE_RIGHT = MOUSE_BASE + SDL_BUTTON_RIGHT,
48  // SDL2 doesn't count wheels as buttons, so just give them the previous sequential IDs
51  MOUSE_X1 = MOUSE_BASE + SDL_BUTTON_X1 + 2,
52  MOUSE_X2 = MOUSE_BASE + SDL_BUTTON_X2 + 2,
53 };
54 
55 #endif // #ifndef INCLUDED_KEYNAME
CStr8 FindKeyName(int keycode)
Definition: KeyName.cpp:229
Definition: KeyName.h:33
Definition: KeyName.h:52
Definition: KeyName.h:50
Definition: KeyName.h:38
Definition: KeyName.h:39
Definition: KeyName.h:47
int FindKeyCode(const CStr8 &keyname)
Definition: KeyName.h:46
Definition: KeyName.h:51
Definition: KeyName.h:36
Definition: KeyName.h:45
Definition: KeyName.h:35
Definition: KeyName.h:49
Definition: KeyName.h:37
void InitKeyNameMap()
Definition: KeyName.cpp:203
Definition: KeyName.h:44