Index: trunk/src/client/cl_keys.c =================================================================== --- trunk/src/client/cl_keys.c (revision 755) +++ trunk/src/client/cl_keys.c (working copy) @@ -978,58 +978,16 @@ /* =================== -CL_AddKeyUpCommands -=================== -*/ -void CL_AddKeyUpCommands( int key, char *kb ) { - int i; - char button[1024], *buttonPtr; - char cmd[1024]; - qboolean keyevent; - - if ( !kb ) { - return; - } - keyevent = qfalse; - buttonPtr = button; - for ( i = 0; ; i++ ) { - if ( kb[i] == ';' || !kb[i] ) { - *buttonPtr = '\0'; - if ( button[0] == '+') { - // button commands add keynum and time as parms so that multiple - // sources can be discriminated and subframe corrected - Com_sprintf (cmd, sizeof(cmd), "-%s %i %i\n", button+1, key, time); - Cbuf_AddText (cmd); - keyevent = qtrue; - } else { - if (keyevent) { - // down-only command - Cbuf_AddText (button); - Cbuf_AddText ("\n"); - } - } - buttonPtr = button; - while ( (kb[i] <= ' ' || kb[i] == ';') && kb[i] != 0 ) { - i++; - } - } - *buttonPtr++ = kb[i]; - if ( !kb[i] ) { - break; - } - } -} - -/* -=================== CL_KeyEvent Called by the system for both key up and key down events =================== */ void CL_KeyEvent (int key, qboolean down, unsigned time) { - char *kb; - char cmd[1024]; + int i; + char *kb; + char cmd[1024]; + char button[1024], *buttonPtr; // update auto-repeat status and BUTTON_ANY status keys[key].down = down; @@ -1071,7 +1029,7 @@ if (!down) { return; } - Con_ToggleConsole_f (); + Con_ToggleConsole_f (); return; } @@ -1117,17 +1075,38 @@ return; } + kb = keys[key].binding; + // // key up events only perform actions if the game key binding is // a button command (leading + sign). These will be processed even in // console mode and menu mode, to keep the character from continuing // an action started before a mode switch. // - if (!down) { - kb = keys[key].binding; + if ( !down ) { + if( kb && kb[0] ) { + buttonPtr = button; + for ( i = 0; ; i++ ) { + if ( kb[i] == ';' || !kb[i] ) { + *buttonPtr = '\0'; + if ( button[0] == '+') { + // button commands add keynum and time as parms so that multiple + // sources can be discriminated and subframe corrected + Com_sprintf (cmd, sizeof(cmd), "-%s %i %i\n", button+1, key, time); + Cbuf_AddText (cmd); + } + buttonPtr = button; + while ( (kb[i] <= ' ' || kb[i] == ';') && kb[i] ) { + i++; + } + } + *buttonPtr++ = kb[i]; + if ( !kb[i] ) { + break; + } + } + } - CL_AddKeyUpCommands( key, kb ); - if ( cls.keyCatchers & KEYCATCH_UI && uivm ) { VM_Call( uivm, UI_KEY_EVENT, key, down ); } else if ( cls.keyCatchers & KEYCATCH_CGAME && cgvm ) { @@ -1155,15 +1134,7 @@ Console_Key( key ); } else { // send the bound action - kb = keys[key].binding; - if ( !kb ) { - if (key >= 200) { - Com_Printf ("%s is unbound, use controls menu to set.\n" - , Key_KeynumToString( key ) ); - } - } else if (kb[0] == '+') { - int i; - char button[1024], *buttonPtr; + if( kb && kb[0] ) { buttonPtr = button; for ( i = 0; ; i++ ) { if ( kb[i] == ';' || !kb[i] ) { @@ -1179,7 +1150,7 @@ Cbuf_AddText ("\n"); } buttonPtr = button; - while ( (kb[i] <= ' ' || kb[i] == ';') && kb[i] != 0 ) { + while ( (kb[i] <= ' ' || kb[i] == ';') && kb[i] ) { i++; } } @@ -1188,10 +1159,6 @@ break; } } - } else { - // down-only command - Cbuf_AddText (kb); - Cbuf_AddText ("\n"); } } }