Pyrogenesis
trunk
source
ps
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.
22
#include "
lib/external_libraries/libsdl.h
"
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
36
UNIFIED_SHIFT
,
37
UNIFIED_CTRL
,
38
UNIFIED_ALT
,
39
UNIFIED_SUPER
,
40
UNIFIED_LAST
,
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.
45
MOUSE_BASE
,
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
50
MOUSE_WHEELUP
=
MOUSE_BASE
+ 4,
51
MOUSE_WHEELDOWN
=
MOUSE_BASE
+ 5,
52
MOUSE_X1
=
MOUSE_BASE
+ SDL_BUTTON_X1 + 2,
53
MOUSE_X2
=
MOUSE_BASE
+ SDL_BUTTON_X2 + 2,
54
MOUSE_LAST
,
55
};
56
57
#endif
// #ifndef INCLUDED_KEYNAME
CStr.h
FindScancode
SDL_Scancode FindScancode(const CStr8 &keyname)
Definition:
KeyName.cpp:89
FindScancodeName
CStr8 FindScancodeName(SDL_Scancode scancode)
Definition:
KeyName.cpp:113
EXTRA_KEYS_BASE
@ EXTRA_KEYS_BASE
Definition:
KeyName.h:34
MOUSE_RIGHT
@ MOUSE_RIGHT
Definition:
KeyName.h:48
MOUSE_X1
@ MOUSE_X1
Definition:
KeyName.h:52
UNIFIED_LAST
@ UNIFIED_LAST
Definition:
KeyName.h:40
MOUSE_LAST
@ MOUSE_LAST
Definition:
KeyName.h:54
MOUSE_MIDDLE
@ MOUSE_MIDDLE
Definition:
KeyName.h:47
MOUSE_WHEELUP
@ MOUSE_WHEELUP
Definition:
KeyName.h:50
MOUSE_X2
@ MOUSE_X2
Definition:
KeyName.h:53
MOUSE_BASE
@ MOUSE_BASE
Definition:
KeyName.h:45
UNIFIED_SHIFT
@ UNIFIED_SHIFT
Definition:
KeyName.h:36
UNIFIED_SUPER
@ UNIFIED_SUPER
Definition:
KeyName.h:39
UNIFIED_ALT
@ UNIFIED_ALT
Definition:
KeyName.h:38
MOUSE_WHEELDOWN
@ MOUSE_WHEELDOWN
Definition:
KeyName.h:51
UNIFIED_CTRL
@ UNIFIED_CTRL
Definition:
KeyName.h:37
MOUSE_LEFT
@ MOUSE_LEFT
Definition:
KeyName.h:46
FindKeyName
CStr8 FindKeyName(SDL_Scancode scancode)
Definition:
KeyName.cpp:171
libsdl.h
Generated by
1.9.4