DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
keys.c File Reference
#include "quakedef.h"
#include "cl_video.h"
#include "utf8lib.h"
#include "csprogs.h"
+ Include dependency graph for keys.c:

Go to the source code of this file.

Data Structures

struct  eventqueueitem_t
 
struct  keyname_t
 

Macros

#define KM_ALT   (!keydown[K_CTRL] && !keydown[K_SHIFT] && keydown[K_ALT])
 
#define KM_CTRL   ( keydown[K_CTRL] && !keydown[K_SHIFT] && !keydown[K_ALT])
 
#define KM_CTRL_ALT   ( keydown[K_CTRL] && !keydown[K_SHIFT] && keydown[K_ALT])
 
#define KM_CTRL_SHIFT   ( keydown[K_CTRL] && keydown[K_SHIFT] && !keydown[K_ALT])
 
#define KM_CTRL_SHIFT_ALT   ( keydown[K_CTRL] && keydown[K_SHIFT] && keydown[K_ALT])
 
#define KM_NONE   (!keydown[K_CTRL] && !keydown[K_SHIFT] && !keydown[K_ALT])
 
#define KM_SHIFT   (!keydown[K_CTRL] && keydown[K_SHIFT] && !keydown[K_ALT])
 
#define KM_SHIFT_ALT   (!keydown[K_CTRL] && keydown[K_SHIFT] && keydown[K_ALT])
 

Functions

int Key_AddChar (int unicode, qbool is_console)
 
static void Key_Bind_f (cmd_state_t *cmd)
 
static void Key_BindList_f (cmd_state_t *cmd)
 
int Key_ClearEditLine (qbool is_console)
 
static void Key_Console (cmd_state_t *cmd, int key, int unicode)
 
static int Key_Convert_NumPadKey (int key)
 
void Key_Event (int key, int ascii, qbool down)
 
static void Key_EventQueue_Add (int key, int ascii, qbool down)
 
void Key_EventQueue_Block (void)
 
void Key_EventQueue_Unblock (void)
 
void Key_FindKeysForCommand (const char *command, int *keys, int numkeys, int bindmap)
 
const char * Key_GetBind (int key, int bindmap)
 
void Key_GetBindMap (int *fg, int *bg)
 
static void Key_History_Down (void)
 
static void Key_History_f (cmd_state_t *cmd)
 
static void Key_History_Find_All (void)
 
static void Key_History_Find_Backwards (void)
 
static void Key_History_Find_Forwards (void)
 
static void Key_History_First (void)
 
static qbool Key_History_Get_foundCommand (void)
 
static void Key_History_Init (void)
 
static void Key_History_Last (void)
 
static void Key_History_Push (void)
 
static void Key_History_Shutdown (void)
 
static void Key_History_Up (void)
 
static void Key_In_Bind_f (cmd_state_t *cmd)
 
static void Key_In_BindList_f (cmd_state_t *cmd)
 
static void Key_In_Bindmap_f (cmd_state_t *cmd)
 
static void Key_In_Unbind_f (cmd_state_t *cmd)
 
void Key_Init (void)
 
const char * Key_KeynumToString (int keynum, char *tinystr, size_t tinystrlength)
 
static void Key_Message (cmd_state_t *cmd, int key, int ascii)
 
int Key_Parse_CommonKeys (cmd_state_t *cmd, qbool is_console, int key, int unicode)
 
static void Key_PrintBindList (int j)
 
void Key_ReleaseAll (void)
 
void Key_ReleaseAll_f (cmd_state_t *cmd)
 
qbool Key_SetBinding (int keynum, int bindmap, const char *binding)
 
qbool Key_SetBindMap (int fg, int bg)
 
void Key_Shutdown (void)
 
int Key_StringToKeynum (const char *str)
 
static void Key_Unbind_f (cmd_state_t *cmd)
 
static void Key_Unbindall_f (cmd_state_t *cmd)
 
void Key_WriteBindings (qfile_t *f)
 

Variables

char chat_buffer [MAX_INPUTLINE]
 
int chat_bufferpos = 0
 
signed char chat_mode
 
cvar_t con_closeontoggleconsole = {CF_CLIENT | CF_ARCHIVE, "con_closeontoggleconsole","1", "allows toggleconsole binds to close the console as well; when set to 2, this even works when not at the start of the line in console input; when set to 3, this works even if the toggleconsole key is the color tag"}
 
cvar_t con_textsize
 
static eventqueueitem_t eventqueue [32]
 
static unsigned eventqueue_idx = 0
 
static int events_blocked = 0
 
conbuffer_t history
 
int history_line
 
qbool history_matchfound = false
 
char history_savedline [MAX_INPUTLINE]
 
char history_searchstring [MAX_INPUTLINE]
 
static int key_bmap
 
static int key_bmap2
 
int key_consoleactive
 
keydest_t key_dest
 
qbool key_insert = true
 
char key_line [MAX_INPUTLINE]
 
int key_linepos
 
char * keybindings [MAX_BINDMAPS][MAX_KEYS]
 
static unsigned char keydown [MAX_KEYS]
 
static const keyname_t keynames []
 
static char tbl_keyascii [MAX_KEYS]
 
static keydest_t tbl_keydest [MAX_KEYS]
 

Macro Definition Documentation

◆ KM_ALT

#define KM_ALT   (!keydown[K_CTRL] && !keydown[K_SHIFT] && keydown[K_ALT])

Definition at line 691 of file keys.c.

◆ KM_CTRL

#define KM_CTRL   ( keydown[K_CTRL] && !keydown[K_SHIFT] && !keydown[K_ALT])

Definition at line 689 of file keys.c.

Referenced by Key_Console(), and Key_Parse_CommonKeys().

◆ KM_CTRL_ALT

#define KM_CTRL_ALT   ( keydown[K_CTRL] && !keydown[K_SHIFT] && keydown[K_ALT])

Definition at line 687 of file keys.c.

◆ KM_CTRL_SHIFT

#define KM_CTRL_SHIFT   ( keydown[K_CTRL] && keydown[K_SHIFT] && !keydown[K_ALT])

Definition at line 686 of file keys.c.

Referenced by Key_Console().

◆ KM_CTRL_SHIFT_ALT

#define KM_CTRL_SHIFT_ALT   ( keydown[K_CTRL] && keydown[K_SHIFT] && keydown[K_ALT])

Definition at line 685 of file keys.c.

◆ KM_NONE

#define KM_NONE   (!keydown[K_CTRL] && !keydown[K_SHIFT] && !keydown[K_ALT])

Definition at line 684 of file keys.c.

Referenced by Key_Console(), and Key_Parse_CommonKeys().

◆ KM_SHIFT

#define KM_SHIFT   (!keydown[K_CTRL] && keydown[K_SHIFT] && !keydown[K_ALT])

Definition at line 690 of file keys.c.

Referenced by Key_Console(), and Key_Parse_CommonKeys().

◆ KM_SHIFT_ALT

#define KM_SHIFT_ALT   (!keydown[K_CTRL] && keydown[K_SHIFT] && keydown[K_ALT])

Definition at line 688 of file keys.c.

Function Documentation

◆ Key_AddChar()

int Key_AddChar ( int unicode,
qbool is_console )

Definition at line 703 of file keys.c.

704{
705 char *line;
706 char buf[16];
707 int len, blen, linepos;
708
709 if (is_console)
710 {
711 line = key_line;
712 linepos = key_linepos;
713 }
714 else
715 {
716 line = chat_buffer;
717 linepos = chat_bufferpos;
718 }
719
720 if (linepos >= MAX_INPUTLINE-1)
721 return linepos;
722
723 blen = u8_fromchar(unicode, buf, sizeof(buf));
724 if (!blen)
725 return linepos;
726 len = (int)strlen(&line[linepos]);
727 // check insert mode, or always insert if at end of line
728 if (key_insert || len == 0)
729 {
730 if (linepos + len + blen >= MAX_INPUTLINE)
731 return linepos;
732 // can't use strcpy to move string to right
733 len++;
734 if (linepos + blen + len >= MAX_INPUTLINE)
735 return linepos;
736 memmove(&line[linepos + blen], &line[linepos], len);
737 }
738 else if (linepos + len + blen - u8_bytelen(line + linepos, 1) >= MAX_INPUTLINE)
739 return linepos;
740 memcpy(line + linepos, buf, blen);
741 if (blen > len)
742 line[linepos + blen] = 0;
743 linepos += blen;
744 return linepos;
745}
static int(ZEXPORT *qz_inflate)(z_stream *strm
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition glquake.h:657
int chat_bufferpos
Definition keys.c:701
int key_linepos
Definition keys.c:35
char chat_buffer[MAX_INPUTLINE]
Definition keys.c:700
char key_line[MAX_INPUTLINE]
Definition keys.c:34
qbool key_insert
Definition keys.c:36
float strlen(string s)
#define MAX_INPUTLINE
maximum size of console commandline, QuakeC strings, and many other text processing buffers
Definition qdefs.h:94
size_t u8_bytelen(const char *_s, size_t n)
Get the number of bytes used in a string to represent an amount of characters.
Definition utf8lib.c:340
int u8_fromchar(Uchar w, char *to, size_t maxlen)
Encode a wide-character into utf-8.
Definition utf8lib.c:628

References buf, chat_buffer, chat_bufferpos, int(), key_insert, key_line, key_linepos, MAX_INPUTLINE, strlen(), u8_bytelen(), and u8_fromchar().

Referenced by Key_Console(), and Key_Message().

◆ Key_Bind_f()

static void Key_Bind_f ( cmd_state_t * cmd)
static

Definition at line 1639 of file keys.c.

1640{
1641 int i, c, b;
1642 char line[MAX_INPUTLINE];
1643
1644 c = Cmd_Argc (cmd);
1645
1646 if (c != 2 && c != 3) {
1647 Con_Print("bind <key> [command] : attach a command to a key\n");
1648 return;
1649 }
1651 if (b == -1 || b >= MAX_KEYS) {
1652 Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(cmd, 1));
1653 return;
1654 }
1655
1656 if (c == 2) {
1657 if (keybindings[0][b])
1658 Con_Printf("\"%s\" = \"%s\"\n", Cmd_Argv(cmd, 1), keybindings[0][b]);
1659 else
1660 Con_Printf("\"%s\" is not bound\n", Cmd_Argv(cmd, 1));
1661 return;
1662 }
1663// copy the rest of the command line
1664 line[0] = 0; // start out with a null string
1665 for (i = 2; i < c; i++) {
1666 dp_strlcat (line, Cmd_Argv(cmd, i), sizeof (line));
1667 if (i != (c - 1))
1668 dp_strlcat (line, " ", sizeof (line));
1669 }
1670
1671 if(!Key_SetBinding (b, 0, line))
1672 Con_Printf("Key_SetBinding failed for unknown reason\n");
1673}
static int Cmd_Argc(cmd_state_t *cmd)
Definition cmd.h:249
static const char * Cmd_Argv(cmd_state_t *cmd, int arg)
Cmd_Argv(cmd, ) will return an empty string (not a NULL) if arg > argc, so string operations are alwa...
Definition cmd.h:254
#define dp_strlcat(dst, src, dsize)
Definition common.h:304
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
qbool Key_SetBinding(int keynum, int bindmap, const char *binding)
Definition keys.c:1409
char * keybindings[MAX_BINDMAPS][MAX_KEYS]
Definition keys.c:39
int Key_StringToKeynum(const char *str)
Definition keys.c:1354
@ MAX_KEYS
Definition keys.h:368
void cmd(string command,...)
int i
dp_FragColor b

References b, cmd(), Cmd_Argc(), Cmd_Argv(), Con_Print(), Con_Printf(), dp_strlcat, i, Key_SetBinding(), Key_StringToKeynum(), keybindings, MAX_INPUTLINE, and MAX_KEYS.

Referenced by Key_Init().

◆ Key_BindList_f()

static void Key_BindList_f ( cmd_state_t * cmd)
static

Definition at line 1633 of file keys.c.

1634{
1636}
static void Key_PrintBindList(int j)
Definition keys.c:1589

References Key_PrintBindList().

Referenced by Key_Init().

◆ Key_ClearEditLine()

int Key_ClearEditLine ( qbool is_console)

Definition at line 668 of file keys.c.

669{
670 if (is_console)
671 {
672 key_line[0] = ']';
673 key_line[1] = 0;
674 return 1;
675 }
676 else
677 {
678 chat_buffer[0] = 0;
679 return 0;
680 }
681}

References chat_buffer, and key_line.

Referenced by Key_Console(), Key_Init(), Key_Message(), and Key_Parse_CommonKeys().

◆ Key_Console()

static void Key_Console ( cmd_state_t * cmd,
int key,
int unicode )
static

Definition at line 1103 of file keys.c.

1104{
1105 int linepos;
1106
1107 key = Key_Convert_NumPadKey(key);
1108
1109 // Forbid Ctrl Alt shortcuts since on Windows they are used to type some characters
1110 // in certain non-English keyboards using the AltGr key (which emulates Ctrl Alt)
1111 // Reference: "Why Ctrl+Alt shouldn't be used as a shortcut modifier"
1112 // https://blogs.msdn.microsoft.com/oldnewthing/20040329-00/?p=40003
1113 if (keydown[K_CTRL] && keydown[K_ALT])
1114 goto add_char;
1115
1116 linepos = Key_Parse_CommonKeys(cmd, true, key, unicode);
1117 if (linepos >= 0)
1118 {
1119 key_linepos = linepos;
1120 return;
1121 }
1122
1123 if ((key == K_ENTER || key == K_KP_ENTER) && KM_NONE)
1124 {
1125 // bones_was_here: prepending allows a loop such as `alias foo "bar; wait; foo"; foo`
1126 // to be broken with an alias or unalias command
1127 Cbuf_InsertText(cmd, key_line+1); // skip the ]
1130 // force an update, because the command may take some time
1131 if (cls.state == ca_disconnected)
1132 CL_UpdateScreen ();
1133 return;
1134 }
1135
1136 if (key == 'l' && KM_CTRL)
1137 {
1138 Cbuf_AddText (cmd, "clear\n");
1139 return;
1140 }
1141
1142 if (key == 'q' && KM_CTRL) // like zsh ^q: push line to history, don't execute, and clear
1143 {
1144 // clear line
1147 return;
1148 }
1149
1150 // End Advanced Console Editing
1151
1152 if (((key == K_UPARROW || key == K_KP_UPARROW) && KM_NONE) || (key == 'p' && KM_CTRL))
1153 {
1155 return;
1156 }
1157
1158 if (((key == K_DOWNARROW || key == K_KP_DOWNARROW) && KM_NONE) || (key == 'n' && KM_CTRL))
1159 {
1161 return;
1162 }
1163
1164 if (keydown[K_CTRL])
1165 {
1166 // prints all the matching commands
1167 if (key == 'f' && KM_CTRL)
1168 {
1170 return;
1171 }
1172 // Search forwards/backwards, pointing the history's index to the
1173 // matching command but without fetching it to let one continue the search.
1174 // To fetch it, it suffices to just press UP or DOWN.
1175 if (key == 'r' && KM_CTRL_SHIFT)
1176 {
1178 return;
1179 }
1180 if (key == 'r' && KM_CTRL)
1181 {
1183 return;
1184 }
1185
1186 // go to the last/first command of the history
1187 if (key == ',' && KM_CTRL)
1188 {
1190 return;
1191 }
1192 if (key == '.' && KM_CTRL)
1193 {
1195 return;
1196 }
1197 }
1198
1199 if (key == K_PGUP || key == K_KP_PGUP)
1200 {
1201 if (KM_CTRL)
1202 {
1204 return;
1205 }
1206 if (KM_NONE)
1207 {
1209 return;
1210 }
1211 }
1212
1213 if (key == K_PGDN || key == K_KP_PGDN)
1214 {
1215 if (KM_CTRL)
1216 {
1218 return;
1219 }
1220 if (KM_NONE)
1221 {
1223 return;
1224 }
1225 }
1226
1227 if (key == K_MWHEELUP)
1228 {
1229 if (KM_CTRL)
1230 {
1231 con_backscroll += 1;
1232 return;
1233 }
1234 if (KM_SHIFT)
1235 {
1237 return;
1238 }
1239 if (KM_NONE)
1240 {
1241 con_backscroll += 5;
1242 return;
1243 }
1244 }
1245
1246 if (key == K_MWHEELDOWN)
1247 {
1248 if (KM_CTRL)
1249 {
1250 con_backscroll -= 1;
1251 return;
1252 }
1253 if (KM_SHIFT)
1254 {
1256 return;
1257 }
1258 if (KM_NONE)
1259 {
1260 con_backscroll -= 5;
1261 return;
1262 }
1263 }
1264
1265 if (keydown[K_CTRL])
1266 {
1267 // text zoom in
1268 if ((key == '=' || key == '+' || key == K_KP_PLUS) && KM_CTRL)
1269 {
1270 if (con_textsize.integer < 128)
1272 return;
1273 }
1274 // text zoom out
1275 if ((key == '-' || key == K_KP_MINUS) && KM_CTRL)
1276 {
1277 if (con_textsize.integer > 1)
1279 return;
1280 }
1281 // text zoom reset
1282 if ((key == '0' || key == K_KP_INS) && KM_CTRL)
1283 {
1285 return;
1286 }
1287 }
1288
1289add_char:
1290
1291 // non printable
1292 if (unicode < 32)
1293 return;
1294
1295 key_linepos = Key_AddChar(unicode, true);
1296}
client_static_t cls
Definition cl_main.c:116
void CL_UpdateScreen(void)
Definition cl_screen.c:2130
cvar_t vid_conheight
Definition cl_screen.c:57
@ ca_disconnected
Definition client.h:531
void Cbuf_InsertText(cmd_state_t *cmd, const char *text)
Definition cmd.c:292
void Cbuf_AddText(cmd_state_t *cmd, const char *text)
Definition cmd.c:264
#define CF_SERVER
cvar/command that only the server can change/execute
Definition cmd.h:49
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
int con_backscroll
Definition console.c:37
void Cvar_SetValueQuick(cvar_t *var, float value)
Definition cvar.c:473
const char * Cvar_VariableDefString(cvar_state_t *cvars, const char *var_name, unsigned neededflags)
Definition cvar.c:159
cvar_state_t cvars_all
Definition cvar.c:28
float K_UPARROW
Definition keycodes.qc:15
float K_PGDN
Definition keycodes.qc:39
float K_DOWNARROW
Definition keycodes.qc:16
float K_MWHEELDOWN
Definition keycodes.qc:133
float K_CTRL
Definition keycodes.qc:21
float K_KP_PLUS
Definition keycodes.qc:73
float K_KP_UPARROW
Definition keycodes.qc:64
float K_PGUP
Definition keycodes.qc:40
float K_ALT
Definition keycodes.qc:20
float K_ENTER
Definition keycodes.qc:8
float K_KP_DOWNARROW
Definition keycodes.qc:53
float K_KP_ENTER
Definition keycodes.qc:74
float K_KP_PGDN
Definition keycodes.qc:55
float K_KP_PGUP
Definition keycodes.qc:66
float K_MWHEELUP
Definition keycodes.qc:132
float K_KP_INS
Definition keycodes.qc:49
float K_KP_MINUS
Definition keycodes.qc:72
int Key_Parse_CommonKeys(cmd_state_t *cmd, qbool is_console, int key, int unicode)
Definition keys.c:750
static void Key_History_First(void)
Definition keys.c:185
static int Key_Convert_NumPadKey(int key)
Definition keys.c:1080
static void Key_History_Find_All(void)
Definition keys.c:278
#define KM_SHIFT
Definition keys.c:690
int Key_AddChar(int unicode, qbool is_console)
Definition keys.c:703
static void Key_History_Find_Backwards(void)
Definition keys.c:211
static void Key_History_Last(void)
Definition keys.c:198
static void Key_History_Down(void)
Definition keys.c:163
int Key_ClearEditLine(qbool is_console)
Definition keys.c:668
static void Key_History_Find_Forwards(void)
Definition keys.c:246
static void Key_History_Up(void)
Definition keys.c:138
#define KM_CTRL
Definition keys.c:689
static unsigned char keydown[MAX_KEYS]
Definition keys.c:327
cvar_t con_textsize
Definition console.c:57
static void Key_History_Push(void)
Definition keys.c:114
#define KM_NONE
Definition keys.c:684
#define KM_CTRL_SHIFT
Definition keys.c:686
cactive_t state
Definition client.h:568
int integer
Definition cvar.h:73

References ca_disconnected, Cbuf_AddText(), Cbuf_InsertText(), CF_CLIENT, CF_SERVER, CL_UpdateScreen(), cls, cmd(), con_backscroll, con_textsize, Cvar_SetValueQuick(), Cvar_VariableDefString(), cvars_all, cvar_t::integer, K_ALT, K_CTRL, K_DOWNARROW, K_ENTER, K_KP_DOWNARROW, K_KP_ENTER, K_KP_INS, K_KP_MINUS, K_KP_PGDN, K_KP_PGUP, K_KP_PLUS, K_KP_UPARROW, K_MWHEELDOWN, K_MWHEELUP, K_PGDN, K_PGUP, K_UPARROW, Key_AddChar(), Key_ClearEditLine(), Key_Convert_NumPadKey(), Key_History_Down(), Key_History_Find_All(), Key_History_Find_Backwards(), Key_History_Find_Forwards(), Key_History_First(), Key_History_Last(), Key_History_Push(), Key_History_Up(), key_line, key_linepos, Key_Parse_CommonKeys(), keydown, KM_CTRL, KM_CTRL_SHIFT, KM_NONE, KM_SHIFT, client_static_t::state, and vid_conheight.

Referenced by Key_Event().

◆ Key_Convert_NumPadKey()

static int Key_Convert_NumPadKey ( int key)
static

Definition at line 1080 of file keys.c.

1081{
1082 // LadyHavoc: copied most of this from Q2 to improve keyboard handling
1083 switch (key)
1084 {
1085 case K_KP_SLASH: return '/';
1086 case K_KP_MINUS: return '-';
1087 case K_KP_PLUS: return '+';
1088 case K_KP_HOME: return '7';
1089 case K_KP_UPARROW: return '8';
1090 case K_KP_PGUP: return '9';
1091 case K_KP_LEFTARROW: return '4';
1092 case K_KP_5: return '5';
1093 case K_KP_RIGHTARROW: return '6';
1094 case K_KP_END: return '1';
1095 case K_KP_DOWNARROW: return '2';
1096 case K_KP_PGDN: return '3';
1097 case K_KP_INS: return '0';
1098 case K_KP_DEL: return '.';
1099 }
1100 return key;
1101}
float K_KP_RIGHTARROW
Definition keycodes.qc:60
float K_KP_LEFTARROW
Definition keycodes.qc:57
float K_KP_DEL
Definition keycodes.qc:68
float K_KP_HOME
Definition keycodes.qc:62
float K_KP_5
Definition keycodes.qc:58
float K_KP_END
Definition keycodes.qc:51
float K_KP_SLASH
Definition keycodes.qc:70

References K_KP_5, K_KP_DEL, K_KP_DOWNARROW, K_KP_END, K_KP_HOME, K_KP_INS, K_KP_LEFTARROW, K_KP_MINUS, K_KP_PGDN, K_KP_PGUP, K_KP_PLUS, K_KP_RIGHTARROW, K_KP_SLASH, and K_KP_UPARROW.

Referenced by Key_Console(), and Key_Message().

◆ Key_Event()

void Key_Event ( int key,
int ascii,
qbool down )

Definition at line 1836 of file keys.c.

1837{
1839 const char *bind;
1840 qbool q;
1841 keydest_t keydest = key_dest;
1842 char vabuf[1024];
1843
1844 if (key < 0 || key >= MAX_KEYS)
1845 return;
1846
1847 if(events_blocked)
1848 {
1849 Key_EventQueue_Add(key, ascii, down);
1850 return;
1851 }
1852
1853 // get key binding
1854 bind = keybindings[key_bmap][key];
1855 if (!bind)
1856 bind = keybindings[key_bmap2][key];
1857
1859 Con_DPrintf("Key_Event(%i, '%c', %s) keydown %i bind \"%s\"\n", key, ascii ? ascii : '?', down ? "down" : "up", keydown[key], bind ? bind : "");
1860
1862 keydest = key_console;
1863
1864 if (down)
1865 {
1866 // increment key repeat count each time a down is received so that things
1867 // which want to ignore key repeat can ignore it
1868 keydown[key] = min(keydown[key] + 1, 2);
1869 if(keydown[key] == 1) {
1870 tbl_keyascii[key] = ascii;
1871 tbl_keydest[key] = keydest;
1872 } else {
1873 ascii = tbl_keyascii[key];
1874 keydest = tbl_keydest[key];
1875 }
1876 }
1877 else
1878 {
1879 // clear repeat count now that the key is released
1880 keydown[key] = 0;
1881 keydest = tbl_keydest[key];
1882 ascii = tbl_keyascii[key];
1883 }
1884
1885 if(keydest == key_void)
1886 return;
1887
1888 // key_consoleactive is a flag not a key_dest because the console is a
1889 // high priority overlay ontop of the normal screen (designed as a safety
1890 // feature so that developers and users can rescue themselves from a bad
1891 // situation).
1892 //
1893 // this also means that toggling the console on/off does not lose the old
1894 // key_dest state
1895
1896 // specially handle escape (togglemenu) and shift-escape (toggleconsole)
1897 // engine bindings, these are not handled as normal binds so that the user
1898 // can recover from a completely empty bindmap
1899 if (key == K_ESCAPE)
1900 {
1901 // ignore key repeats on escape
1902 if (keydown[key] > 1)
1903 return;
1904
1905 // escape does these things:
1906 // key_consoleactive - close console
1907 // key_message - abort messagemode
1908 // key_menu - go to parent menu (or key_game)
1909 // key_game - open menu
1910
1911 // in all modes shift-escape toggles console
1912 if (keydown[K_SHIFT])
1913 {
1914 if(down)
1915 {
1917 tbl_keydest[key] = key_void; // esc release should go nowhere (especially not to key_menu or key_game)
1918 }
1919 return;
1920 }
1921
1922 switch (keydest)
1923 {
1924 case key_console:
1925 if(down)
1926 {
1928 {
1929 key_consoleactive &= ~KEY_CONSOLEACTIVE_USER;
1930#ifdef CONFIG_MENU
1931 MR_ToggleMenu(1);
1932#endif
1933 }
1934 else
1936 }
1937 break;
1938
1939 case key_message:
1940 if (down)
1941 Key_Message (cmd, key, ascii); // that'll close the message input
1942 break;
1943
1944 case key_menu:
1945 case key_menu_grabbed:
1946#ifdef CONFIG_MENU
1947 MR_KeyEvent (key, ascii, down);
1948#endif
1949 break;
1950
1951 case key_game:
1952 // csqc has priority over toggle menu if it wants to (e.g. handling escape for UI stuff in-game.. :sick:)
1953 q = CL_VM_InputEvent(down ? 0 : 1, key, ascii);
1954#ifdef CONFIG_MENU
1955 if (!q && down)
1956 MR_ToggleMenu(1);
1957#endif
1958 break;
1959
1960 default:
1961 Con_Printf ("Key_Event: Bad key_dest\n");
1962 }
1963 return;
1964 }
1965
1966 // send function keydowns to interpreter no matter what mode is (unless the menu has specifically grabbed the keyboard, for rebinding keys)
1967 // VorteX: Omnicide does bind F* keys
1968 if (keydest != key_menu_grabbed)
1969 if (key >= K_F1 && key <= K_F12 && gamemode != GAME_BLOODOMNICIDE)
1970 {
1971 if (bind)
1972 {
1973 if(keydown[key] == 1 && down)
1974 {
1975 // button commands add keynum as a parm
1976 // prepend to avoid delays from `wait` commands added by other sources
1977 if (bind[0] == '+')
1978 Cbuf_InsertText(cmd, va(vabuf, sizeof(vabuf), "%s %i\n", bind, key));
1979 else
1980 Cbuf_InsertText(cmd, bind);
1981 }
1982 else if(bind[0] == '+' && !down && keydown[key] == 0)
1983 // append -bind to ensure it's after the +bind in case they arrive in the same frame
1984 Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "-%s %i\n", bind + 1, key));
1985 }
1986 return;
1987 }
1988
1989 // send input to console if it wants it
1990 if (keydest == key_console)
1991 {
1992 if (!down)
1993 return;
1994 // con_closeontoggleconsole enables toggleconsole keys to close the
1995 // console, as long as they are not the color prefix character
1996 // (special exemption for german keyboard layouts)
1997 if (con_closeontoggleconsole.integer && bind && !strncmp(bind, "toggleconsole", strlen("toggleconsole")) && (key_consoleactive & KEY_CONSOLEACTIVE_USER) && (con_closeontoggleconsole.integer >= ((ascii != STRING_COLOR_TAG) ? 2 : 3) || key_linepos == 1))
1998 {
2000 return;
2001 }
2002
2003 if (Sys_CheckParm ("-noconsole"))
2004 return; // only allow the key bind to turn off console
2005
2006 Key_Console (cmd, key, ascii);
2007 return;
2008 }
2009
2010 // handle toggleconsole in menu too
2011 if (keydest == key_menu)
2012 {
2013 if (down && con_closeontoggleconsole.integer && bind && !strncmp(bind, "toggleconsole", strlen("toggleconsole")) && ascii != STRING_COLOR_TAG)
2014 {
2015 Cbuf_InsertText(cmd, "toggleconsole\n"); // Deferred to next frame so we're not sending the text event to the console.
2016 tbl_keydest[key] = key_void; // key release should go nowhere (especially not to key_menu or key_game)
2017 return;
2018 }
2019 }
2020
2021 // ignore binds while a video is played, let the video system handle the key event
2022 if (cl_videoplaying)
2023 {
2024 if (gamemode == GAME_BLOODOMNICIDE) // menu controls key events
2025#ifdef CONFIG_MENU
2026 MR_KeyEvent(key, ascii, down);
2027#else
2028 {
2029 }
2030#endif
2031 else
2032 CL_Video_KeyEvent (key, ascii, keydown[key] != 0);
2033 return;
2034 }
2035
2036 // anything else is a key press into the game, chat line, or menu
2037 switch (keydest)
2038 {
2039 case key_message:
2040 if (down)
2041 Key_Message (cmd, key, ascii);
2042 break;
2043 case key_menu:
2044 case key_menu_grabbed:
2045#ifdef CONFIG_MENU
2046 MR_KeyEvent (key, ascii, down);
2047#endif
2048 break;
2049 case key_game:
2050 q = CL_VM_InputEvent(down ? 0 : 1, key, ascii);
2051 // ignore key repeats on binds and only send the bind if the event hasnt been already processed by csqc
2052 if (!q && bind)
2053 {
2054 if(keydown[key] == 1 && down)
2055 {
2056 // button commands add keynum as a parm
2057 // prepend to avoid delays from `wait` commands added by other sources
2058 if (bind[0] == '+')
2059 Cbuf_InsertText(cmd, va(vabuf, sizeof(vabuf), "%s %i\n", bind, key));
2060 else
2061 Cbuf_InsertText(cmd, bind);
2062 }
2063 else if(bind[0] == '+' && !down && keydown[key] == 0)
2064 // append -bind to ensure it's after the +bind in case they arrive in the same frame
2065 Cbuf_AddText(cmd, va(vabuf, sizeof(vabuf), "-%s %i\n", bind + 1, key));
2066 }
2067 break;
2068 default:
2069 Con_Printf ("Key_Event: Bad key_dest\n");
2070 }
2071}
void CL_Video_KeyEvent(int key, int ascii, qbool down)
Definition cl_video.c:596
int cl_videoplaying
Definition cl_video.c:458
cmd_state_t * cmd_local
command interpreter for local commands injected by SVQC, CSQC, MQC, server or client engine code uses...
Definition cmd.c:25
gamemode_t gamemode
Definition com_game.c:26
@ GAME_BLOODOMNICIDE
Definition com_game.h:52
char * va(char *buf, size_t buflen, const char *format,...)
Definition common.c:972
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1544
void Con_ToggleConsole_f(cmd_state_t *cmd)
Definition console.c:686
qbool CL_VM_InputEvent(int eventtype, float x, float y)
Definition csprogs.c:459
#define STRING_COLOR_TAG
Definition draw.h:140
cvar_t developer_insane
Definition host.c:50
float K_SHIFT
Definition keycodes.qc:22
float K_F1
Definition keycodes.qc:24
float K_F12
Definition keycodes.qc:35
float K_ESCAPE
Definition keycodes.qc:9
cvar_t con_closeontoggleconsole
Definition keys.c:28
static int key_bmap2
Definition keys.c:326
static void Key_EventQueue_Add(int key, int ascii, qbool down)
Definition keys.c:1808
static void Key_Console(cmd_state_t *cmd, int key, int unicode)
Definition keys.c:1103
static int events_blocked
Definition keys.c:1804
static keydest_t tbl_keydest[MAX_KEYS]
Definition keys.c:1795
static char tbl_keyascii[MAX_KEYS]
Definition keys.c:1794
keydest_t key_dest
Definition keys.c:37
static void Key_Message(cmd_state_t *cmd, int key, int ascii)
Definition keys.c:1301
int key_consoleactive
Definition keys.c:38
static int key_bmap
Definition keys.c:326
#define KEY_CONSOLEACTIVE_USER
Definition keys.h:380
keydest_t
Definition keys.h:372
@ key_menu
Definition keys.h:372
@ key_game
Definition keys.h:372
@ key_message
Definition keys.h:372
@ key_void
Definition keys.h:372
@ key_menu_grabbed
Definition keys.h:372
@ key_console
Definition keys.h:372
#define KEY_CONSOLEACTIVE_FORCED
Definition keys.h:382
#define min(A, B)
Definition mathlib.h:37
void(* MR_ToggleMenu)(int mode)
Definition menu.c:5480
void(* MR_KeyEvent)(int key, int ascii, qbool downevent)
Definition menu.c:5478
bool qbool
Definition qtypes.h:9
command interpreter state - the tokenizing and execution of commands, as well as pointers to which cv...
Definition cmd.h:127
int Sys_CheckParm(const char *parm)
Definition sys_shared.c:327

References Cbuf_AddText(), Cbuf_InsertText(), CL_Video_KeyEvent(), cl_videoplaying, CL_VM_InputEvent(), cmd(), cmd_local, con_closeontoggleconsole, Con_DPrintf(), Con_Printf(), Con_ToggleConsole_f(), developer_insane, events_blocked, GAME_BLOODOMNICIDE, gamemode, cvar_t::integer, K_ESCAPE, K_F1, K_F12, K_SHIFT, key_bmap, key_bmap2, Key_Console(), key_console, key_consoleactive, KEY_CONSOLEACTIVE_FORCED, KEY_CONSOLEACTIVE_USER, key_dest, Key_EventQueue_Add(), key_game, key_linepos, key_menu, key_menu_grabbed, Key_Message(), key_message, key_void, keybindings, keydown, MAX_KEYS, min, MR_KeyEvent, MR_ToggleMenu, STRING_COLOR_TAG, strlen(), Sys_CheckParm(), tbl_keyascii, tbl_keydest, and va().

Referenced by Key_EventQueue_Unblock(), Key_ReleaseAll(), Sys_SDL_HandleEvents(), VID_KeyEventForButton(), VID_TouchscreenArea(), and VID_TouchscreenCursor().

◆ Key_EventQueue_Add()

static void Key_EventQueue_Add ( int key,
int ascii,
qbool down )
static

Definition at line 1808 of file keys.c.

1809{
1810 if(eventqueue_idx < sizeof(eventqueue) / sizeof(*eventqueue))
1811 {
1816 }
1817}
static unsigned eventqueue_idx
Definition keys.c:1806
static eventqueueitem_t eventqueue[32]
Definition keys.c:1805

References eventqueueitem_t::ascii, eventqueueitem_t::down, eventqueue, eventqueue_idx, and eventqueueitem_t::key.

Referenced by Key_Event().

◆ Key_EventQueue_Block()

void Key_EventQueue_Block ( void )

Definition at line 1819 of file keys.c.

1820{
1821 // block key events until call to Unblock
1822 events_blocked = true;
1823}

References events_blocked.

◆ Key_EventQueue_Unblock()

void Key_EventQueue_Unblock ( void )

Definition at line 1825 of file keys.c.

1826{
1827 // unblocks key events again
1828 unsigned i;
1829 events_blocked = false;
1830 for(i = 0; i < eventqueue_idx; ++i)
1831 Key_Event(eventqueue[i].key, eventqueue[i].ascii, eventqueue[i].down);
1832 eventqueue_idx = 0;
1833}
void Key_Event(int key, int ascii, qbool down)
Definition keys.c:1836

References eventqueue, eventqueue_idx, events_blocked, i, and Key_Event().

◆ Key_FindKeysForCommand()

void Key_FindKeysForCommand ( const char * command,
int * keys,
int numkeys,
int bindmap )

Definition at line 1760 of file keys.c.

1761{
1762 int count;
1763 int j;
1764 const char *b;
1765
1766 for (j = 0;j < numkeys;j++)
1767 keys[j] = -1;
1768
1769 if(bindmap >= MAX_BINDMAPS)
1770 return;
1771
1772 count = 0;
1773
1774 for (j = 0; j < MAX_KEYS; ++j)
1775 {
1776 b = Key_GetBind(j, bindmap);
1777 if (!b)
1778 continue;
1779 if (!strcmp (b, command) )
1780 {
1781 keys[count++] = j;
1782 if (count == numkeys)
1783 break;
1784 }
1785 }
1786}
GLenum GLenum GLsizei count
Definition glquake.h:656
const char * Key_GetBind(int key, int bindmap)
Definition keys.c:1740
#define MAX_BINDMAPS
Definition qdefs.h:152

References b, count, Key_GetBind(), MAX_BINDMAPS, and MAX_KEYS.

Referenced by M_Keys_Draw(), M_Keys_Key(), and VM_findkeysforcommand().

◆ Key_GetBind()

const char * Key_GetBind ( int key,
int bindmap )

Definition at line 1740 of file keys.c.

1741{
1742 const char *bind;
1743 if (key < 0 || key >= MAX_KEYS)
1744 return NULL;
1745 if(bindmap >= MAX_BINDMAPS)
1746 return NULL;
1747 if(bindmap >= 0)
1748 {
1749 bind = keybindings[bindmap][key];
1750 }
1751 else
1752 {
1753 bind = keybindings[key_bmap][key];
1754 if (!bind)
1755 bind = keybindings[key_bmap2][key];
1756 }
1757 return bind;
1758}
#define NULL
Definition qtypes.h:12

References key_bmap, key_bmap2, keybindings, MAX_BINDMAPS, MAX_KEYS, and NULL.

Referenced by Key_FindKeysForCommand(), and VM_getkeybind().

◆ Key_GetBindMap()

void Key_GetBindMap ( int * fg,
int * bg )

Definition at line 1435 of file keys.c.

1436{
1437 if(fg)
1438 *fg = key_bmap;
1439 if(bg)
1440 *bg = key_bmap2;
1441}

References key_bmap, and key_bmap2.

Referenced by VM_getbindmaps().

◆ Key_History_Down()

static void Key_History_Down ( void )
static

Definition at line 163 of file keys.c.

164{
165 if(history_line == -1) // editing the "new" line
166 return;
167
169 return;
170
172 {
173 ++history_line;
175 }
176 else
177 {
178 history_line = -1;
180 }
181
183}
#define dp_strlcpy(dst, src, dsize)
Definition common.h:303
const char * ConBuffer_GetLine(conbuffer_t *buf, int i)
Definition console.c:386
#define CONBUFFER_LINES_COUNT(buf)
Definition console.h:137
static qbool Key_History_Get_foundCommand(void)
Definition keys.c:128
int history_line
Definition keys.c:41
conbuffer_t history
Definition keys.c:45
char history_savedline[MAX_INPUTLINE]
Definition keys.c:42

References ConBuffer_GetLine(), CONBUFFER_LINES_COUNT, dp_strlcpy, history, history_line, history_savedline, int(), Key_History_Get_foundCommand(), key_line, key_linepos, and strlen().

Referenced by Key_Console().

◆ Key_History_f()

static void Key_History_f ( cmd_state_t * cmd)
static

Definition at line 300 of file keys.c.

301{
302 char *errchar = NULL;
303 int i = 0;
304 char vabuf[1024];
305 size_t digits = strlen(va(vabuf, sizeof(vabuf), "%i", HIST_MAXLINES));
306
307 if (Cmd_Argc (cmd) > 1)
308 {
309 if (!strcmp(Cmd_Argv(cmd, 1), "-c"))
310 {
312 return;
313 }
314 i = strtol(Cmd_Argv(cmd, 1), &errchar, 0);
315 if ((i < 0) || (i > CONBUFFER_LINES_COUNT(&history)) || (errchar && *errchar))
316 i = 0;
317 else
319 }
320
321 for ( ; i<CONBUFFER_LINES_COUNT(&history); i++)
322 Con_Printf("^3%*i^7 %s\n", (int)digits, i+1, ConBuffer_GetLine(&history, i));
323 Con_Printf("\n");
324}
void ConBuffer_Clear(conbuffer_t *buf)
Definition console.c:212
#define HIST_MAXLINES
max command history buffer lines in console
Definition qdefs.h:98

References cmd(), Cmd_Argc(), Cmd_Argv(), Con_Printf(), ConBuffer_Clear(), ConBuffer_GetLine(), CONBUFFER_LINES_COUNT, HIST_MAXLINES, history, i, NULL, strlen(), and va().

Referenced by Key_Init().

◆ Key_History_Find_All()

static void Key_History_Find_All ( void )
static

Definition at line 278 of file keys.c.

279{
280 const char *partial = key_line + 1;
281 int i, count = 0;
282 char vabuf[1024];
283 size_t digits = strlen(va(vabuf, sizeof(vabuf), "%i", HIST_MAXLINES));
284 Con_Printf("History commands containing \"%s\":\n", key_line + 1);
285
286 if (!*partial)
287 partial = "*";
288 else if (!( strchr(partial, '*') || strchr(partial, '?') )) // no pattern?
289 partial = va(vabuf, sizeof(vabuf), "*%s*", partial);
290
291 for (i=0; i<CONBUFFER_LINES_COUNT(&history); i++)
292 if (matchpattern_with_separator(ConBuffer_GetLine(&history, i), partial, true, "", false))
293 {
294 Con_Printf("%s%*i^7 %s\n", (i == history_line) ? "^2" : "^3", (int)digits, i+1, ConBuffer_GetLine(&history, i));
295 count++;
296 }
297 Con_Printf("%i result%s\n\n", count, (count != 1) ? "s" : "");
298}
int matchpattern_with_separator(const char *in, const char *pattern, int caseinsensitive, const char *separators, qbool wildcard_least_one)
Definition filematch.c:23

References Con_Printf(), ConBuffer_GetLine(), CONBUFFER_LINES_COUNT, count, HIST_MAXLINES, history, history_line, i, key_line, matchpattern_with_separator(), strlen(), and va().

Referenced by Key_Console().

◆ Key_History_Find_Backwards()

static void Key_History_Find_Backwards ( void )
static

Definition at line 211 of file keys.c.

212{
213 int i;
214 const char *partial = key_line + 1;
215 char vabuf[1024];
216 size_t digits = strlen(va(vabuf, sizeof(vabuf), "%i", HIST_MAXLINES));
217
218 if (history_line == -1) // editing the "new" line
220
221 if (strcmp(key_line + 1, history_searchstring)) // different string? Start a new search
222 {
225 }
226 else if (history_line == -1)
228 else
229 i = history_line - 1;
230
231 if (!*partial)
232 partial = "*";
233 else if (!( strchr(partial, '*') || strchr(partial, '?') )) // no pattern?
234 partial = va(vabuf, sizeof(vabuf), "*%s*", partial);
235
236 for ( ; i >= 0; i--)
237 if (matchpattern_with_separator(ConBuffer_GetLine(&history, i), partial, true, "", false))
238 {
239 Con_Printf("^2%*i^7 %s\n", (int)digits, i+1, ConBuffer_GetLine(&history, i));
240 history_line = i;
241 history_matchfound = true;
242 return;
243 }
244}
qbool history_matchfound
Definition keys.c:44
char history_searchstring[MAX_INPUTLINE]
Definition keys.c:43

References Con_Printf(), ConBuffer_GetLine(), CONBUFFER_LINES_COUNT, dp_strlcpy, HIST_MAXLINES, history, history_line, history_matchfound, history_savedline, history_searchstring, i, key_line, matchpattern_with_separator(), strlen(), and va().

Referenced by Key_Console().

◆ Key_History_Find_Forwards()

static void Key_History_Find_Forwards ( void )
static

Definition at line 246 of file keys.c.

247{
248 int i;
249 const char *partial = key_line + 1;
250 char vabuf[1024];
251 size_t digits = strlen(va(vabuf, sizeof(vabuf), "%i", HIST_MAXLINES));
252
253 if (history_line == -1) // editing the "new" line
254 return;
255
256 if (strcmp(key_line + 1, history_searchstring)) // different string? Start a new search
257 {
259 i = 0;
260 }
261 else i = history_line + 1;
262
263 if (!*partial)
264 partial = "*";
265 else if (!( strchr(partial, '*') || strchr(partial, '?') )) // no pattern?
266 partial = va(vabuf, sizeof(vabuf), "*%s*", partial);
267
268 for ( ; i < CONBUFFER_LINES_COUNT(&history); i++)
269 if (matchpattern_with_separator(ConBuffer_GetLine(&history, i), partial, true, "", false))
270 {
271 Con_Printf("^2%*i^7 %s\n", (int)digits, i+1, ConBuffer_GetLine(&history, i));
272 history_line = i;
273 history_matchfound = true;
274 return;
275 }
276}

References Con_Printf(), ConBuffer_GetLine(), CONBUFFER_LINES_COUNT, dp_strlcpy, HIST_MAXLINES, history, history_line, history_matchfound, history_searchstring, i, key_line, matchpattern_with_separator(), strlen(), and va().

Referenced by Key_Console().

◆ Key_History_First()

static void Key_History_First ( void )
static

Definition at line 185 of file keys.c.

186{
187 if(history_line == -1) // editing the "new" line
189
191 {
192 history_line = 0;
195 }
196}

References ConBuffer_GetLine(), CONBUFFER_LINES_COUNT, dp_strlcpy, history, history_line, history_savedline, int(), key_line, key_linepos, and strlen().

Referenced by Key_Console().

◆ Key_History_Get_foundCommand()

static qbool Key_History_Get_foundCommand ( void )
static

Definition at line 128 of file keys.c.

129{
131 return false;
134 history_matchfound = false;
135 return true;
136}

References ConBuffer_GetLine(), dp_strlcpy, history, history_line, history_matchfound, int(), key_line, key_linepos, and strlen().

Referenced by Key_History_Down(), and Key_History_Up().

◆ Key_History_Init()

static void Key_History_Init ( void )
static

Definition at line 50 of file keys.c.

51{
52 qfile_t *historyfile;
54
55// not necessary for mobile
56#ifndef DP_MOBILETOUCH
57 historyfile = FS_OpenRealFile("darkplaces_history.txt", "rb", false); // rb to handle unix line endings on windows too
58 if(historyfile)
59 {
60 char buf[MAX_INPUTLINE];
61 int bufpos;
62 int c;
63
64 bufpos = 0;
65 for(;;)
66 {
67 c = FS_Getc(historyfile);
68 if(c < 0 || c == 0 || c == '\r' || c == '\n')
69 {
70 if(bufpos > 0)
71 {
72 buf[bufpos] = 0;
73 ConBuffer_AddLine(&history, buf, bufpos, 0);
74 bufpos = 0;
75 }
76 if(c < 0)
77 break;
78 }
79 else
80 {
81 if(bufpos < MAX_INPUTLINE - 1)
82 buf[bufpos++] = c;
83 }
84 }
85
86 FS_Close(historyfile);
87 }
88#endif
89
90 history_line = -1;
91}
void ConBuffer_AddLine(conbuffer_t *buf, const char *line, int len, unsigned mask)
Appends a given string as a new line to the console.
Definition console.c:332
void ConBuffer_Init(conbuffer_t *buf, int textsize, int maxlines, mempool_t *mempool)
Definition console.c:108
qfile_t * FS_OpenRealFile(const char *filepath, const char *mode, qbool quiet)
Definition fs.c:2901
int FS_Close(qfile_t *file)
Definition fs.c:2970
int FS_Getc(qfile_t *file)
Definition fs.c:3323
#define HIST_TEXTSIZE
max command history buffer characters in console
Definition qdefs.h:97
mempool_t * zonemempool
Definition zone.c:796

References buf, ConBuffer_AddLine(), ConBuffer_Init(), FS_Close(), FS_Getc(), FS_OpenRealFile(), HIST_MAXLINES, HIST_TEXTSIZE, history, history_line, MAX_INPUTLINE, and zonemempool.

Referenced by Key_Init().

◆ Key_History_Last()

static void Key_History_Last ( void )
static

Definition at line 198 of file keys.c.

199{
200 if(history_line == -1) // editing the "new" line
202
204 {
208 }
209}

References ConBuffer_GetLine(), CONBUFFER_LINES_COUNT, dp_strlcpy, history, history_line, history_savedline, int(), key_line, key_linepos, and strlen().

Referenced by Key_Console().

◆ Key_History_Push()

static void Key_History_Push ( void )
static

Definition at line 114 of file keys.c.

115{
116 if(key_line[1]) // empty?
117 if(strcmp(key_line, "]quit")) // putting these into the history just sucks
118 if(strncmp(key_line, "]quit ", 6)) // putting these into the history just sucks
119 if(strcmp(key_line, "]rcon_password")) // putting these into the history just sucks
120 if(strncmp(key_line, "]rcon_password ", 15)) // putting these into the history just sucks
121 ConBuffer_AddLine(&history, key_line + 1, (int)strlen(key_line) - 1, 0);
122 Con_Printf("%s\n", key_line); // don't mark empty lines as history
123 history_line = -1;
125 history_matchfound = false;
126}

References Con_Printf(), ConBuffer_AddLine(), history, history_line, history_matchfound, key_line, and strlen().

Referenced by Key_Console().

◆ Key_History_Shutdown()

static void Key_History_Shutdown ( void )
static

Definition at line 93 of file keys.c.

94{
95// not necessary for mobile
96#ifndef DP_MOBILETOUCH
97 qfile_t *historyfile = FS_OpenRealFile("darkplaces_history.txt", "w", false);
98 if(historyfile)
99 {
100 int i;
101
102 Con_Print("Saving command history to darkplaces_history.txt ...\n");
103 for(i = 0; i < CONBUFFER_LINES_COUNT(&history); ++i)
104 FS_Printf(historyfile, "%s\n", ConBuffer_GetLine(&history, i));
105 FS_Close(historyfile);
106 }
107 else
108 Con_Print(CON_ERROR "Couldn't write darkplaces_history.txt\n");
109#endif
110
112}
void ConBuffer_Shutdown(conbuffer_t *buf)
Definition console.c:222
#define CON_ERROR
Definition console.h:102
int FS_Printf(qfile_t *file, const char *format,...)
Definition fs.c:3273

References CON_ERROR, Con_Print(), ConBuffer_GetLine(), CONBUFFER_LINES_COUNT, ConBuffer_Shutdown(), FS_Close(), FS_OpenRealFile(), FS_Printf(), history, and i.

Referenced by Key_Shutdown().

◆ Key_History_Up()

static void Key_History_Up ( void )
static

Definition at line 138 of file keys.c.

139{
140 if(history_line == -1) // editing the "new" line
142
144 return;
145
146 if(history_line == -1)
147 {
149 if(history_line != -1)
150 {
153 }
154 }
155 else if(history_line > 0)
156 {
157 --history_line; // this also does -1 -> 0, so it is good
160 }
161}

References ConBuffer_GetLine(), CONBUFFER_LINES_COUNT, dp_strlcpy, history, history_line, history_savedline, int(), Key_History_Get_foundCommand(), key_line, key_linepos, and strlen().

Referenced by Key_Console().

◆ Key_In_Bind_f()

static void Key_In_Bind_f ( cmd_state_t * cmd)
static

Definition at line 1484 of file keys.c.

1485{
1486 int i, c, b, m;
1487 char line[MAX_INPUTLINE];
1488 char *errchar = NULL;
1489
1490 c = Cmd_Argc (cmd);
1491
1492 if (c != 3 && c != 4) {
1493 Con_Print("in_bind <bindmap> <key> [command] : attach a command to a key\n");
1494 return;
1495 }
1496
1497 m = strtol(Cmd_Argv(cmd, 1), &errchar, 0);
1498 if ((m < 0) || (m >= MAX_BINDMAPS) || (errchar && *errchar)) {
1499 Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(cmd, 1));
1500 return;
1501 }
1502
1504 if (b == -1 || b >= MAX_KEYS) {
1505 Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(cmd, 2));
1506 return;
1507 }
1508
1509 if (c == 3) {
1510 if (keybindings[m][b])
1511 Con_Printf("\"%s\" = \"%s\"\n", Cmd_Argv(cmd, 2), keybindings[m][b]);
1512 else
1513 Con_Printf("\"%s\" is not bound\n", Cmd_Argv(cmd, 2));
1514 return;
1515 }
1516// copy the rest of the command line
1517 line[0] = 0; // start out with a null string
1518 for (i = 3; i < c; i++) {
1519 dp_strlcat (line, Cmd_Argv(cmd, i), sizeof (line));
1520 if (i != (c - 1))
1521 dp_strlcat (line, " ", sizeof (line));
1522 }
1523
1524 if(!Key_SetBinding (b, m, line))
1525 Con_Printf("Key_SetBinding failed for unknown reason\n");
1526}

References b, cmd(), Cmd_Argc(), Cmd_Argv(), Con_Print(), Con_Printf(), dp_strlcat, i, Key_SetBinding(), Key_StringToKeynum(), keybindings, MAX_BINDMAPS, MAX_INPUTLINE, MAX_KEYS, and NULL.

Referenced by Key_Init().

◆ Key_In_BindList_f()

static void Key_In_BindList_f ( cmd_state_t * cmd)
static

Definition at line 1611 of file keys.c.

1612{
1613 int m;
1614 char *errchar = NULL;
1615
1616 if(Cmd_Argc(cmd) >= 2)
1617 {
1618 m = strtol(Cmd_Argv(cmd, 1), &errchar, 0);
1619 if ((m < 0) || (m >= MAX_BINDMAPS) || (errchar && *errchar)) {
1620 Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(cmd, 1));
1621 return;
1622 }
1624 }
1625 else
1626 {
1627 for (m = 0; m < MAX_BINDMAPS; m++)
1629 }
1630}

References cmd(), Cmd_Argc(), Cmd_Argv(), Con_Printf(), Key_PrintBindList(), MAX_BINDMAPS, and NULL.

Referenced by Key_Init().

◆ Key_In_Bindmap_f()

static void Key_In_Bindmap_f ( cmd_state_t * cmd)
static

Definition at line 1529 of file keys.c.

1530{
1531 int m1, m2, c;
1532 char *errchar = NULL;
1533
1534 c = Cmd_Argc (cmd);
1535
1536 if (c != 3) {
1537 Con_Print("in_bindmap <bindmap> <fallback>: set current bindmap and fallback\n");
1538 return;
1539 }
1540
1541 m1 = strtol(Cmd_Argv(cmd, 1), &errchar, 0);
1542 if ((m1 < 0) || (m1 >= MAX_BINDMAPS) || (errchar && *errchar)) {
1543 Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(cmd, 1));
1544 return;
1545 }
1546
1547 m2 = strtol(Cmd_Argv(cmd, 2), &errchar, 0);
1548 if ((m2 < 0) || (m2 >= MAX_BINDMAPS) || (errchar && *errchar)) {
1549 Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(cmd, 2));
1550 return;
1551 }
1552
1553 key_bmap = m1;
1554 key_bmap2 = m2;
1555}

References cmd(), Cmd_Argc(), Cmd_Argv(), Con_Print(), Con_Printf(), key_bmap, key_bmap2, MAX_BINDMAPS, and NULL.

Referenced by Key_Init().

◆ Key_In_Unbind_f()

static void Key_In_Unbind_f ( cmd_state_t * cmd)
static

Definition at line 1457 of file keys.c.

1458{
1459 int b, m;
1460 char *errchar = NULL;
1461
1462 if (Cmd_Argc (cmd) != 3) {
1463 Con_Print("in_unbind <bindmap> <key> : remove commands from a key\n");
1464 return;
1465 }
1466
1467 m = strtol(Cmd_Argv(cmd, 1), &errchar, 0);
1468 if ((m < 0) || (m >= MAX_BINDMAPS) || (errchar && *errchar)) {
1469 Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(cmd, 1));
1470 return;
1471 }
1472
1474 if (b == -1) {
1475 Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(cmd, 2));
1476 return;
1477 }
1478
1479 if(!Key_SetBinding (b, m, ""))
1480 Con_Printf("Key_SetBinding failed for unknown reason\n");
1481}

References b, cmd(), Cmd_Argc(), Cmd_Argv(), Con_Print(), Con_Printf(), Key_SetBinding(), Key_StringToKeynum(), MAX_BINDMAPS, and NULL.

Referenced by Key_Init().

◆ Key_Init()

void Key_Init ( void )

Definition at line 1710 of file keys.c.

1711{
1714
1715//
1716// register our functions
1717//
1718 Cmd_AddCommand(CF_CLIENT, "in_bind", Key_In_Bind_f, "binds a command to the specified key in the selected bindmap");
1719 Cmd_AddCommand(CF_CLIENT, "in_unbind", Key_In_Unbind_f, "removes command on the specified key in the selected bindmap");
1720 Cmd_AddCommand(CF_CLIENT, "in_bindlist", Key_In_BindList_f, "bindlist: displays bound keys for all bindmaps, or the given bindmap");
1721 Cmd_AddCommand(CF_CLIENT, "in_bindmap", Key_In_Bindmap_f, "selects active foreground and background (used only if a key is not bound in the foreground) bindmaps for typing");
1722 Cmd_AddCommand(CF_CLIENT, "in_releaseall", Key_ReleaseAll_f, "releases all currently pressed keys (debug command)");
1723
1724 Cmd_AddCommand(CF_CLIENT, "bind", Key_Bind_f, "binds a command to the specified key in bindmap 0");
1725 Cmd_AddCommand(CF_CLIENT, "unbind", Key_Unbind_f, "removes a command on the specified key in bindmap 0");
1726 Cmd_AddCommand(CF_CLIENT, "bindlist", Key_BindList_f, "bindlist: displays bound keys for bindmap 0 bindmaps");
1727 Cmd_AddCommand(CF_CLIENT, "unbindall", Key_Unbindall_f, "removes all commands from all keys in all bindmaps (leaving only shift-escape and escape)");
1728
1729 Cmd_AddCommand(CF_CLIENT, "history", Key_History_f, "prints the history of executed commands (history X prints the last X entries, history -c clears the whole history)");
1730
1732}
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.c:1661
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
static void Key_History_Init(void)
Definition keys.c:50
static void Key_History_f(cmd_state_t *cmd)
Definition keys.c:300
static void Key_In_Bind_f(cmd_state_t *cmd)
Definition keys.c:1484
static void Key_In_Unbind_f(cmd_state_t *cmd)
Definition keys.c:1457
static void Key_In_BindList_f(cmd_state_t *cmd)
Definition keys.c:1611
static void Key_In_Bindmap_f(cmd_state_t *cmd)
Definition keys.c:1529
static void Key_Unbind_f(cmd_state_t *cmd)
Definition keys.c:1558
static void Key_Bind_f(cmd_state_t *cmd)
Definition keys.c:1639
static void Key_BindList_f(cmd_state_t *cmd)
Definition keys.c:1633
void Key_ReleaseAll_f(cmd_state_t *cmd)
Definition keys.c:2088
static void Key_Unbindall_f(cmd_state_t *cmd)
Definition keys.c:1578

References CF_CLIENT, Cmd_AddCommand(), con_closeontoggleconsole, Cvar_RegisterVariable(), Key_Bind_f(), Key_BindList_f(), Key_ClearEditLine(), Key_History_f(), Key_History_Init(), Key_In_Bind_f(), Key_In_BindList_f(), Key_In_Bindmap_f(), Key_In_Unbind_f(), key_linepos, Key_ReleaseAll_f(), Key_Unbind_f(), and Key_Unbindall_f().

Referenced by CL_Init().

◆ Key_KeynumToString()

const char * Key_KeynumToString ( int keynum,
char * tinystr,
size_t tinystrlength )

Definition at line 1383 of file keys.c.

1384{
1385 const keyname_t *kn;
1386
1387 // -1 is an invalid code
1388 if (keynum < 0)
1389 return "<KEY NOT FOUND>";
1390
1391 // search overrides first, because some characters are special
1392 for (kn = keynames; kn->name; kn++)
1393 if (keynum == kn->keynum)
1394 return kn->name;
1395
1396 // if it is printable, output it as a single character
1397 if (keynum > 32)
1398 {
1399 u8_fromchar(keynum, tinystr, tinystrlength);
1400 return tinystr;
1401 }
1402
1403 // if it is not overridden and not printable, we don't know what to do with it
1404 return "<UNKNOWN KEYNUM>";
1405}
static const keyname_t keynames[]
Definition keys.c:336
int keynum
Definition keys.c:332
const char * name
Definition keys.c:331

References keynames, keyname_t::keynum, keyname_t::name, and u8_fromchar().

Referenced by Key_PrintBindList(), Key_WriteBindings(), M_Keys_Draw(), M_Keys_Key(), and VM_keynumtostring().

◆ Key_Message()

static void Key_Message ( cmd_state_t * cmd,
int key,
int ascii )
static

Definition at line 1301 of file keys.c.

1302{
1303 int linepos;
1304 char vabuf[1024];
1305
1306 key = Key_Convert_NumPadKey(key);
1307
1308 if (key == K_ENTER || key == K_KP_ENTER || ascii == 10 || ascii == 13)
1309 {
1310 if(chat_mode < 0)
1311 Cmd_ExecuteString(cmd, chat_buffer, strlen(chat_buffer), src_local, true); // not Cbuf_AddText to allow semiclons in args; however, this allows no variables then. Use aliases!
1312 else
1313 CL_ForwardToServer(va(vabuf, sizeof(vabuf), "%s %s", chat_mode ? "say_team" : "say ", chat_buffer));
1314
1317 return;
1318 }
1319
1320 if (key == K_ESCAPE) {
1323 return;
1324 }
1325
1326 linepos = Key_Parse_CommonKeys(cmd, false, key, ascii);
1327 if (linepos >= 0)
1328 {
1329 chat_bufferpos = linepos;
1330 return;
1331 }
1332
1333 // ctrl+key generates an ascii value < 32 and shows a char from the charmap
1334 if (ascii > 0 && ascii < 32 && utf8_enable.integer)
1335 ascii = 0xE000 + ascii;
1336
1337 if (!ascii)
1338 return; // non printable
1339
1340 chat_bufferpos = Key_AddChar(ascii, false);
1341}
void CL_ForwardToServer(const char *s)
adds the string as a clc_stringcmd to the client message.
Definition cl_cmd.c:54
void Cmd_ExecuteString(cmd_state_t *cmd, const char *text, size_t textlen, cmd_source_t src, qbool lockmutex)
Parses a single line of text into arguments and tries to execute it.
Definition cmd.c:2068
@ src_local
from the command buffer
Definition cmd.h:75
signed char chat_mode
Definition keys.c:699
cvar_t utf8_enable
Definition utf8lib.c:11

References chat_buffer, chat_bufferpos, chat_mode, CL_ForwardToServer(), cmd(), Cmd_ExecuteString(), cvar_t::integer, K_ENTER, K_ESCAPE, K_KP_ENTER, Key_AddChar(), Key_ClearEditLine(), Key_Convert_NumPadKey(), key_dest, key_game, Key_Parse_CommonKeys(), src_local, strlen(), utf8_enable, and va().

Referenced by Key_Event().

◆ Key_Parse_CommonKeys()

int Key_Parse_CommonKeys ( cmd_state_t * cmd,
qbool is_console,
int key,
int unicode )

Definition at line 750 of file keys.c.

751{
752 char *line;
753 int linepos, linestart;
754 unsigned int linesize;
755 if (is_console)
756 {
757 line = key_line;
758 linepos = key_linepos;
759 linesize = sizeof(key_line);
760 linestart = 1;
761 }
762 else
763 {
764 line = chat_buffer;
765 linepos = chat_bufferpos;
766 linesize = sizeof(chat_buffer);
767 linestart = 0;
768 }
769
770 if ((key == 'v' && KM_CTRL) || ((key == K_INS || key == K_KP_INS) && KM_SHIFT))
771 {
772 char *cbd, *p;
773 if ((cbd = Sys_SDL_GetClipboardData()) != 0)
774 {
775 int i;
776#if 1
777 p = cbd;
778 while (*p)
779 {
780 if (*p == '\r' && *(p+1) == '\n')
781 {
782 *p++ = ';';
783 *p++ = ' ';
784 }
785 else if (*p == '\n' || *p == '\r' || *p == '\b')
786 *p++ = ';';
787 else
788 p++;
789 }
790#else
791 strtok(cbd, "\n\r\b");
792#endif
793 i = (int)strlen(cbd);
794 if (i + linepos >= MAX_INPUTLINE)
795 i= MAX_INPUTLINE - linepos - 1;
796 if (i > 0)
797 {
798 cbd[i] = 0;
799 memmove(line + linepos + i, line + linepos, linesize - linepos - i);
800 memcpy(line + linepos, cbd, i);
801 linepos += i;
802 }
803 Z_Free(cbd);
804 }
805 return linepos;
806 }
807
808 if (key == 'u' && KM_CTRL) // like vi/readline ^u: delete currently edited line
809 {
810 return Key_ClearEditLine(is_console);
811 }
812
813 if (key == K_TAB)
814 {
815 if (is_console && KM_CTRL) // append the cvar value to the cvar name
816 {
817 int cvar_len, cvar_str_len, chars_to_move;
818 char k;
819 char cvar[MAX_INPUTLINE];
820 const char *cvar_str;
821
822 // go to the start of the variable
823 while(--linepos)
824 {
825 k = line[linepos];
826 if(k == '\"' || k == ';' || k == ' ' || k == '\'')
827 break;
828 }
829 linepos++;
830
831 // save the variable name in cvar
832 for(cvar_len=0; (k = line[linepos + cvar_len]) != 0; cvar_len++)
833 {
834 if(k == '\"' || k == ';' || k == ' ' || k == '\'')
835 break;
836 cvar[cvar_len] = k;
837 }
838 if (cvar_len==0)
839 return linepos;
840 cvar[cvar_len] = 0;
841
842 // go to the end of the cvar
843 linepos += cvar_len;
844
845 // save the content of the variable in cvar_str
847 cvar_str_len = (int)strlen(cvar_str);
848 if (cvar_str_len==0)
849 return linepos;
850
851 // insert space and cvar_str in line
852 chars_to_move = (int)strlen(&line[linepos]);
853 if (linepos + 1 + cvar_str_len + chars_to_move < MAX_INPUTLINE)
854 {
855 if (chars_to_move)
856 memmove(&line[linepos + 1 + cvar_str_len], &line[linepos], chars_to_move);
857 line[linepos++] = ' ';
858 memcpy(&line[linepos], cvar_str, cvar_str_len);
859 linepos += cvar_str_len;
860 line[linepos + chars_to_move] = 0;
861 }
862 else
863 Con_Printf("Couldn't append cvar value, edit line too long.\n");
864 return linepos;
865 }
866
867 if (KM_NONE)
868 return Con_CompleteCommandLine(cmd, is_console);
869 }
870
871 // Advanced Console Editing by Radix radix@planetquake.com
872 // Added/Modified by EvilTypeGuy eviltypeguy@qeradiant.com
873 // Enhanced by [515]
874 // Enhanced by terencehill
875
876 // move cursor to the previous character
877 if (key == K_LEFTARROW || key == K_KP_LEFTARROW)
878 {
879 if(KM_CTRL) // move cursor to the previous word
880 {
881 int pos;
882 char k;
883 if (linepos <= linestart + 1)
884 return linestart;
885 pos = linepos;
886
887 do {
888 k = line[--pos];
889 if (!(k == '\"' || k == ';' || k == ' ' || k == '\''))
890 break;
891 } while(pos > linestart); // skip all "; ' after the word
892
893 if (pos == linestart)
894 return linestart;
895
896 do {
897 k = line[--pos];
898 if (k == '\"' || k == ';' || k == ' ' || k == '\'')
899 {
900 pos++;
901 break;
902 }
903 } while(pos > linestart);
904
905 linepos = pos;
906 return linepos;
907 }
908
909 if(KM_SHIFT) // move cursor to the previous character ignoring colors
910 {
911 int pos;
912 size_t inchar = 0;
913 if (linepos <= linestart + 1)
914 return linestart;
915 pos = (int)u8_prevbyte(line + linestart, linepos - linestart) + linestart;
916 while (pos > linestart)
917 if(pos-1 >= linestart && line[pos-1] == STRING_COLOR_TAG && isdigit(line[pos]))
918 pos-=2;
919 else if(pos-4 >= linestart && line[pos-4] == STRING_COLOR_TAG && line[pos-3] == STRING_COLOR_RGB_TAG_CHAR
920 && isxdigit(line[pos-2]) && isxdigit(line[pos-1]) && isxdigit(line[pos]))
921 pos-=5;
922 else
923 {
924 if(pos-1 >= linestart && line[pos-1] == STRING_COLOR_TAG && line[pos] == STRING_COLOR_TAG) // consider ^^ as a character
925 pos--;
926 pos--;
927 break;
928 }
929 if (pos < linestart)
930 return linestart;
931 // we need to move to the beginning of the character when in a wide character:
932 u8_charidx(line, pos + 1, &inchar);
933 linepos = (int)(pos + 1 - inchar);
934 return linepos;
935 }
936
937 if(KM_NONE)
938 {
939 if (linepos <= linestart + 1)
940 return linestart;
941 // hide ']' from u8_prevbyte otherwise it could go out of bounds
942 linepos = (int)u8_prevbyte(line + linestart, linepos - linestart) + linestart;
943 return linepos;
944 }
945 }
946
947 // delete char before cursor
948 if ((key == K_BACKSPACE && KM_NONE) || (key == 'h' && KM_CTRL))
949 {
950 if (linepos > linestart)
951 {
952 // hide ']' from u8_prevbyte otherwise it could go out of bounds
953 int newpos = (int)u8_prevbyte(line + linestart, linepos - linestart) + linestart;
954 dp_strlcpy(line + newpos, line + linepos, linesize + 1 - linepos);
955 linepos = newpos;
956 }
957 return linepos;
958 }
959
960 // delete char on cursor
961 if ((key == K_DEL || key == K_KP_DEL) && KM_NONE)
962 {
963 size_t linelen;
964 linelen = strlen(line);
965 if (linepos < (int)linelen)
966 memmove(line + linepos, line + linepos + u8_bytelen(line + linepos, 1), linelen - linepos);
967 return linepos;
968 }
969
970 // move cursor to the next character
971 if (key == K_RIGHTARROW || key == K_KP_RIGHTARROW)
972 {
973 if (KM_CTRL) // move cursor to the next word
974 {
975 int pos, len;
976 char k;
977 len = (int)strlen(line);
978 if (linepos >= len)
979 return linepos;
980 pos = linepos;
981
982 while(++pos < len)
983 {
984 k = line[pos];
985 if(k == '\"' || k == ';' || k == ' ' || k == '\'')
986 break;
987 }
988
989 if (pos < len) // skip all "; ' after the word
990 while(++pos < len)
991 {
992 k = line[pos];
993 if (!(k == '\"' || k == ';' || k == ' ' || k == '\''))
994 break;
995 }
996 linepos = pos;
997 return linepos;
998 }
999
1000 if (KM_SHIFT) // move cursor to the next character ignoring colors
1001 {
1002 int pos, len;
1003 len = (int)strlen(line);
1004 if (linepos >= len)
1005 return linepos;
1006 pos = linepos;
1007
1008 // go beyond all initial consecutive color tags, if any
1009 if(pos < len)
1010 while (line[pos] == STRING_COLOR_TAG)
1011 {
1012 if(isdigit(line[pos+1]))
1013 pos+=2;
1014 else if(line[pos+1] == STRING_COLOR_RGB_TAG_CHAR && isxdigit(line[pos+2]) && isxdigit(line[pos+3]) && isxdigit(line[pos+4]))
1015 pos+=5;
1016 else
1017 break;
1018 }
1019
1020 // skip the char
1021 if (line[pos] == STRING_COLOR_TAG && line[pos+1] == STRING_COLOR_TAG) // consider ^^ as a character
1022 pos++;
1023 pos += (int)u8_bytelen(line + pos, 1);
1024
1025 // now go beyond all next consecutive color tags, if any
1026 if(pos < len)
1027 while (line[pos] == STRING_COLOR_TAG)
1028 {
1029 if(isdigit(line[pos+1]))
1030 pos+=2;
1031 else if(line[pos+1] == STRING_COLOR_RGB_TAG_CHAR && isxdigit(line[pos+2]) && isxdigit(line[pos+3]) && isxdigit(line[pos+4]))
1032 pos+=5;
1033 else
1034 break;
1035 }
1036 linepos = pos;
1037 return linepos;
1038 }
1039
1040 if (KM_NONE)
1041 {
1042 if (linepos >= (int)strlen(line))
1043 return linepos;
1044 linepos += (int)u8_bytelen(line + linepos, 1);
1045 return linepos;
1046 }
1047 }
1048
1049 if ((key == K_INS || key == K_KP_INS) && KM_NONE) // toggle insert mode
1050 {
1051 key_insert ^= 1;
1052 return linepos;
1053 }
1054
1055 if (key == K_HOME || key == K_KP_HOME)
1056 {
1057 if (is_console && KM_CTRL)
1058 {
1060 return linepos;
1061 }
1062 if (KM_NONE)
1063 return linestart;
1064 }
1065
1066 if (key == K_END || key == K_KP_END)
1067 {
1068 if (is_console && KM_CTRL)
1069 {
1070 con_backscroll = 0;
1071 return linepos;
1072 }
1073 if (KM_NONE)
1074 return (int)strlen(line);
1075 }
1076
1077 return -1;
1078}
int Con_CompleteCommandLine(cmd_state_t *cmd, qbool is_console)
wrapper function to attempt to either complete the command line or to list possible matches grouped b...
Definition console.c:2898
const char * Cvar_VariableString(cvar_state_t *cvars, const char *var_name, unsigned neededflags)
Definition cvar.c:149
#define STRING_COLOR_RGB_TAG_CHAR
Definition draw.h:143
float K_BACKSPACE
Definition keycodes.qc:14
float K_RIGHTARROW
Definition keycodes.qc:18
float K_DEL
Definition keycodes.qc:38
float K_LEFTARROW
Definition keycodes.qc:17
float K_HOME
Definition keycodes.qc:41
float K_END
Definition keycodes.qc:42
float K_INS
Definition keycodes.qc:37
float K_TAB
Definition keycodes.qc:7
float cvar(string name)
#define CON_TEXTSIZE
max scrollback buffer characters in console
Definition qdefs.h:95
char * Sys_SDL_GetClipboardData(void)
Definition sys_null.c:17
int u8_charidx(const char *_s, size_t i, size_t *len)
Get the char-index for a byte-index.
Definition utf8lib.c:462
size_t u8_prevbyte(const char *_s, size_t i)
Get the byte offset of the previous byte.
Definition utf8lib.c:525
#define Z_Free(data)
Definition zone.h:164

References CF_CLIENT, CF_SERVER, chat_buffer, chat_bufferpos, cmd(), con_backscroll, Con_CompleteCommandLine(), Con_Printf(), CON_TEXTSIZE, cvar(), Cvar_VariableString(), cvars_all, dp_strlcpy, i, int(), K_BACKSPACE, K_DEL, K_END, K_HOME, K_INS, K_KP_DEL, K_KP_END, K_KP_HOME, K_KP_INS, K_KP_LEFTARROW, K_KP_RIGHTARROW, K_LEFTARROW, K_RIGHTARROW, K_TAB, Key_ClearEditLine(), key_insert, key_line, key_linepos, KM_CTRL, KM_NONE, KM_SHIFT, MAX_INPUTLINE, STRING_COLOR_RGB_TAG_CHAR, STRING_COLOR_TAG, strlen(), Sys_SDL_GetClipboardData(), u8_bytelen(), u8_charidx(), u8_prevbyte(), and Z_Free.

Referenced by Key_Console(), and Key_Message().

◆ Key_PrintBindList()

static void Key_PrintBindList ( int j)
static

Definition at line 1589 of file keys.c.

1590{
1591 char bindbuf[MAX_INPUTLINE];
1592 char tinystr[TINYSTR_LEN];
1593 const char *p;
1594 int i;
1595
1596 for (i = 0; i < (int)(sizeof(keybindings[0])/sizeof(keybindings[0][0])); i++)
1597 {
1598 p = keybindings[j][i];
1599 if (p)
1600 {
1601 Cmd_QuoteString(bindbuf, sizeof(bindbuf), p, "\"\\", false);
1602 if (j == 0)
1603 Con_Printf("^2%s ^7= \"%s\"\n", Key_KeynumToString (i, tinystr, TINYSTR_LEN), bindbuf);
1604 else
1605 Con_Printf("^3bindmap %d: ^2%s ^7= \"%s\"\n", j, Key_KeynumToString (i, tinystr, TINYSTR_LEN), bindbuf);
1606 }
1607 }
1608}
qbool Cmd_QuoteString(char *out, size_t outlen, const char *in, const char *quoteset, qbool putquotes)
quotes a string so that it can be used as a command argument again; quoteset is a string that contain...
Definition cmd.c:1000
const char * Key_KeynumToString(int keynum, char *tinystr, size_t tinystrlength)
Definition keys.c:1383
#define TINYSTR_LEN
Definition keys.h:46

References Cmd_QuoteString(), Con_Printf(), i, int(), Key_KeynumToString(), keybindings, MAX_INPUTLINE, and TINYSTR_LEN.

Referenced by Key_BindList_f(), and Key_In_BindList_f().

◆ Key_ReleaseAll()

void Key_ReleaseAll ( void )

Definition at line 2075 of file keys.c.

2076{
2077 int key;
2078 // clear the event queue first
2079 eventqueue_idx = 0;
2080 // then send all down events (possibly into the event queue)
2081 for(key = 0; key < MAX_KEYS; ++key)
2082 if(keydown[key])
2083 Key_Event(key, 0, false);
2084 // now all keys are guaranteed down (once the event queue is unblocked)
2085 // and only future events count
2086}

References eventqueue_idx, Key_Event(), keydown, and MAX_KEYS.

Referenced by Key_ReleaseAll_f(), VID_Restart_f(), and VID_Start().

◆ Key_ReleaseAll_f()

void Key_ReleaseAll_f ( cmd_state_t * cmd)

Definition at line 2088 of file keys.c.

2089{
2091}
void Key_ReleaseAll(void)
Definition keys.c:2075

References Key_ReleaseAll().

Referenced by Key_Init().

◆ Key_SetBinding()

qbool Key_SetBinding ( int keynum,
int bindmap,
const char * binding )

Definition at line 1409 of file keys.c.

1410{
1411 char *newbinding;
1412 size_t l;
1413
1414 if (keynum == -1 || keynum >= MAX_KEYS)
1415 return false;
1416 if ((bindmap < 0) || (bindmap >= MAX_BINDMAPS))
1417 return false;
1418
1419// free old bindings
1420 if (keybindings[bindmap][keynum]) {
1421 Z_Free (keybindings[bindmap][keynum]);
1422 keybindings[bindmap][keynum] = NULL;
1423 }
1424 if(!binding[0]) // make "" binds be removed --blub
1425 return true;
1426// allocate memory for new binding
1427 l = strlen (binding);
1428 newbinding = (char *)Z_Malloc (l + 1);
1429 memcpy (newbinding, binding, l + 1);
1430 newbinding[l] = 0;
1431 keybindings[bindmap][keynum] = newbinding;
1432 return true;
1433}
#define Z_Malloc(size)
Definition zone.h:161

References keybindings, MAX_BINDMAPS, MAX_KEYS, NULL, strlen(), Z_Free, and Z_Malloc.

Referenced by Key_Bind_f(), Key_In_Bind_f(), Key_In_Unbind_f(), Key_Unbind_f(), Key_Unbindall_f(), M_UnbindCommand(), and VM_setkeybind().

◆ Key_SetBindMap()

qbool Key_SetBindMap ( int fg,
int bg )

Definition at line 1443 of file keys.c.

1444{
1445 if(fg >= MAX_BINDMAPS)
1446 return false;
1447 if(bg >= MAX_BINDMAPS)
1448 return false;
1449 if(fg >= 0)
1450 key_bmap = fg;
1451 if(bg >= 0)
1452 key_bmap2 = bg;
1453 return true;
1454}

References key_bmap, key_bmap2, and MAX_BINDMAPS.

Referenced by VM_setbindmaps().

◆ Key_Shutdown()

void Key_Shutdown ( void )

Definition at line 1735 of file keys.c.

1736{
1738}
static void Key_History_Shutdown(void)
Definition keys.c:93

References Key_History_Shutdown().

Referenced by CL_Shutdown().

◆ Key_StringToKeynum()

int Key_StringToKeynum ( const char * str)

Definition at line 1354 of file keys.c.

1355{
1356 Uchar ch;
1357 const keyname_t *kn;
1358
1359 if (!str || !str[0])
1360 return -1;
1361 if (!str[1])
1362 return tolower(str[0]);
1363
1364 for (kn = keynames; kn->name; kn++) {
1365 if (!strcasecmp (str, kn->name))
1366 return kn->keynum;
1367 }
1368
1369 // non-ascii keys are Unicode codepoints, so give the character if it's valid;
1370 // error message have more than one character, don't allow it
1371 ch = u8_getnchar(str, &str, 3);
1372 return (ch == 0 || *str != 0) ? -1 : (int)ch;
1373}
#define u8_getnchar(c, e, n)
Definition utf8lib.h:74
int32_t Uchar
Definition utf8lib.h:35

References int(), keynames, keyname_t::keynum, keyname_t::name, and u8_getnchar.

Referenced by Key_Bind_f(), Key_In_Bind_f(), Key_In_Unbind_f(), Key_Unbind_f(), and VM_stringtokeynum().

◆ Key_Unbind_f()

static void Key_Unbind_f ( cmd_state_t * cmd)
static

Definition at line 1558 of file keys.c.

1559{
1560 int b;
1561
1562 if (Cmd_Argc (cmd) != 2) {
1563 Con_Print("unbind <key> : remove commands from a key\n");
1564 return;
1565 }
1566
1568 if (b == -1) {
1569 Con_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(cmd, 1));
1570 return;
1571 }
1572
1573 if(!Key_SetBinding (b, 0, ""))
1574 Con_Printf("Key_SetBinding failed for unknown reason\n");
1575}

References b, cmd(), Cmd_Argc(), Cmd_Argv(), Con_Print(), Con_Printf(), Key_SetBinding(), and Key_StringToKeynum().

Referenced by Key_Init().

◆ Key_Unbindall_f()

static void Key_Unbindall_f ( cmd_state_t * cmd)
static

Definition at line 1578 of file keys.c.

1579{
1580 int i, j;
1581
1582 for (j = 0; j < MAX_BINDMAPS; j++)
1583 for (i = 0; i < (int)(sizeof(keybindings[0])/sizeof(keybindings[0][0])); i++)
1584 if (keybindings[j][i])
1585 Key_SetBinding (i, j, "");
1586}

References i, int(), Key_SetBinding(), keybindings, and MAX_BINDMAPS.

Referenced by Key_Init().

◆ Key_WriteBindings()

void Key_WriteBindings ( qfile_t * f)

Definition at line 1681 of file keys.c.

1682{
1683 int i, j;
1684 char bindbuf[MAX_INPUTLINE];
1685 char tinystr[TINYSTR_LEN];
1686 const char *p;
1687
1688 // Override default binds
1689 FS_Printf(f, "unbindall\n");
1690
1691 for (j = 0; j < MAX_BINDMAPS; j++)
1692 {
1693 for (i = 0; i < (int)(sizeof(keybindings[0])/sizeof(keybindings[0][0])); i++)
1694 {
1695 p = keybindings[j][i];
1696 if (p)
1697 {
1698 Cmd_QuoteString(bindbuf, sizeof(bindbuf), p, "\"\\", false); // don't need to escape $ because cvars are not expanded inside bind
1699 if (j == 0)
1700 FS_Printf(f, "bind %s \"%s\"\n", Key_KeynumToString (i, tinystr, TINYSTR_LEN), bindbuf);
1701 else
1702 FS_Printf(f, "in_bind %d %s \"%s\"\n", j, Key_KeynumToString (i, tinystr, TINYSTR_LEN), bindbuf);
1703 }
1704 }
1705 }
1706}
float f

References Cmd_QuoteString(), f, FS_Printf(), i, int(), Key_KeynumToString(), keybindings, MAX_BINDMAPS, MAX_INPUTLINE, and TINYSTR_LEN.

Referenced by Host_SaveConfig().

Variable Documentation

◆ chat_buffer

◆ chat_bufferpos

◆ chat_mode

signed char chat_mode

Definition at line 699 of file keys.c.

Referenced by Con_DrawInput(), Con_MsgCmdMode(), and Key_Message().

◆ con_closeontoggleconsole

cvar_t con_closeontoggleconsole = {CF_CLIENT | CF_ARCHIVE, "con_closeontoggleconsole","1", "allows toggleconsole binds to close the console as well; when set to 2, this even works when not at the start of the line in console input; when set to 3, this works even if the toggleconsole key is the color tag"}

Definition at line 28 of file keys.c.

28{CF_CLIENT | CF_ARCHIVE, "con_closeontoggleconsole","1", "allows toggleconsole binds to close the console as well; when set to 2, this even works when not at the start of the line in console input; when set to 3, this works even if the toggleconsole key is the color tag"};
#define CF_ARCHIVE
cvar should have its set value saved to config.cfg and persist across sessions
Definition cmd.h:53

Referenced by Key_Event(), and Key_Init().

◆ con_textsize

cvar_t con_textsize
extern

Definition at line 57 of file console.c.

57{CF_CLIENT | CF_ARCHIVE, "con_textsize","8", "console text size in virtual 2D pixels"};

Referenced by Con_CheckResize(), Con_DrawConsole(), Con_DrawConsoleLine(), Con_Init(), Con_LineHeight(), and Key_Console().

◆ eventqueue

eventqueueitem_t eventqueue[32]
static

Definition at line 1805 of file keys.c.

Referenced by Key_EventQueue_Add(), and Key_EventQueue_Unblock().

◆ eventqueue_idx

unsigned eventqueue_idx = 0
static

Definition at line 1806 of file keys.c.

Referenced by Key_EventQueue_Add(), Key_EventQueue_Unblock(), and Key_ReleaseAll().

◆ events_blocked

int events_blocked = 0
static

Definition at line 1804 of file keys.c.

Referenced by Key_Event(), Key_EventQueue_Block(), and Key_EventQueue_Unblock().

◆ history

◆ history_line

◆ history_matchfound

◆ history_savedline

char history_savedline[MAX_INPUTLINE]

◆ history_searchstring

char history_searchstring[MAX_INPUTLINE]

Definition at line 43 of file keys.c.

Referenced by Key_History_Find_Backwards(), and Key_History_Find_Forwards().

◆ key_bmap

int key_bmap
static

Definition at line 326 of file keys.c.

Referenced by Key_Event(), Key_GetBind(), Key_GetBindMap(), Key_In_Bindmap_f(), and Key_SetBindMap().

◆ key_bmap2

int key_bmap2
static

Definition at line 326 of file keys.c.

Referenced by Key_Event(), Key_GetBind(), Key_GetBindMap(), Key_In_Bindmap_f(), and Key_SetBindMap().

◆ key_consoleactive

◆ key_dest

◆ key_insert

qbool key_insert = true

Definition at line 36 of file keys.c.

Referenced by Con_DrawInput(), Key_AddChar(), and Key_Parse_CommonKeys().

◆ key_line

◆ key_linepos

◆ keybindings

◆ keydown

unsigned char keydown[MAX_KEYS]
static

Definition at line 327 of file keys.c.

Referenced by Key_Console(), Key_Event(), and Key_ReleaseAll().

◆ keynames

const keyname_t keynames[]
static

Definition at line 336 of file keys.c.

336 {
337 {"TAB", K_TAB},
338 {"ENTER", K_ENTER},
339 {"ESCAPE", K_ESCAPE},
340 {"SPACE", K_SPACE},
341
342 // spacer so it lines up with keys.h
343
344 {"BACKSPACE", K_BACKSPACE},
345 {"UPARROW", K_UPARROW},
346 {"DOWNARROW", K_DOWNARROW},
347 {"LEFTARROW", K_LEFTARROW},
348 {"RIGHTARROW", K_RIGHTARROW},
349
350 {"ALT", K_ALT},
351 {"CTRL", K_CTRL},
352 {"SHIFT", K_SHIFT},
353
354 {"F1", K_F1},
355 {"F2", K_F2},
356 {"F3", K_F3},
357 {"F4", K_F4},
358 {"F5", K_F5},
359 {"F6", K_F6},
360 {"F7", K_F7},
361 {"F8", K_F8},
362 {"F9", K_F9},
363 {"F10", K_F10},
364 {"F11", K_F11},
365 {"F12", K_F12},
366
367 {"INS", K_INS},
368 {"DEL", K_DEL},
369 {"PGDN", K_PGDN},
370 {"PGUP", K_PGUP},
371 {"HOME", K_HOME},
372 {"END", K_END},
373
374 {"PAUSE", K_PAUSE},
375
376 {"NUMLOCK", K_NUMLOCK},
377 {"CAPSLOCK", K_CAPSLOCK},
378 {"SCROLLOCK", K_SCROLLOCK},
379
380 {"KP_INS", K_KP_INS },
381 {"KP_0", K_KP_0},
382 {"KP_END", K_KP_END },
383 {"KP_1", K_KP_1},
384 {"KP_DOWNARROW", K_KP_DOWNARROW },
385 {"KP_2", K_KP_2},
386 {"KP_PGDN", K_KP_PGDN },
387 {"KP_3", K_KP_3},
388 {"KP_LEFTARROW", K_KP_LEFTARROW },
389 {"KP_4", K_KP_4},
390 {"KP_5", K_KP_5},
391 {"KP_RIGHTARROW", K_KP_RIGHTARROW },
392 {"KP_6", K_KP_6},
393 {"KP_HOME", K_KP_HOME },
394 {"KP_7", K_KP_7},
395 {"KP_UPARROW", K_KP_UPARROW },
396 {"KP_8", K_KP_8},
397 {"KP_PGUP", K_KP_PGUP },
398 {"KP_9", K_KP_9},
399 {"KP_DEL", K_KP_DEL },
400 {"KP_PERIOD", K_KP_PERIOD},
401 {"KP_SLASH", K_KP_SLASH },
402 {"KP_DIVIDE", K_KP_DIVIDE},
403 {"KP_MULTIPLY", K_KP_MULTIPLY},
404 {"KP_MINUS", K_KP_MINUS},
405 {"KP_PLUS", K_KP_PLUS},
406 {"KP_ENTER", K_KP_ENTER},
407 {"KP_EQUALS", K_KP_EQUALS},
408
409 {"PRINTSCREEN", K_PRINTSCREEN},
410
411
412
413 {"MOUSE1", K_MOUSE1},
414
415 {"MOUSE2", K_MOUSE2},
416 {"MOUSE3", K_MOUSE3},
417 {"MWHEELUP", K_MWHEELUP},
418 {"MWHEELDOWN", K_MWHEELDOWN},
419 {"MOUSE4", K_MOUSE4},
420 {"MOUSE5", K_MOUSE5},
421 {"MOUSE6", K_MOUSE6},
422 {"MOUSE7", K_MOUSE7},
423 {"MOUSE8", K_MOUSE8},
424 {"MOUSE9", K_MOUSE9},
425 {"MOUSE10", K_MOUSE10},
426 {"MOUSE11", K_MOUSE11},
427 {"MOUSE12", K_MOUSE12},
428 {"MOUSE13", K_MOUSE13},
429 {"MOUSE14", K_MOUSE14},
430 {"MOUSE15", K_MOUSE15},
431 {"MOUSE16", K_MOUSE16},
432
433
434
435
436 {"JOY1", K_JOY1},
437 {"JOY2", K_JOY2},
438 {"JOY3", K_JOY3},
439 {"JOY4", K_JOY4},
440 {"JOY5", K_JOY5},
441 {"JOY6", K_JOY6},
442 {"JOY7", K_JOY7},
443 {"JOY8", K_JOY8},
444 {"JOY9", K_JOY9},
445 {"JOY10", K_JOY10},
446 {"JOY11", K_JOY11},
447 {"JOY12", K_JOY12},
448 {"JOY13", K_JOY13},
449 {"JOY14", K_JOY14},
450 {"JOY15", K_JOY15},
451 {"JOY16", K_JOY16},
452
453
454
455
456
457
458 {"AUX1", K_AUX1},
459 {"AUX2", K_AUX2},
460 {"AUX3", K_AUX3},
461 {"AUX4", K_AUX4},
462 {"AUX5", K_AUX5},
463 {"AUX6", K_AUX6},
464 {"AUX7", K_AUX7},
465 {"AUX8", K_AUX8},
466 {"AUX9", K_AUX9},
467 {"AUX10", K_AUX10},
468 {"AUX11", K_AUX11},
469 {"AUX12", K_AUX12},
470 {"AUX13", K_AUX13},
471 {"AUX14", K_AUX14},
472 {"AUX15", K_AUX15},
473 {"AUX16", K_AUX16},
474 {"AUX17", K_AUX17},
475 {"AUX18", K_AUX18},
476 {"AUX19", K_AUX19},
477 {"AUX20", K_AUX20},
478 {"AUX21", K_AUX21},
479 {"AUX22", K_AUX22},
480 {"AUX23", K_AUX23},
481 {"AUX24", K_AUX24},
482 {"AUX25", K_AUX25},
483 {"AUX26", K_AUX26},
484 {"AUX27", K_AUX27},
485 {"AUX28", K_AUX28},
486 {"AUX29", K_AUX29},
487 {"AUX30", K_AUX30},
488 {"AUX31", K_AUX31},
489 {"AUX32", K_AUX32},
490
491 {"X360_DPAD_UP", K_X360_DPAD_UP},
492 {"X360_DPAD_DOWN", K_X360_DPAD_DOWN},
493 {"X360_DPAD_LEFT", K_X360_DPAD_LEFT},
494 {"X360_DPAD_RIGHT", K_X360_DPAD_RIGHT},
495 {"X360_START", K_X360_START},
496 {"X360_BACK", K_X360_BACK},
497 {"X360_LEFT_THUMB", K_X360_LEFT_THUMB},
498 {"X360_RIGHT_THUMB", K_X360_RIGHT_THUMB},
499 {"X360_LEFT_SHOULDER", K_X360_LEFT_SHOULDER},
500 {"X360_RIGHT_SHOULDER", K_X360_RIGHT_SHOULDER},
501 {"X360_A", K_X360_A},
502 {"X360_B", K_X360_B},
503 {"X360_X", K_X360_X},
504 {"X360_Y", K_X360_Y},
505 {"X360_LEFT_TRIGGER", K_X360_LEFT_TRIGGER},
506 {"X360_RIGHT_TRIGGER", K_X360_RIGHT_TRIGGER},
507 {"X360_LEFT_THUMB_UP", K_X360_LEFT_THUMB_UP},
508 {"X360_LEFT_THUMB_DOWN", K_X360_LEFT_THUMB_DOWN},
509 {"X360_LEFT_THUMB_LEFT", K_X360_LEFT_THUMB_LEFT},
510 {"X360_LEFT_THUMB_RIGHT", K_X360_LEFT_THUMB_RIGHT},
511 {"X360_RIGHT_THUMB_UP", K_X360_RIGHT_THUMB_UP},
512 {"X360_RIGHT_THUMB_DOWN", K_X360_RIGHT_THUMB_DOWN},
513 {"X360_RIGHT_THUMB_LEFT", K_X360_RIGHT_THUMB_LEFT},
514 {"X360_RIGHT_THUMB_RIGHT", K_X360_RIGHT_THUMB_RIGHT},
515
516 {"JOY_UP", K_JOY_UP},
517 {"JOY_DOWN", K_JOY_DOWN},
518 {"JOY_LEFT", K_JOY_LEFT},
519 {"JOY_RIGHT", K_JOY_RIGHT},
520
521 {"SEMICOLON", ';'}, // because a raw semicolon separates commands
522 {"TILDE", '~'},
523 {"BACKQUOTE", '`'},
524 {"QUOTE", '"'},
525 {"APOSTROPHE", '\''},
526 {"BACKSLASH", '\\'}, // because a raw backslash is used for special characters
527
528 {"MIDINOTE0", K_MIDINOTE0},
529 {"MIDINOTE1", K_MIDINOTE1},
530 {"MIDINOTE2", K_MIDINOTE2},
531 {"MIDINOTE3", K_MIDINOTE3},
532 {"MIDINOTE4", K_MIDINOTE4},
533 {"MIDINOTE5", K_MIDINOTE5},
534 {"MIDINOTE6", K_MIDINOTE6},
535 {"MIDINOTE7", K_MIDINOTE7},
536 {"MIDINOTE8", K_MIDINOTE8},
537 {"MIDINOTE9", K_MIDINOTE9},
538 {"MIDINOTE10", K_MIDINOTE10},
539 {"MIDINOTE11", K_MIDINOTE11},
540 {"MIDINOTE12", K_MIDINOTE12},
541 {"MIDINOTE13", K_MIDINOTE13},
542 {"MIDINOTE14", K_MIDINOTE14},
543 {"MIDINOTE15", K_MIDINOTE15},
544 {"MIDINOTE16", K_MIDINOTE16},
545 {"MIDINOTE17", K_MIDINOTE17},
546 {"MIDINOTE18", K_MIDINOTE18},
547 {"MIDINOTE19", K_MIDINOTE19},
548 {"MIDINOTE20", K_MIDINOTE20},
549 {"MIDINOTE21", K_MIDINOTE21},
550 {"MIDINOTE22", K_MIDINOTE22},
551 {"MIDINOTE23", K_MIDINOTE23},
552 {"MIDINOTE24", K_MIDINOTE24},
553 {"MIDINOTE25", K_MIDINOTE25},
554 {"MIDINOTE26", K_MIDINOTE26},
555 {"MIDINOTE27", K_MIDINOTE27},
556 {"MIDINOTE28", K_MIDINOTE28},
557 {"MIDINOTE29", K_MIDINOTE29},
558 {"MIDINOTE30", K_MIDINOTE30},
559 {"MIDINOTE31", K_MIDINOTE31},
560 {"MIDINOTE32", K_MIDINOTE32},
561 {"MIDINOTE33", K_MIDINOTE33},
562 {"MIDINOTE34", K_MIDINOTE34},
563 {"MIDINOTE35", K_MIDINOTE35},
564 {"MIDINOTE36", K_MIDINOTE36},
565 {"MIDINOTE37", K_MIDINOTE37},
566 {"MIDINOTE38", K_MIDINOTE38},
567 {"MIDINOTE39", K_MIDINOTE39},
568 {"MIDINOTE40", K_MIDINOTE40},
569 {"MIDINOTE41", K_MIDINOTE41},
570 {"MIDINOTE42", K_MIDINOTE42},
571 {"MIDINOTE43", K_MIDINOTE43},
572 {"MIDINOTE44", K_MIDINOTE44},
573 {"MIDINOTE45", K_MIDINOTE45},
574 {"MIDINOTE46", K_MIDINOTE46},
575 {"MIDINOTE47", K_MIDINOTE47},
576 {"MIDINOTE48", K_MIDINOTE48},
577 {"MIDINOTE49", K_MIDINOTE49},
578 {"MIDINOTE50", K_MIDINOTE50},
579 {"MIDINOTE51", K_MIDINOTE51},
580 {"MIDINOTE52", K_MIDINOTE52},
581 {"MIDINOTE53", K_MIDINOTE53},
582 {"MIDINOTE54", K_MIDINOTE54},
583 {"MIDINOTE55", K_MIDINOTE55},
584 {"MIDINOTE56", K_MIDINOTE56},
585 {"MIDINOTE57", K_MIDINOTE57},
586 {"MIDINOTE58", K_MIDINOTE58},
587 {"MIDINOTE59", K_MIDINOTE59},
588 {"MIDINOTE60", K_MIDINOTE60},
589 {"MIDINOTE61", K_MIDINOTE61},
590 {"MIDINOTE62", K_MIDINOTE62},
591 {"MIDINOTE63", K_MIDINOTE63},
592 {"MIDINOTE64", K_MIDINOTE64},
593 {"MIDINOTE65", K_MIDINOTE65},
594 {"MIDINOTE66", K_MIDINOTE66},
595 {"MIDINOTE67", K_MIDINOTE67},
596 {"MIDINOTE68", K_MIDINOTE68},
597 {"MIDINOTE69", K_MIDINOTE69},
598 {"MIDINOTE70", K_MIDINOTE70},
599 {"MIDINOTE71", K_MIDINOTE71},
600 {"MIDINOTE72", K_MIDINOTE72},
601 {"MIDINOTE73", K_MIDINOTE73},
602 {"MIDINOTE74", K_MIDINOTE74},
603 {"MIDINOTE75", K_MIDINOTE75},
604 {"MIDINOTE76", K_MIDINOTE76},
605 {"MIDINOTE77", K_MIDINOTE77},
606 {"MIDINOTE78", K_MIDINOTE78},
607 {"MIDINOTE79", K_MIDINOTE79},
608 {"MIDINOTE80", K_MIDINOTE80},
609 {"MIDINOTE81", K_MIDINOTE81},
610 {"MIDINOTE82", K_MIDINOTE82},
611 {"MIDINOTE83", K_MIDINOTE83},
612 {"MIDINOTE84", K_MIDINOTE84},
613 {"MIDINOTE85", K_MIDINOTE85},
614 {"MIDINOTE86", K_MIDINOTE86},
615 {"MIDINOTE87", K_MIDINOTE87},
616 {"MIDINOTE88", K_MIDINOTE88},
617 {"MIDINOTE89", K_MIDINOTE89},
618 {"MIDINOTE90", K_MIDINOTE90},
619 {"MIDINOTE91", K_MIDINOTE91},
620 {"MIDINOTE92", K_MIDINOTE92},
621 {"MIDINOTE93", K_MIDINOTE93},
622 {"MIDINOTE94", K_MIDINOTE94},
623 {"MIDINOTE95", K_MIDINOTE95},
624 {"MIDINOTE96", K_MIDINOTE96},
625 {"MIDINOTE97", K_MIDINOTE97},
626 {"MIDINOTE98", K_MIDINOTE98},
627 {"MIDINOTE99", K_MIDINOTE99},
628 {"MIDINOTE100", K_MIDINOTE100},
629 {"MIDINOTE101", K_MIDINOTE101},
630 {"MIDINOTE102", K_MIDINOTE102},
631 {"MIDINOTE103", K_MIDINOTE103},
632 {"MIDINOTE104", K_MIDINOTE104},
633 {"MIDINOTE105", K_MIDINOTE105},
634 {"MIDINOTE106", K_MIDINOTE106},
635 {"MIDINOTE107", K_MIDINOTE107},
636 {"MIDINOTE108", K_MIDINOTE108},
637 {"MIDINOTE109", K_MIDINOTE109},
638 {"MIDINOTE110", K_MIDINOTE110},
639 {"MIDINOTE111", K_MIDINOTE111},
640 {"MIDINOTE112", K_MIDINOTE112},
641 {"MIDINOTE113", K_MIDINOTE113},
642 {"MIDINOTE114", K_MIDINOTE114},
643 {"MIDINOTE115", K_MIDINOTE115},
644 {"MIDINOTE116", K_MIDINOTE116},
645 {"MIDINOTE117", K_MIDINOTE117},
646 {"MIDINOTE118", K_MIDINOTE118},
647 {"MIDINOTE119", K_MIDINOTE119},
648 {"MIDINOTE120", K_MIDINOTE120},
649 {"MIDINOTE121", K_MIDINOTE121},
650 {"MIDINOTE122", K_MIDINOTE122},
651 {"MIDINOTE123", K_MIDINOTE123},
652 {"MIDINOTE124", K_MIDINOTE124},
653 {"MIDINOTE125", K_MIDINOTE125},
654 {"MIDINOTE126", K_MIDINOTE126},
655 {"MIDINOTE127", K_MIDINOTE127},
656
657 {NULL, 0}
658};
float K_F8
Definition keycodes.qc:31
float K_KP_9
Definition keycodes.qc:65
float K_MOUSE13
Definition keycodes.qc:143
float K_KP_EQUALS
Definition keycodes.qc:75
float K_AUX11
Definition keycodes.qc:103
float K_KP_8
Definition keycodes.qc:63
float K_MOUSE16
Definition keycodes.qc:146
float K_MOUSE15
Definition keycodes.qc:145
float K_AUX18
Definition keycodes.qc:110
float K_F9
Definition keycodes.qc:32
float K_AUX12
Definition keycodes.qc:104
float K_AUX32
Definition keycodes.qc:124
float K_F11
Definition keycodes.qc:34
float K_AUX20
Definition keycodes.qc:112
float K_F10
Definition keycodes.qc:33
float K_CAPSLOCK
Definition keycodes.qc:45
float K_AUX22
Definition keycodes.qc:114
float K_KP_PERIOD
Definition keycodes.qc:67
float K_AUX29
Definition keycodes.qc:121
float K_KP_3
Definition keycodes.qc:54
float K_KP_0
Definition keycodes.qc:48
float K_AUX17
Definition keycodes.qc:109
float K_MOUSE8
Definition keycodes.qc:138
float K_AUX30
Definition keycodes.qc:122
float K_AUX19
Definition keycodes.qc:111
float K_KP_7
Definition keycodes.qc:61
float K_MOUSE1
Definition keycodes.qc:129
float K_KP_4
Definition keycodes.qc:56
float K_AUX3
Definition keycodes.qc:95
float K_F6
Definition keycodes.qc:29
float K_AUX27
Definition keycodes.qc:119
float K_AUX7
Definition keycodes.qc:99
float K_JOY1
Definition keycodes.qc:83
float K_MOUSE7
Definition keycodes.qc:137
float K_F2
Definition keycodes.qc:25
float K_JOY3
Definition keycodes.qc:85
float K_F4
Definition keycodes.qc:27
float K_AUX16
Definition keycodes.qc:108
float K_AUX15
Definition keycodes.qc:107
float K_AUX8
Definition keycodes.qc:100
float K_MOUSE3
Definition keycodes.qc:131
float K_SPACE
Definition keycodes.qc:10
float K_AUX10
Definition keycodes.qc:102
float K_KP_2
Definition keycodes.qc:52
float K_F3
Definition keycodes.qc:26
float K_AUX13
Definition keycodes.qc:105
float K_NUMLOCK
Definition keycodes.qc:44
float K_JOY2
Definition keycodes.qc:84
float K_MOUSE2
Definition keycodes.qc:130
float K_AUX24
Definition keycodes.qc:116
float K_MOUSE10
Definition keycodes.qc:140
float K_MOUSE14
Definition keycodes.qc:144
float K_AUX23
Definition keycodes.qc:115
float K_AUX31
Definition keycodes.qc:123
float K_SCROLLOCK
Definition keycodes.qc:46
float K_MOUSE11
Definition keycodes.qc:141
float K_F5
Definition keycodes.qc:28
float K_AUX14
Definition keycodes.qc:106
float K_KP_MULTIPLY
Definition keycodes.qc:71
float K_KP_1
Definition keycodes.qc:50
float K_AUX28
Definition keycodes.qc:120
float K_AUX9
Definition keycodes.qc:101
float K_MOUSE6
Definition keycodes.qc:136
float K_MOUSE12
Definition keycodes.qc:142
float K_F7
Definition keycodes.qc:30
float K_MOUSE9
Definition keycodes.qc:139
float K_MOUSE5
Definition keycodes.qc:135
float K_AUX5
Definition keycodes.qc:97
float K_AUX6
Definition keycodes.qc:98
float K_KP_6
Definition keycodes.qc:59
float K_KP_DIVIDE
Definition keycodes.qc:69
float K_AUX25
Definition keycodes.qc:117
float K_AUX21
Definition keycodes.qc:113
float K_JOY4
Definition keycodes.qc:86
float K_MOUSE4
Definition keycodes.qc:134
float K_AUX26
Definition keycodes.qc:118
float K_AUX2
Definition keycodes.qc:94
float K_AUX1
Definition keycodes.qc:93
float K_AUX4
Definition keycodes.qc:96
float K_PAUSE
Definition keycodes.qc:78
@ K_MIDINOTE111
Definition keys.h:350
@ K_MIDINOTE127
Definition keys.h:366
@ K_MIDINOTE55
Definition keys.h:294
@ K_MIDINOTE56
Definition keys.h:295
@ K_MIDINOTE110
Definition keys.h:349
@ K_MIDINOTE114
Definition keys.h:353
@ K_MIDINOTE89
Definition keys.h:328
@ K_X360_A
Definition keys.h:218
@ K_MIDINOTE61
Definition keys.h:300
@ K_MIDINOTE6
Definition keys.h:245
@ K_MIDINOTE77
Definition keys.h:316
@ K_MIDINOTE28
Definition keys.h:267
@ K_MIDINOTE69
Definition keys.h:308
@ K_MIDINOTE9
Definition keys.h:248
@ K_X360_BACK
Definition keys.h:213
@ K_MIDINOTE94
Definition keys.h:333
@ K_MIDINOTE10
Definition keys.h:249
@ K_MIDINOTE44
Definition keys.h:283
@ K_MIDINOTE85
Definition keys.h:324
@ K_MIDINOTE37
Definition keys.h:276
@ K_MIDINOTE57
Definition keys.h:296
@ K_MIDINOTE105
Definition keys.h:344
@ K_MIDINOTE7
Definition keys.h:246
@ K_JOY7
Definition keys.h:159
@ K_MIDINOTE8
Definition keys.h:247
@ K_MIDINOTE115
Definition keys.h:354
@ K_MIDINOTE3
Definition keys.h:242
@ K_MIDINOTE73
Definition keys.h:312
@ K_MIDINOTE5
Definition keys.h:244
@ K_MIDINOTE0
Definition keys.h:239
@ K_JOY12
Definition keys.h:164
@ K_X360_X
Definition keys.h:220
@ K_MIDINOTE62
Definition keys.h:301
@ K_MIDINOTE126
Definition keys.h:365
@ K_MIDINOTE125
Definition keys.h:364
@ K_MIDINOTE63
Definition keys.h:302
@ K_MIDINOTE101
Definition keys.h:340
@ K_X360_RIGHT_SHOULDER
Definition keys.h:217
@ K_MIDINOTE13
Definition keys.h:252
@ K_MIDINOTE4
Definition keys.h:243
@ K_MIDINOTE93
Definition keys.h:332
@ K_MIDINOTE45
Definition keys.h:284
@ K_X360_RIGHT_THUMB_UP
Definition keys.h:228
@ K_MIDINOTE12
Definition keys.h:251
@ K_MIDINOTE78
Definition keys.h:317
@ K_MIDINOTE23
Definition keys.h:262
@ K_MIDINOTE83
Definition keys.h:322
@ K_MIDINOTE86
Definition keys.h:325
@ K_MIDINOTE16
Definition keys.h:255
@ K_X360_DPAD_RIGHT
Definition keys.h:211
@ K_MIDINOTE27
Definition keys.h:266
@ K_JOY10
Definition keys.h:162
@ K_MIDINOTE103
Definition keys.h:342
@ K_JOY_DOWN
Definition keys.h:235
@ K_JOY13
Definition keys.h:165
@ K_X360_RIGHT_TRIGGER
Definition keys.h:223
@ K_JOY14
Definition keys.h:166
@ K_MIDINOTE64
Definition keys.h:303
@ K_X360_DPAD_UP
Definition keys.h:208
@ K_MIDINOTE96
Definition keys.h:335
@ K_JOY15
Definition keys.h:167
@ K_MIDINOTE79
Definition keys.h:318
@ K_JOY16
Definition keys.h:168
@ K_JOY_LEFT
Definition keys.h:236
@ K_MIDINOTE90
Definition keys.h:329
@ K_X360_LEFT_THUMB_RIGHT
Definition keys.h:227
@ K_MIDINOTE97
Definition keys.h:336
@ K_MIDINOTE14
Definition keys.h:253
@ K_X360_DPAD_DOWN
Definition keys.h:209
@ K_MIDINOTE106
Definition keys.h:345
@ K_X360_DPAD_LEFT
Definition keys.h:210
@ K_MIDINOTE82
Definition keys.h:321
@ K_MIDINOTE107
Definition keys.h:346
@ K_MIDINOTE36
Definition keys.h:275
@ K_PRINTSCREEN
Definition keys.h:126
@ K_MIDINOTE88
Definition keys.h:327
@ K_X360_RIGHT_THUMB
Definition keys.h:215
@ K_MIDINOTE49
Definition keys.h:288
@ K_X360_LEFT_THUMB_DOWN
Definition keys.h:225
@ K_MIDINOTE122
Definition keys.h:361
@ K_X360_RIGHT_THUMB_DOWN
Definition keys.h:229
@ K_X360_RIGHT_THUMB_RIGHT
Definition keys.h:231
@ K_MIDINOTE53
Definition keys.h:292
@ K_JOY_RIGHT
Definition keys.h:237
@ K_MIDINOTE109
Definition keys.h:348
@ K_MIDINOTE81
Definition keys.h:320
@ K_MIDINOTE33
Definition keys.h:272
@ K_MIDINOTE58
Definition keys.h:297
@ K_MIDINOTE11
Definition keys.h:250
@ K_MIDINOTE70
Definition keys.h:309
@ K_MIDINOTE124
Definition keys.h:363
@ K_MIDINOTE59
Definition keys.h:298
@ K_MIDINOTE71
Definition keys.h:310
@ K_MIDINOTE31
Definition keys.h:270
@ K_X360_START
Definition keys.h:212
@ K_MIDINOTE67
Definition keys.h:306
@ K_JOY5
Definition keys.h:157
@ K_MIDINOTE39
Definition keys.h:278
@ K_MIDINOTE40
Definition keys.h:279
@ K_MIDINOTE46
Definition keys.h:285
@ K_MIDINOTE48
Definition keys.h:287
@ K_MIDINOTE18
Definition keys.h:257
@ K_MIDINOTE15
Definition keys.h:254
@ K_JOY9
Definition keys.h:161
@ K_MIDINOTE95
Definition keys.h:334
@ K_MIDINOTE116
Definition keys.h:355
@ K_MIDINOTE118
Definition keys.h:357
@ K_MIDINOTE17
Definition keys.h:256
@ K_MIDINOTE120
Definition keys.h:359
@ K_MIDINOTE60
Definition keys.h:299
@ K_MIDINOTE75
Definition keys.h:314
@ K_MIDINOTE19
Definition keys.h:258
@ K_MIDINOTE54
Definition keys.h:293
@ K_MIDINOTE30
Definition keys.h:269
@ K_MIDINOTE34
Definition keys.h:273
@ K_MIDINOTE42
Definition keys.h:281
@ K_X360_RIGHT_THUMB_LEFT
Definition keys.h:230
@ K_MIDINOTE65
Definition keys.h:304
@ K_MIDINOTE123
Definition keys.h:362
@ K_X360_LEFT_THUMB_UP
Definition keys.h:224
@ K_MIDINOTE51
Definition keys.h:290
@ K_MIDINOTE92
Definition keys.h:331
@ K_X360_LEFT_SHOULDER
Definition keys.h:216
@ K_X360_LEFT_THUMB_LEFT
Definition keys.h:226
@ K_MIDINOTE50
Definition keys.h:289
@ K_MIDINOTE41
Definition keys.h:280
@ K_JOY_UP
Definition keys.h:234
@ K_JOY11
Definition keys.h:163
@ K_MIDINOTE24
Definition keys.h:263
@ K_MIDINOTE38
Definition keys.h:277
@ K_MIDINOTE102
Definition keys.h:341
@ K_JOY8
Definition keys.h:160
@ K_MIDINOTE100
Definition keys.h:339
@ K_MIDINOTE119
Definition keys.h:358
@ K_MIDINOTE74
Definition keys.h:313
@ K_MIDINOTE1
Definition keys.h:240
@ K_MIDINOTE25
Definition keys.h:264
@ K_MIDINOTE76
Definition keys.h:315
@ K_MIDINOTE66
Definition keys.h:305
@ K_MIDINOTE21
Definition keys.h:260
@ K_MIDINOTE91
Definition keys.h:330
@ K_MIDINOTE80
Definition keys.h:319
@ K_X360_LEFT_TRIGGER
Definition keys.h:222
@ K_MIDINOTE35
Definition keys.h:274
@ K_MIDINOTE2
Definition keys.h:241
@ K_MIDINOTE22
Definition keys.h:261
@ K_JOY6
Definition keys.h:158
@ K_MIDINOTE112
Definition keys.h:351
@ K_MIDINOTE32
Definition keys.h:271
@ K_MIDINOTE26
Definition keys.h:265
@ K_MIDINOTE108
Definition keys.h:347
@ K_MIDINOTE52
Definition keys.h:291
@ K_MIDINOTE98
Definition keys.h:337
@ K_X360_Y
Definition keys.h:221
@ K_MIDINOTE117
Definition keys.h:356
@ K_X360_B
Definition keys.h:219
@ K_MIDINOTE121
Definition keys.h:360
@ K_MIDINOTE113
Definition keys.h:352
@ K_MIDINOTE99
Definition keys.h:338
@ K_X360_LEFT_THUMB
Definition keys.h:214
@ K_MIDINOTE72
Definition keys.h:311
@ K_MIDINOTE47
Definition keys.h:286
@ K_MIDINOTE43
Definition keys.h:282
@ K_MIDINOTE68
Definition keys.h:307
@ K_MIDINOTE20
Definition keys.h:259
@ K_MIDINOTE104
Definition keys.h:343
@ K_MIDINOTE84
Definition keys.h:323
@ K_MIDINOTE87
Definition keys.h:326
@ K_MIDINOTE29
Definition keys.h:268

Referenced by Key_KeynumToString(), and Key_StringToKeynum().

◆ tbl_keyascii

char tbl_keyascii[MAX_KEYS]
static

Definition at line 1794 of file keys.c.

Referenced by Key_Event().

◆ tbl_keydest

keydest_t tbl_keydest[MAX_KEYS]
static

Definition at line 1795 of file keys.c.

Referenced by Key_Event().