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_KEYNAME
19 #define INCLUDED_KEYNAME
20 
21 // Need SDLK_* enum values.
22 #include "lib/external_libraries/libsdl.h"
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
35 	UNIFIED_SHIFT,
36 	UNIFIED_CTRL,
37 	UNIFIED_ALT,
38 	UNIFIED_SUPER,
39 	UNIFIED_LAST,
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.
44 	MOUSE_BASE,
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
49 	MOUSE_WHEELUP = MOUSE_BASE + 4,
50 	MOUSE_WHEELDOWN = MOUSE_BASE + 5,
51 	MOUSE_X1 = MOUSE_BASE + SDL_BUTTON_X1 + 2,
52 	MOUSE_X2 = MOUSE_BASE + SDL_BUTTON_X2 + 2,
53 	MOUSE_LAST,
54 };
55 
56 #endif	// #ifndef INCLUDED_KEYNAME
57