UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cl_keys.h
Go to the documentation of this file.
1 
6 /*
7 All original material Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 Original file from Quake 2 v3.21: quake2-2.31/client/keys.h
10 Copyright (C) 1997-2001 Id Software, Inc.
11 
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 as published by the Free Software Foundation; either version 2
15 of the License, or (at your option) any later version.
16 
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 
21 See the GNU General Public License for more details.
22 
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 
27 */
28 
29 #pragma once
30 
31 /* these are the key numbers that should be passed to KeyEvent */
32 
33 /* normal keys should be passed as lowercased ascii */
34 
35 typedef enum {
37 
39  K_TAB = 9,
40  K_ENTER = 13,
41  K_PAUSE = 19,
42  K_ESCAPE = 27,
43  K_SPACE = 32,
44  K_DEL = 127,
45 
46  K_MOUSE1 = 200,
47  K_MOUSE2 = 201,
48  K_MOUSE3 = 202,
49  K_MWHEELDOWN = 239,
50  K_MWHEELUP = 240,
51  K_MOUSE4 = 241,
52  K_MOUSE5 = 242,
53 
54  K_KP_INS = 256,
55  K_KP_END = 257,
57  K_KP_PGDN = 259,
59  K_KP_5 = 261,
61  K_KP_HOME = 263,
62  K_KP_UPARROW = 264,
63  K_KP_PGUP = 265,
64  K_KP_DEL = 266,
65  K_KP_SLASH = 267,
67  K_KP_MINUS = 269,
68  K_KP_PLUS = 270,
69  K_KP_ENTER = 271,
70  K_KP_NUMLOCK = 272,
71 
72  K_UPARROW = 273,
73  K_DOWNARROW = 274,
74  K_RIGHTARROW = 275,
75  K_LEFTARROW = 276,
76 
77  K_HOME = 278,
78  K_END = 279,
79  K_PGUP = 280,
80  K_PGDN = 281,
81  K_F1 = 282,
82  K_F2 = 283,
83  K_F3 = 284,
84  K_F4 = 285,
85  K_F5 = 286,
86  K_F6 = 287,
87  K_F7 = 288,
88  K_F8 = 289,
89  K_F9 = 290,
90  K_F10 = 291,
91  K_F11 = 292,
92  K_F12 = 293,
93  K_F13 = 294,
94  K_F14 = 295,
95  K_F15 = 296,
96  K_INS = 277,
97  K_SHIFT = 304,
98  K_CTRL = 306,
99  K_ALT = 308,
100 
133 
150 
163 
168 
169  K_LAST_KEY = 511, /* to support as many chars as posible */
171 } keyNum_t;
172 
173 typedef enum {
177 
180 
181 typedef enum {
184 } keydest_t;
185 
186 #define MAXKEYLINES 32
187 
188 extern int msgMode;
189 extern char msgBuffer[MAXCMDLINE];
190 extern size_t msgBufferLen;
191 extern char keyLines[MAXKEYLINES][MAXCMDLINE];
192 extern uint32_t keyLinePos;
193 extern int historyLine;
194 extern int editLine;
195 extern char* keyBindings[K_KEY_SIZE];
196 extern char* menuKeyBindings[K_KEY_SIZE];
197 extern char* battleKeyBindings[K_KEY_SIZE];
198 
199 bool Key_IsDown(unsigned int key);
200 bool Key_IsNumlock(void);
201 void Key_SetDest(keydest_t key_dest);
202 void Key_Event(unsigned int key, unsigned short unicode, bool down, unsigned time);
203 void Key_Init(void);
204 void Key_WriteBindings(const char* filename);
205 const char* Key_GetBinding(const char* binding, keyBindSpace_t space);
206 const char* Key_KeynumToString(int keynum);
207 int Key_StringToKeynum(const char* str);
208 void Key_SetBinding(int keynum, const char* binding, keyBindSpace_t space);
int editLine
Definition: cl_keys.cpp:42
keydest_t
Definition: cl_keys.h:181
bool Key_IsNumlock(void)
Definition: cl_keys.cpp:221
Definition: cl_keys.h:79
void Key_Event(unsigned int key, unsigned short unicode, bool down, unsigned time)
Called by the system between frames for both key up and key down events.
Definition: cl_keys.cpp:845
char * keyBindings[K_KEY_SIZE]
Definition: cl_keys.cpp:63
keyNum_t
Definition: cl_keys.h:35
uint32_t keyLinePos
Definition: cl_keys.cpp:38
Definition: cl_keys.h:94
Definition: cl_keys.h:88
void Key_WriteBindings(const char *filename)
Writes lines containing "bind key value".
Definition: cl_keys.cpp:664
const char * filename
Definition: ioapi.h:41
Definition: cl_keys.h:85
keyBindSpace_t
Definition: cl_keys.h:173
Definition: cl_keys.h:39
Definition: cl_keys.h:98
unsigned short unicode
Definition: cl_input.cpp:69
unsigned int key
Definition: cl_input.cpp:68
int Key_StringToKeynum(const char *str)
Convert to given string to keynum.
Definition: cl_keys.cpp:462
void Key_SetBinding(int keynum, const char *binding, keyBindSpace_t space)
Bind a keynum to script command.
Definition: cl_keys.cpp:547
int historyLine
Definition: cl_keys.cpp:43
Definition: cl_keys.h:96
Definition: cl_keys.h:83
Definition: cl_keys.h:89
Definition: cl_keys.h:91
Definition: cl_keys.h:84
void Key_SetDest(keydest_t key_dest)
Sets the keyDest in cls.
Definition: cl_keys.cpp:815
char msgBuffer[MAXCMDLINE]
Definition: cl_keys.cpp:46
#define MAXKEYLINES
Definition: cl_keys.h:186
Definition: cl_keys.h:80
Definition: cl_keys.h:92
#define MAXCMDLINE
Definition: common.h:307
const char * Key_KeynumToString(int keynum)
Convert a given keynum to string.
Definition: cl_keys.cpp:485
Definition: cl_keys.h:77
Definition: cl_keys.h:95
Definition: cl_keys.h:99
Definition: cl_keys.h:78
Definition: cl_keys.h:93
char * battleKeyBindings[K_KEY_SIZE]
Definition: cl_keys.cpp:65
Definition: cl_keys.h:87
Definition: cl_keys.h:81
int msgMode
Definition: cl_keys.cpp:45
Definition: cl_keys.h:90
const char * Key_GetBinding(const char *binding, keyBindSpace_t space)
Return the key binding for a given script command.
Definition: cl_keys.cpp:511
Definition: cl_keys.h:44
bool Key_IsDown(unsigned int key)
Checks whether a given key is currently pressed.
Definition: cl_keys.cpp:214
const uiKeyBinding_t * binding
size_t msgBufferLen
Definition: cl_keys.cpp:47
Definition: cl_keys.h:82
Definition: cl_keys.h:59
Definition: cl_keys.h:86
void Key_Init(void)
Definition: cl_keys.cpp:776
char keyLines[MAXKEYLINES][MAXCMDLINE]
Definition: cl_keys.cpp:37
int down
Definition: cl_input.cpp:70
char * menuKeyBindings[K_KEY_SIZE]
Definition: cl_keys.cpp:64