本文整理汇总了C++中Key_SetBinding函数的典型用法代码示例。如果您正苦于以下问题:C++ Key_SetBinding函数的具体用法?C++ Key_SetBinding怎么用?C++ Key_SetBinding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Key_SetBinding函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Key_Unbindall_f
/**
* @brief Unbind all key bindings
* @sa Key_SetBinding
*/
static void Key_Unbindall_f (void)
{
int i;
for (i = K_FIRST_KEY; i < K_LAST_KEY; i++)
if (keyBindings[i]) {
if (Q_streq(Cmd_Argv(0), "unbindallmenu"))
Key_SetBinding(i, "", KEYSPACE_UI);
else
Key_SetBinding(i, "", KEYSPACE_GAME);
}
}
示例2: Key_Reset_f
/*
===================
Key_Reset_f
===================
*/
void Key_Reset_f( void )
{
int i;
keyname_t *kn;
// clear all keys first
for( i = 0; i < 256; i++ )
{
if( keys[i].binding )
Key_SetBinding( i, "" );
}
// apply default values
for( kn = keynames; kn->name; kn++ )
Key_SetBinding( kn->keynum, kn->binding );
}
示例3: UI_KeyBindingNodeKeyPressed
/**
* @brief Called when we press a key when the node got the focus
* @return True, if we use the event
*/
static qboolean UI_KeyBindingNodeKeyPressed (uiNode_t *node, unsigned int key, unsigned short unicode)
{
const char *command;
const char *binding;
UI_RemoveFocus();
/** @todo what about macro expansion? */
if (!Q_strstart(node->text, "*binding:"))
return qfalse;
command = node->text + 9;
/** @todo ensure that the binding for the key command is not executed */
binding = Key_GetBinding(command, EXTRADATA(node).keySpace);
if (binding[0] != '\0') {
/* if it's the same command, do not change anything, otherwise
* show the reason why nothing was changed */
if (!Q_streq(binding, command)) {
const char *keyStr = Key_KeynumToString(key);
UI_DisplayNotice(va(_("Key %s already bound"), keyStr), 2000, NULL);
}
return qfalse;
}
/* fire change event */
if (node->onChange)
UI_ExecuteEventActions(node, node->onChange);
Key_SetBinding(key, command, EXTRADATA(node).keySpace);
return qtrue;
}
示例4: Key_Unbindall_f
static void Key_Unbindall_f (void)
{
int i;
for (i = 0; i < 256; i++)
Key_SetBinding(i, NULL);
}
示例5: Key_Bind_f
/*
===================
Key_Bind_f
===================
*/
static void Key_Bind_f(void)
{
int c, b;
c = Cmd_Argc();
if (c < 2) {
Com_Printf("bind <key> [command] : attach a command to a key\n");
return;
}
b = Key_StringToKeynum(Cmd_Argv(1));
if (b == -1) {
Com_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(1));
return;
}
if (c == 2) {
if (keybindings[b])
Com_Printf("\"%s\" = \"%s\"\n", Cmd_Argv(1), keybindings[b]);
else
Com_Printf("\"%s\" is not bound\n", Cmd_Argv(1));
return;
}
// copy the rest of the command line
Key_SetBinding(b, Cmd_ArgsFrom(2));
}
示例6: Key_Unbindall_f
void Key_Unbindall_f (void)
{
int i;
for (i=0 ; i<256 ; i++)
if (keybindings[i])
Key_SetBinding (i, "");
}
示例7: Key_Unbindall
static void Key_Unbindall( void )
{
int i;
for( i = 0; i < 256; i++ )
{
if( keybindings[i] )
Key_SetBinding( i, NULL );
}
}
示例8: Key_Unbindall_f
/*
===================
Key_Unbindall_f
===================
*/
void Key_Unbindall_f( void )
{
int i;
for( i = 0; i < 256; i++ )
{
if( i != K_ESCAPE && keys[i].binding )
Key_SetBinding( i, "" );
}
}
示例9: Key_Bind_f
/**
* @brief Binds a key to a given script command
* @sa Key_SetBinding
*/
static void Key_Bind_f (void)
{
int i, c, b;
char cmd[1024];
c = Cmd_Argc();
if (c < 2) {
Com_Printf("Usage: %s <key> [command] : attach a command to a key\n", Cmd_Argv(0));
return;
}
b = Key_StringToKeynum(Cmd_Argv(1));
if (b == -1) {
Com_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(1));
return;
}
if (c == 2) {
if (keyBindings[b])
Com_Printf("\"%s\" = \"%s\"\n", Cmd_Argv(1), keyBindings[b]);
else
Com_Printf("\"%s\" is not bound\n", Cmd_Argv(1));
return;
}
/* copy the rest of the command line */
cmd[0] = '\0'; /* start out with a null string */
for (i = 2; i < c; i++) {
Q_strcat(cmd, Cmd_Argv(i), sizeof(cmd));
if (i != (c - 1))
Q_strcat(cmd, " ", sizeof(cmd));
}
if (Q_streq(Cmd_Argv(0), "bindui"))
UI_SetKeyBinding(cmd, b);
else if (Q_streq(Cmd_Argv(0), "bindmenu"))
Key_SetBinding(b, cmd, KEYSPACE_UI);
else if (Q_streq(Cmd_Argv(0), "bindbattle"))
Key_SetBinding(b, cmd, KEYSPACE_BATTLE);
else
Key_SetBinding(b, cmd, KEYSPACE_GAME);
}
示例10: Key_Unbindall_f
/*
===================
Key_Unbindall_f
===================
*/
void Key_Unbindall_f (void)
{
int i;
for ( i = 0 ; i < MAX_KEYS; i++ )
{
if ( keys[i].binding )
{
Key_SetBinding( i, "" );
}
}
}
示例11: Key_Unbindall_f
/**
* \brief Console callback method to unbind all key mapping
*/
PRIVATE void Key_Unbindall_f( void )
{
int i;
for( i = 0; i < 256; ++i )
{
if( keybindings[ i ] )
{
Key_SetBinding( i, "" );
}
}
}
示例12: Key_Unbind_f
/**
* @brief Unbind a given key binding
* @sa Key_SetBinding
*/
static void Key_Unbind_f (void)
{
int b;
if (Cmd_Argc() != 2) {
Com_Printf("Usage: %s <key> : remove commands from a key\n", Cmd_Argv(0));
return;
}
b = Key_StringToKeynum(Cmd_Argv(1));
if (b == -1) {
Com_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(1));
return;
}
if (Q_streq(Cmd_Argv(0), "unbindmenu"))
Key_SetBinding(b, "", KEYSPACE_UI);
else if (Q_streq(Cmd_Argv(0), "unbindbattle"))
Key_SetBinding(b, "", KEYSPACE_BATTLE);
else
Key_SetBinding(b, "", KEYSPACE_GAME);
}
示例13: Key_Init
/*
===================
Key_Init
===================
*/
void Key_Init( void )
{
keyname_t *kn;
// register our functions
Cmd_AddCommand( "bind", Key_Bind_f, "binds a command to the specified key in bindmap" );
Cmd_AddCommand( "unbind", Key_Unbind_f, "removes a command on the specified key in bindmap" );
Cmd_AddCommand( "unbindall", Key_Unbindall_f, "removes all commands from all keys in bindmap" );
Cmd_AddCommand( "resetkeys", Key_Reset_f, "reset all keys to their default values" );
Cmd_AddCommand( "bindlist", Key_Bindlist_f, "display current key bindings" );
Cmd_AddCommand( "makehelp", Key_EnumCmds_f, "write help.txt that contains all console cvars and cmds" );
// setup default binding. "unbindall" from config.cfg will reset it
for( kn = keynames; kn->name; kn++ ) Key_SetBinding( kn->keynum, kn->binding );
}
示例14: M_UnbindCommand
static void M_UnbindCommand (char *command)
{
int j;
int l;
char *b;
l = strlen(command);
for (j=0 ; j<MAX_KEYS ; j++)
{
b = keys[j].binding;
if (!b)
continue;
if (!strncmp (b, command, l) )
Key_SetBinding (j, "");
}
}
示例15: Key_Unbind_f
/*
===================
Key_Unbind_f
===================
*/
static void Key_Unbind_f(void)
{
int b;
if (Cmd_Argc() != 2) {
Com_Printf("unbind <key> : remove commands from a key\n");
return;
}
b = Key_StringToKeynum(Cmd_Argv(1));
if (b == -1) {
Com_Printf("\"%s\" isn't a valid key\n", Cmd_Argv(1));
return;
}
Key_SetBinding(b, NULL);
}