Keyboard handling routines. More...
#include "../client.h"
#include "../cl_screen.h"
#include "../cl_console.h"
#include "../ui/ui_input.h"
#include "../ui/ui_nodes.h"
#include "../../shared/utf8.h"
Go to the source code of this file.
Data Structures | |
struct | keyName_t |
Defines | |
#define | M(x) {#x, K_##x} |
Functions | |
static void | Key_Console (int key, int unicode) |
Interactive line editing and console scrollback. | |
static void | Key_Message (int key) |
Handles input when cls.keyDest == key_message. | |
static int | Key_StringToKeynum (const char *str) |
Convert to given string to keynum. | |
const char * | Key_KeynumToString (int keynum) |
Convert a given keynum to string. | |
const char * | Key_GetBinding (const char *binding, keyBindSpace_t space) |
Return the key binding for a given script command. | |
void | Key_SetBinding (int keynum, const char *binding, keyBindSpace_t space) |
Bind a keynum to script command. | |
static void | Key_Unbind_f (void) |
Unbind a given key binding. | |
static void | Key_Unbindall_f (void) |
Unbind all key bindings. | |
static void | Key_Bind_f (void) |
Binds a key to a given script command. | |
void | Key_WriteBindings (const char *filename) |
Writes lines containing "bind key value". | |
static void | Key_WriteBindings_f (void) |
static void | Key_Bindlist_f (void) |
List all binded keys with its function. | |
static int | Key_CompleteKeyName (const char *partial, const char **match) |
void | Key_Init (void) |
void | Key_SetDest (int keyDest) |
Sets the keyDest in cls. | |
void | Key_Event (unsigned int key, unsigned short unicode, qboolean down, unsigned time) |
Called by the system between frames for both key up and key down events. | |
Variables | |
char | keyLines [MAXKEYLINES][MAXCMDLINE] |
int | keyLinePos |
static int | keyInsert = 1 |
int | editLine = 0 |
int | historyLine = 0 |
int | msgMode |
char | msgBuffer [MAXCMDLINE] |
size_t | msgBufferLen = 0 |
char * | keyBindings [K_KEY_SIZE] |
char * | menuKeyBindings [K_KEY_SIZE] |
char * | battleKeyBindings [K_KEY_SIZE] |
static qboolean | keyDown [K_KEY_SIZE] |
static const keyName_t | keyNames [] |
Keyboard handling routines.
Note: Key up events are sent even if in console mode
Definition in file cl_keys.c.
#define M | ( | x | ) | {#x, K_##x} |
Definition at line 75 of file cl_keys.c.
Referenced by DisplayContentFlags(), mdfour_tail(), and mdfour_update().
static void Key_Bind_f | ( | void | ) | [static] |
Binds a key to a given script command.
Definition at line 695 of file cl_keys.c.
References Cmd_Argc(), Cmd_Argv(), Com_Printf(), i, Key_SetBinding(), Key_StringToKeynum(), keyBindings, KEYSPACE_BATTLE, KEYSPACE_GAME, KEYSPACE_UI, Q_strcat(), and UI_SetKeyBinding().
Referenced by Key_Init().
static void Key_Bindlist_f | ( | void | ) | [static] |
List all binded keys with its function.
Definition at line 825 of file cl_keys.c.
References battleKeyBindings, Com_Printf(), i, K_FIRST_KEY, K_LAST_KEY, Key_KeynumToString(), keyBindings, and menuKeyBindings.
Referenced by Key_Init().
static int Key_CompleteKeyName | ( | const char * | partial, | |
const char ** | match | |||
) | [static] |
Definition at line 844 of file cl_keys.c.
References Cmd_GenericCompleteFunction(), Com_Printf(), len, MAX_COMPLETE, and keyName_t::name.
Referenced by Key_Init().
static void Key_Console | ( | int | key, | |
int | unicode | |||
) | [static] |
Interactive line editing and console scrollback.
[in] | key | key code, either K_ value or lowercase ascii |
[in] | unicode | translated meaning of keypress in unicode |
Definition at line 219 of file cl_keys.c.
References ca_disconnected, Cbuf_AddText(), cls, Com_ConsoleCompleteCommand(), Com_Printf(), Con_Scroll(), CONSOLE_COLORED_TEXT_MASK, CONSOLE_PROMPT_CHAR, editLine, historyLine, i, K_BACKSPACE, K_CTRL, K_DEL, K_DOWNARROW, K_END, K_ENTER, K_HOME, K_INS, K_KP_5, K_KP_DEL, K_KP_DOWNARROW, K_KP_END, K_KP_ENTER, 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, K_KP_UPARROW, K_LEFTARROW, K_MWHEELDOWN, K_MWHEELUP, K_PGDN, K_PGUP, K_RIGHTARROW, K_TAB, K_UPARROW, keyDown, keyInsert, keyLinePos, keyLines, MAXCMDLINE, MAXKEYLINES, Q_strncpyz(), SCR_UpdateScreen(), and client_static_s::state.
Referenced by Key_Event().
void Key_Event | ( | unsigned int | key, | |
unsigned short | unicode, | |||
qboolean | down, | |||
unsigned | time | |||
) |
Called by the system between frames for both key up and key down events.
Definition at line 921 of file cl_keys.c.
References battleKeyBindings, Cbuf_AddText(), CL_OnBattlescape(), cls, Com_Error(), Com_sprintf(), Con_ToggleConsole_f(), ERR_FATAL, i, K_ESCAPE, K_KEY_SIZE, K_MOUSE1, K_MWHEELUP, Key_Console(), key_console, key_game, Key_Message(), key_message, keyBindings, client_static_s::keyDest, keyDown, MAX_STRING_CHARS, menuKeyBindings, mouseSpace, MS_UI, and UI_KeyPressed().
Referenced by IN_SendKeyEvents().
const char* Key_GetBinding | ( | const char * | binding, | |
keyBindSpace_t | space | |||
) |
Return the key binding for a given script command.
[in] | binding | The script command to bind keynum to |
Definition at line 573 of file cl_keys.c.
References battleKeyBindings, i, K_FIRST_KEY, K_LAST_KEY, Key_KeynumToString(), keyBindings, KEYSPACE_BATTLE, KEYSPACE_GAME, KEYSPACE_UI, menuKeyBindings, and Sys_Error().
Referenced by UI_GetReferenceString(), and UI_KeyBindingNodeKeyPressed().
void Key_Init | ( | void | ) |
Definition at line 872 of file cl_keys.c.
Referenced by Qcommon_Init().
const char* Key_KeynumToString | ( | int | keynum | ) |
Convert a given keynum to string.
[in] | keynum | The keynum to convert to string |
Definition at line 546 of file cl_keys.c.
References keyName_t::keynum, and keyName_t::name.
Referenced by CLMN_AddBindings(), IN_EventEnqueue(), Key_Bindlist_f(), Key_GetBinding(), Key_WriteBindings(), UI_KeyBindingNodeKeyPressed(), and UI_Tooltip().
static void Key_Message | ( | int | key | ) | [static] |
Handles input when cls.keyDest == key_message.
Definition at line 445 of file cl_keys.c.
References ca_active, ca_disconnected, Cbuf_AddText(), cls, Com_DPrintf(), Com_Error(), Com_Printf(), DEBUG_CLIENT, ERR_DROP, K_BACKSPACE, K_ENTER, K_ESCAPE, K_KP_ENTER, key_game, Key_SetDest(), MSG_SAY, MSG_SAY_TEAM, msgBuffer, msgBufferLen, msgMode, qfalse, qtrue, client_static_s::state, UTF8_delete_char(), UTF8_encoded_len(), and UTF8_insert_char().
Referenced by Key_Event().
void Key_SetBinding | ( | int | keynum, | |
const char * | binding, | |||
keyBindSpace_t | space | |||
) |
Bind a keynum to script command.
[in] | keynum | Converted from string to keynum |
[in] | binding | The script command to bind keynum to |
[in] | space | The key space to bind the key for (menu, game or battle) |
Definition at line 610 of file cl_keys.c.
References battleKeyBindings, Com_DPrintf(), com_genericPool, DEBUG_CLIENT, K_KEY_SIZE, keyBindings, KEYSPACE_BATTLE, KEYSPACE_GAME, KEYSPACE_UI, Mem_Free, Mem_PoolStrDup, and menuKeyBindings.
Referenced by Key_Bind_f(), Key_Unbind_f(), Key_Unbindall_f(), and UI_KeyBindingNodeKeyPressed().
void Key_SetDest | ( | int | keyDest | ) |
Sets the keyDest in cls.
[in] | keyDest | see keydest_t |
Definition at line 907 of file cl_keys.c.
References cls, key_console, client_static_s::keyDest, and UI_ReleaseInput().
Referenced by Con_Close(), Con_MessageModeSay_f(), Con_MessageModeSayTeam_f(), Con_ToggleChat_f(), Con_ToggleConsole_f(), Key_Message(), UI_PopWindow(), and UI_PushWindowDelete().
static int Key_StringToKeynum | ( | const char * | str | ) | [static] |
Convert to given string to keynum.
[in] | str | The keystring to convert to keynum |
Definition at line 521 of file cl_keys.c.
References keyName_t::keynum, keyName_t::name, and Q_strcasecmp.
Referenced by Key_Bind_f(), and Key_Unbind_f().
static void Key_Unbind_f | ( | void | ) | [static] |
Unbind a given key binding.
Definition at line 651 of file cl_keys.c.
References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Key_SetBinding(), Key_StringToKeynum(), KEYSPACE_BATTLE, KEYSPACE_GAME, and KEYSPACE_UI.
Referenced by Key_Init().
static void Key_Unbindall_f | ( | void | ) | [static] |
Unbind all key bindings.
Definition at line 678 of file cl_keys.c.
References Cmd_Argv(), i, K_FIRST_KEY, K_LAST_KEY, Key_SetBinding(), keyBindings, KEYSPACE_GAME, and KEYSPACE_UI.
Referenced by Key_Init().
void Key_WriteBindings | ( | const char * | filename | ) |
Writes lines containing "bind key value".
[in] | filename | Path to print the keybinding too |
Definition at line 743 of file cl_keys.c.
References battleKeyBindings, binding, Com_Printf(), qFILE_s::f, f, FILE_WRITE, FS_CloseFile(), FS_Gamedir(), FS_OpenFile(), FS_Printf(), FS_RemoveFile(), i, K_LAST_KEY, uiKeyBinding_s::key, Key_KeynumToString(), keyBindings, menuKeyBindings, uiKeyBinding_s::node, uiKeyBinding_s::property, qfalse, qtrue, value_s::string, UI_GetKeyBindingByIndex(), UI_GetKeyBindingCount(), UI_GetPath(), and va().
Referenced by CL_Shutdown(), and Key_WriteBindings_f().
static void Key_WriteBindings_f | ( | void | ) | [static] |
Definition at line 808 of file cl_keys.c.
References Cmd_Argc(), Cmd_Argv(), Com_DefaultExtension(), Com_Printf(), Key_WriteBindings(), MAX_QPATH, and Q_strncpyz().
Referenced by Key_Init().
char* battleKeyBindings[K_KEY_SIZE] |
Definition at line 66 of file cl_keys.c.
Referenced by CLMN_InitKeyList_f(), Key_Bindlist_f(), Key_Event(), Key_GetBinding(), Key_SetBinding(), and Key_WriteBindings().
int editLine = 0 |
Definition at line 43 of file cl_keys.c.
Referenced by Con_DrawInput(), Con_LoadConsoleHistory(), Key_ClearTyping(), and Key_Console().
int historyLine = 0 |
Definition at line 44 of file cl_keys.c.
Referenced by Con_LoadConsoleHistory(), Con_SaveConsoleHistory(), and Key_Console().
char* keyBindings[K_KEY_SIZE] |
Definition at line 64 of file cl_keys.c.
Referenced by CLMN_InitKeyList_f(), Key_Bind_f(), Key_Bindlist_f(), Key_Event(), Key_GetBinding(), Key_SetBinding(), Key_Unbindall_f(), and Key_WriteBindings().
Definition at line 68 of file cl_keys.c.
Referenced by Key_Console(), and Key_Event().
int keyInsert = 1 [static] |
Definition at line 41 of file cl_keys.c.
Referenced by Key_Console().
int keyLinePos |
Definition at line 39 of file cl_keys.c.
Referenced by Con_DrawInput(), Key_ClearTyping(), Key_Console(), and Key_Init().
char keyLines[MAXKEYLINES][MAXCMDLINE] |
Definition at line 38 of file cl_keys.c.
Referenced by Con_DrawInput(), Con_LoadConsoleHistory(), Con_SaveConsoleHistory(), Key_ClearTyping(), Key_Console(), and Key_Init().
char* menuKeyBindings[K_KEY_SIZE] |
Definition at line 65 of file cl_keys.c.
Referenced by CLMN_InitKeyList_f(), Key_Bindlist_f(), Key_Event(), Key_GetBinding(), Key_SetBinding(), and Key_WriteBindings().
char msgBuffer[MAXCMDLINE] |
Definition at line 47 of file cl_keys.c.
Referenced by Con_DrawNotify(), and Key_Message().
size_t msgBufferLen = 0 |
Definition at line 48 of file cl_keys.c.
Referenced by Con_DrawNotify(), and Key_Message().
int msgMode |
Definition at line 46 of file cl_keys.c.
Referenced by Con_DrawNotify(), Con_MessageModeSay_f(), Con_MessageModeSayTeam_f(), and Key_Message().