UFO: Alien Invasion
|
Keyboard handling routines. More...
#include "../client.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 |
Macros | |
#define | M(x) {#x, K_##x} |
Functions | |
bool | Key_IsDown (unsigned int key) |
Checks whether a given key is currently pressed. More... | |
bool | Key_IsNumlock (void) |
static void | Key_Console (int key, int unicode) |
Interactive line editing and console scrollback. More... | |
int | Key_StringToKeynum (const char *str) |
Convert to given string to keynum. More... | |
const char * | Key_KeynumToString (int keynum) |
Convert a given keynum to string. More... | |
const char * | Key_GetBinding (const char *binding, keyBindSpace_t space) |
Return the key binding for a given script command. More... | |
void | Key_SetBinding (int keynum, const char *binding, keyBindSpace_t space) |
Bind a keynum to script command. More... | |
static void | Key_Unbind_f (void) |
Unbind a given key binding. More... | |
static void | Key_Unbindall_f (void) |
Unbind all key bindings. More... | |
static void | Key_Bind_f (void) |
Binds a key to a given script command. More... | |
void | Key_WriteBindings (const char *filename) |
Writes lines containing "bind key value". More... | |
static void | Key_WriteBindings_f (void) |
static void | Key_Bindlist_f (void) |
List all binded keys with its function. More... | |
static int | Key_CompleteKeyName (const char *partial, const char **match) |
void | Key_Init (void) |
void | Key_SetDest (keydest_t keyDest) |
Sets the keyDest in cls. More... | |
static bool | Key_IsMouseButton (unsigned int key) |
Returns true if the Key is a mouse event. More... | |
void | Key_Event (unsigned int key, unsigned short unicode, bool down, unsigned time) |
Called by the system between frames for both key up and key down events. More... | |
Variables | |
char | keyLines [MAXKEYLINES][MAXCMDLINE] |
uint32_t | 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 bool | 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.cpp.
#define M | ( | x | ) | {#x, K_##x} |
Definition at line 74 of file cl_keys.cpp.
Referenced by mdfour_tail(), and mdfour_update().
Binds a key to a given script command.
Definition at line 626 of file cl_keys.cpp.
References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Key_SetBinding(), Key_StringToKeynum(), keyBindings, KEYSPACE_BATTLE, KEYSPACE_GAME, KEYSPACE_UI, Q_streq, and UI_SetKeyBinding().
Referenced by Key_Init().
List all binded keys with its function.
Definition at line 747 of file cl_keys.cpp.
References battleKeyBindings, Com_Printf(), i, K_FIRST_KEY, K_LAST_KEY, Key_KeynumToString(), keyBindings, and menuKeyBindings.
Referenced by Key_Init().
|
static |
Definition at line 764 of file cl_keys.cpp.
References Cmd_GenericCompleteFunction(), Com_Printf(), and keyName_t::name.
Referenced by Key_Init().
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 236 of file cl_keys.cpp.
References Cbuf_AddText(), Com_ConsoleCompleteCommand(), Com_Printf(), Con_Scroll(), 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_MULTIPLY, 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, key, keyDown, keyInsert, keyLinePos, keyLines, MAXCMDLINE, MAXKEYLINES, Q_strncpyz(), and unicode.
Referenced by Key_Event().
Called by the system between frames for both key up and key down events.
Definition at line 845 of file cl_keys.cpp.
References battleKeyBindings, Cbuf_AddText(), CL_OnBattlescape(), cls, Com_Error(), Con_ToggleConsole_f(), down, ERR_FATAL, i, IN_GetMouseSpace, K_ESCAPE, K_KEY_SIZE, K_MOUSE1, K_MWHEELUP, key, key_console, Key_Console(), key_game, Key_IsMouseButton(), keyBindings, client_static_s::keyDest, keyDown, menuKeyBindings, MS_UI, UI_KeyPressed(), UI_KeyRelease(), and unicode.
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 |
space | Namespace of the key binding |
Definition at line 511 of file cl_keys.cpp.
References battleKeyBindings, i, K_FIRST_KEY, K_LAST_KEY, Key_KeynumToString(), keyBindings, KEYSPACE_BATTLE, KEYSPACE_GAME, KEYSPACE_UI, menuKeyBindings, Q_streq, and Sys_Error().
Definition at line 776 of file cl_keys.cpp.
References battleKeyBindings, Cmd_AddCommand(), Cmd_AddParamCompleteFunction(), CONSOLE_PROMPT_CHAR, i, Key_Bind_f(), Key_Bindlist_f(), Key_CompleteKeyName(), Key_Unbind_f(), Key_Unbindall_f(), Key_WriteBindings_f(), keyBindings, keyDown, keyLinePos, keyLines, MAXKEYLINES, menuKeyBindings, and OBJZERO.
Referenced by Qcommon_Init().
bool Key_IsDown | ( | unsigned int | key | ) |
Checks whether a given key is currently pressed.
[in] | key | The key to check, |
keyNum_t
true
if the key is pressed, false
otherwise Definition at line 214 of file cl_keys.cpp.
References K_KEY_SIZE, key, and keyDown.
Referenced by uiAbstractValueNode::getFactorFloat(), uiContainerNode::onDndFinished(), and UI_ContainerNodeDrawDropPreview().
|
static |
Returns true if the Key is a mouse event.
[in] | key | Key code |
Definition at line 835 of file cl_keys.cpp.
References K_MOUSE1, and K_MOUSE5.
Referenced by Key_Event().
bool Key_IsNumlock | ( | void | ) |
Definition at line 221 of file cl_keys.cpp.
Referenced by IN_TranslateKey().
const char* Key_KeynumToString | ( | int | keynum | ) |
Convert a given keynum to string.
[in] | keynum | The keynum to convert to string |
Definition at line 485 of file cl_keys.cpp.
References keyName_t::name.
Referenced by CLMN_AddBindings(), CLMN_AddUIBindings(), IN_EventEnqueue(), Key_Bindlist_f(), Key_GetBinding(), Key_WriteBindings(), UI_SetKeyBindingEx(), and UI_Tooltip().
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 547 of file cl_keys.cpp.
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(), and Key_Unbindall_f().
Sets the keyDest in cls.
[in] | keyDest | see keydest_t |
Definition at line 815 of file cl_keys.cpp.
References cls, key_console, client_static_s::keyDest, and UI_ReleaseInput().
Referenced by Con_Close(), Con_ToggleChat_f(), Con_ToggleConsole_f(), UI_PopWindow(), and UI_PushWindow().
int Key_StringToKeynum | ( | const char * | str | ) |
Convert to given string to keynum.
[in] | str | The keystring to convert to keynum |
Definition at line 462 of file cl_keys.cpp.
References keyName_t::name, Q_strcasecmp, and Q_strnull().
Referenced by CL_PressKey_f(), Key_Bind_f(), and Key_Unbind_f().
Unbind a given key binding.
Definition at line 586 of file cl_keys.cpp.
References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Key_SetBinding(), Key_StringToKeynum(), KEYSPACE_BATTLE, KEYSPACE_GAME, KEYSPACE_UI, and Q_streq.
Referenced by Key_Init().
Unbind all key bindings.
Definition at line 611 of file cl_keys.cpp.
References Cmd_Argv(), i, K_FIRST_KEY, K_LAST_KEY, Key_SetBinding(), keyBindings, KEYSPACE_GAME, KEYSPACE_UI, and Q_streq.
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 664 of file cl_keys.cpp.
References battleKeyBindings, binding, Com_Printf(), uiKeyBinding_s::description, f, FILE_WRITE, FS_CloseFile(), FS_Gamedir(), FS_OpenFile(), FS_Printf(), FS_RemoveFile(), i, uiKeyBinding_s::inherited, K_LAST_KEY, uiKeyBinding_s::key, Key_KeynumToString(), keyBindings, menuKeyBindings, uiKeyBinding_s::node, uiKeyBinding_s::property, value_s::string, UI_GetKeyBindingByIndex(), UI_GetKeyBindingCount(), UI_GetPath(), and va().
Referenced by CL_Shutdown(), and Key_WriteBindings_f().
Definition at line 730 of file cl_keys.cpp.
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 65 of file cl_keys.cpp.
Referenced by CLMN_InitKeyList_f(), Key_Bindlist_f(), Key_Event(), Key_GetBinding(), Key_Init(), Key_SetBinding(), and Key_WriteBindings().
int editLine = 0 |
Definition at line 42 of file cl_keys.cpp.
Referenced by Con_DrawInput(), Con_LoadConsoleHistory(), Key_ClearTyping(), and Key_Console().
int historyLine = 0 |
Definition at line 43 of file cl_keys.cpp.
Referenced by Con_LoadConsoleHistory(), Con_SaveConsoleHistory(), and Key_Console().
char* keyBindings[K_KEY_SIZE] |
Definition at line 63 of file cl_keys.cpp.
Referenced by CLMN_InitKeyList_f(), Key_Bind_f(), Key_Bindlist_f(), Key_Event(), Key_GetBinding(), Key_Init(), Key_SetBinding(), Key_Unbindall_f(), and Key_WriteBindings().
|
static |
Definition at line 67 of file cl_keys.cpp.
Referenced by IN_EventEnqueue(), Key_Console(), Key_Event(), Key_Init(), and Key_IsDown().
|
static |
Definition at line 40 of file cl_keys.cpp.
Referenced by Key_Console().
uint32_t keyLinePos |
Definition at line 38 of file cl_keys.cpp.
Referenced by Con_DrawInput(), Key_ClearTyping(), Key_Console(), and Key_Init().
char keyLines[MAXKEYLINES][MAXCMDLINE] |
Definition at line 37 of file cl_keys.cpp.
Referenced by Con_DrawInput(), Con_LoadConsoleHistory(), Con_SaveConsoleHistory(), Key_ClearTyping(), Key_Console(), and Key_Init().
|
static |
Definition at line 75 of file cl_keys.cpp.
char* menuKeyBindings[K_KEY_SIZE] |
Definition at line 64 of file cl_keys.cpp.
Referenced by CLMN_InitKeyList_f(), Key_Bindlist_f(), Key_Event(), Key_GetBinding(), Key_Init(), Key_SetBinding(), and Key_WriteBindings().
char msgBuffer[MAXCMDLINE] |
Definition at line 46 of file cl_keys.cpp.
size_t msgBufferLen = 0 |
Definition at line 47 of file cl_keys.cpp.
int msgMode |
Definition at line 45 of file cl_keys.cpp.