aboutsummaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-08-30 19:29:34 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-08-30 19:29:34 +0000
commit9a4940ab28d892ac0b1e4d5a4a4fbf9ed9ab26e1 (patch)
tree1df315480ad7422f76e83d4ea56e02d1c189d59c /code
parentb5282704799c72e7c049891f6921118ef26a48b3 (diff)
downloadioquake3-aero-9a4940ab28d892ac0b1e4d5a4a4fbf9ed9ab26e1.tar.gz
ioquake3-aero-9a4940ab28d892ac0b1e4d5a4a4fbf9ed9ab26e1.zip
* Update IN_IsConsoleKey so that specifying ascii values/characters for the
console key always results in the character being used as opposed to the key git-svn-id: svn://svn.icculus.org/quake3/trunk@1464 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code')
-rw-r--r--code/sdl/sdl_input.c62
1 files changed, 52 insertions, 10 deletions
diff --git a/code/sdl/sdl_input.c b/code/sdl/sdl_input.c
index f6c58eb..b2fb981 100644
--- a/code/sdl/sdl_input.c
+++ b/code/sdl/sdl_input.c
@@ -120,9 +120,24 @@ static void IN_PrintKey( const SDL_keysym *keysym, keyNum_t key, qboolean down )
IN_IsConsoleKey
===============
*/
-static qboolean IN_IsConsoleKey( keyNum_t key, const char *buf )
+static qboolean IN_IsConsoleKey( keyNum_t key, const char character )
{
- static int consoleKeys[ MAX_CONSOLE_KEYS ];
+ typedef struct consoleKey_s
+ {
+ enum
+ {
+ KEY,
+ CHARACTER
+ } type;
+
+ union
+ {
+ keyNum_t key;
+ char character;
+ } u;
+ } consoleKey_t;
+
+ static consoleKey_t consoleKeys[ MAX_CONSOLE_KEYS ];
static int numConsoleKeys = 0;
int i;
@@ -137,26 +152,53 @@ static qboolean IN_IsConsoleKey( keyNum_t key, const char *buf )
while( numConsoleKeys < MAX_CONSOLE_KEYS )
{
+ consoleKey_t *c = &consoleKeys[ numConsoleKeys ];
+ char *keyName;
+
token = COM_Parse( &text_p );
if( !token[ 0 ] )
break;
- consoleKeys[ numConsoleKeys++ ] =
- Key_StringToKeynum( token );
+ c->u.key = Key_StringToKeynum( token );
+
+ // 0 isn't a key
+ if( c->u.key == 0 )
+ continue;
+
+ keyName = Key_KeynumToString( c->u.key );
+
+ if( strlen( keyName ) == 1 )
+ {
+ c->type = CHARACTER;
+ c->u.character = *keyName;
+ }
+ else
+ c->type = KEY;
+
+ numConsoleKeys++;
}
}
// Use the character in preference to the key name
- if( *buf )
+ if( character != '\0' )
key = 0;
for( i = 0; i < numConsoleKeys; i++ )
{
- if( !consoleKeys[ i ] )
- continue;
+ consoleKey_t *c = &consoleKeys[ i ];
- if( consoleKeys[ i ] == key || consoleKeys[ i ] == *buf )
- return qtrue;
+ switch( c->type )
+ {
+ case KEY:
+ if( key && c->u.key == key )
+ return qtrue;
+ break;
+
+ case CHARACTER:
+ if( c->u.character == character )
+ return qtrue;
+ break;
+ }
}
return qfalse;
@@ -291,7 +333,7 @@ static const char *IN_TranslateSDLToQ3Key( SDL_keysym *keysym,
if( in_keyboardDebug->integer )
IN_PrintKey( keysym, *key, down );
- if( IN_IsConsoleKey( *key, buf ) )
+ if( IN_IsConsoleKey( *key, *buf ) )
{
// Console keys can't be bound or generate characters
*key = K_CONSOLE;