Pyrogenesis  trunk
KeyName.h
Go to the documentation of this file.
1 /* Copyright (C) 2021 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 #include "ps/CStr.h"
24 
25 extern SDL_Scancode FindScancode(const CStr8& keyname);
26 // Map a scancode to a locale-independent scancode name.
27 extern CStr8 FindScancodeName(SDL_Scancode scancode);
28 // Map a scancode to a locale-dependent key name (to show the user).
29 extern CStr8 FindKeyName(SDL_Scancode scancode);
30 
31 enum {
32  // Start sequential IDs in the right place
33  // Pick a code which is greater than any scancodes used by SDL itself
34  EXTRA_KEYS_BASE = SDL_NUM_SCANCODES,
35  // 'Keycodes' for the unified modifier keys
41  // 'Keycodes' for the mouse buttons
42  // Base for mouse buttons.
43  // Everything less than MOUSE_BASE is not reported by an SDL mouse button event.
44  // Everything greater than MOUSE_BASE is reported by an SDL mouse button event.
46  MOUSE_LEFT = MOUSE_BASE + SDL_BUTTON_LEFT,
47  MOUSE_MIDDLE = MOUSE_BASE + SDL_BUTTON_MIDDLE,
48  MOUSE_RIGHT = MOUSE_BASE + SDL_BUTTON_RIGHT,
49  // SDL2 doesn't count wheels as buttons, so just give them the previous sequential IDs
52  MOUSE_X1 = MOUSE_BASE + SDL_BUTTON_X1 + 2,
53  MOUSE_X2 = MOUSE_BASE + SDL_BUTTON_X2 + 2,
55 };
56 
57 #endif // #ifndef INCLUDED_KEYNAME
Definition: KeyName.h:53
Definition: KeyName.h:54
Definition: KeyName.h:36
Definition: KeyName.h:40
Definition: KeyName.h:47
Definition: KeyName.h:38
Definition: KeyName.h:50
Definition: KeyName.h:46
Definition: KeyName.h:48
Definition: KeyName.h:52
CStr8 FindKeyName(SDL_Scancode scancode)
Definition: KeyName.cpp:171
Definition: KeyName.h:51
Definition: KeyName.h:45
CStr8 FindScancodeName(SDL_Scancode scancode)
Definition: KeyName.cpp:113
Definition: KeyName.h:37
Definition: KeyName.h:34
Definition: KeyName.h:39
SDL_Scancode FindScancode(const CStr8 &keyname)
Definition: KeyName.cpp:89