diff options
Diffstat (limited to 'src/client/cl_keys.c')
-rw-r--r-- | src/client/cl_keys.c | 71 |
1 files changed, 50 insertions, 21 deletions
diff --git a/src/client/cl_keys.c b/src/client/cl_keys.c index ee075ce5..10abefc2 100644 --- a/src/client/cl_keys.c +++ b/src/client/cl_keys.c @@ -728,7 +728,6 @@ qboolean Key_IsDown( int keynum ) { return keys[keynum].down; } - /* =================== Key_StringToKeynum @@ -753,28 +752,12 @@ int Key_StringToKeynum( char *str ) { } // check for hex code - if ( str[0] == '0' && str[1] == 'x' && strlen( str ) == 4) { - int n1, n2; - - n1 = str[2]; - if ( n1 >= '0' && n1 <= '9' ) { - n1 -= '0'; - } else if ( n1 >= 'a' && n1 <= 'f' ) { - n1 = n1 - 'a' + 10; - } else { - n1 = 0; - } + if ( strlen( str ) == 4 ) { + int n = Com_HexStrToInt( str ); - n2 = str[3]; - if ( n2 >= '0' && n2 <= '9' ) { - n2 -= '0'; - } else if ( n2 >= 'a' && n2 <= 'f' ) { - n2 = n2 - 'a' + 10; - } else { - n2 = 0; + if ( n >= 0 ) { + return n; } - - return n1 * 16 + n2; } // scan for a text match @@ -1027,6 +1010,50 @@ void Key_KeynameCompletion( void(*callback)(const char *s) ) { } /* +==================== +Key_CompleteUnbind +==================== +*/ +static void Key_CompleteUnbind( char *args, int argNum ) +{ + if( argNum == 2 ) + { + // Skip "unbind " + char *p = Com_SkipTokens( args, 1, " " ); + + if( p > args ) + Field_CompleteKeyname( ); + } +} + +/* +==================== +Key_CompleteBind +==================== +*/ +static void Key_CompleteBind( char *args, int argNum ) +{ + char *p; + + if( argNum == 2 ) + { + // Skip "bind " + p = Com_SkipTokens( args, 1, " " ); + + if( p > args ) + Field_CompleteKeyname( ); + } + else if( argNum >= 3 ) + { + // Skip "bind <key> " + p = Com_SkipTokens( args, 2, " " ); + + if( p > args ) + Field_CompleteCommand( p, qtrue, qtrue ); + } +} + +/* =================== CL_InitKeyCommands =================== @@ -1034,7 +1061,9 @@ CL_InitKeyCommands void CL_InitKeyCommands( void ) { // register our functions Cmd_AddCommand ("bind",Key_Bind_f); + Cmd_SetCommandCompletionFunc( "bind", Key_CompleteBind ); Cmd_AddCommand ("unbind",Key_Unbind_f); + Cmd_SetCommandCompletionFunc( "unbind", Key_CompleteUnbind ); Cmd_AddCommand ("unbindall",Key_Unbindall_f); Cmd_AddCommand ("bindlist",Key_Bindlist_f); } |