31 #include "../client.h"
32 #include "../cl_console.h"
33 #include "../ui/ui_input.h"
34 #include "../ui/ui_nodes.h"
35 #include "../../shared/utf8.h"
74 #define M(x) {#x, K_##x}
223 return (SDL_GetModState() & KMOD_NUM) == KMOD_NUM;
239 switch (toupper(key)) {
433 if (key < 32 || key > 127)
488 return "<KEY NOT FOUND>";
490 if (keynum > 32 && keynum < 127) {
491 static char tinystr[2];
498 if (keynum == kn->keynum)
501 return "<UNKNOWN KEYNUM>";
513 char** keySpace =
nullptr;
526 Sys_Error(
"Unknown key space (%i) given", space);
530 if (keySpace[
i] && *keySpace[
i] &&
Q_streq(keySpace[
i], binding)) {
549 char** keySpace =
nullptr;
666 bool writeError =
false;
676 FS_Printf(&f,
"// generated by ufo, do not modify\n");
677 FS_Printf(&f,
"// If you want to know the keyname of a specific key - set in_debug cvar to 1 and press the key\n");
688 for (
int i = 0; i <
K_LAST_KEY && !writeError; i++)
694 for (
int i = 0; i <
K_LAST_KEY && !writeError; i++)
705 if (binding->
node ==
nullptr)
719 if (!writeError && cnt > 0) {
821 #if SDL_VERSION_ATLEAST(2,0,0)
822 SDL_StartTextInput();
825 #if SDL_VERSION_ATLEAST(2,0,0)
883 for (
int i = 0;
i < 3;
i++) {
884 if (kb && kb[0] ==
'+') {
905 const char* kb =
nullptr;
910 if (!kb && unicode >= 32 && unicode < 127)
bool Q_strnull(const char *string)
const char * Cmd_Argv(int arg)
Returns a given argument.
static void Key_Bindlist_f(void)
List all binded keys with its function.
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
void Sys_Error(const char *error,...)
static void Key_Bind_f(void)
Binds a key to a given script command.
int FS_OpenFile(const char *filename, qFILE *file, filemode_t mode)
Finds and opens the file in the search path.
bool CL_OnBattlescape(void)
Check whether we are in a tactical mission as server or as client. But this only means that we are ab...
char * menuKeyBindings[K_KEY_SIZE]
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
static void Key_Unbindall_f(void)
Unbind all key bindings.
void Cbuf_AddText(const char *format,...)
Adds command text at the end of the buffer.
const struct value_s * property
void FS_RemoveFile(const char *osPath)
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.
void Com_Printf(const char *const fmt,...)
bool Cmd_GenericCompleteFunction(char const *candidate, char const *partial, char const **match)
static void Key_WriteBindings_f(void)
const char * Key_GetBinding(const char *binding, keyBindSpace_t space)
Return the key binding for a given script command.
void Com_Error(int code, const char *fmt,...)
void Key_SetDest(keydest_t keyDest)
Sets the keyDest in cls.
const char * FS_Gamedir(void)
Called to find where to write a file (savegames, etc)
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
#define CONSOLE_PROMPT_CHAR
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
void Con_Scroll(int scroll)
Scrolls the console.
memPool_t * com_genericPool
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
static bool keyDown[K_KEY_SIZE]
int FS_Printf(qFILE *f, const char *msg,...)
Can print chunks for 1024 chars into a file.
void FS_CloseFile(qFILE *f)
char keyLines[MAXKEYLINES][MAXCMDLINE]
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
#define Q_strcasecmp(a, b)
static void Key_Unbind_f(void)
Unbind a given key binding.
static int Key_CompleteKeyName(const char *partial, const char **match)
static const keyName_t keyNames[]
bool Key_IsDown(unsigned int key)
Checks whether a given key is currently pressed.
void Com_DefaultExtension(char *path, size_t len, const char *extension)
Sets a default extension if there is none.
bool Com_ConsoleCompleteCommand(const char *s, char *target, size_t bufSize, uint32_t *pos, uint32_t offset)
Console completion for command and variables.
static bool Key_IsMouseButton(unsigned int key)
Returns true if the Key is a mouse event.
char msgBuffer[MAXCMDLINE]
void Cmd_AddParamCompleteFunction(const char *cmdName, int(*function)(const char *partial, const char **match))
char * keyBindings[K_KEY_SIZE]
const uiKeyBinding_t * binding
#define Mem_PoolStrDup(in, pool, tagNum)
const char * Key_KeynumToString(int keynum)
Convert a given keynum to string.
void Con_ToggleConsole_f(void)
void Key_SetBinding(int keynum, const char *binding, keyBindSpace_t space)
Bind a keynum to script command.
int Key_StringToKeynum(const char *str)
Convert to given string to keynum.
char * battleKeyBindings[K_KEY_SIZE]
static void Key_Console(int key, int unicode)
Interactive line editing and console scrollback.
void Key_WriteBindings(const char *filename)
Writes lines containing "bind key value".