From 0492f22ca68a7799fd2334a68c86ef467598ab4d Mon Sep 17 00:00:00 2001 From: Richard Allen Date: Wed, 18 May 2011 02:24:02 +0000 Subject: [PATCH] IOQ3 commit 1942 --- reaction/code/client/cl_keys.c | 7 ++++++- reaction/code/sdl/sdl_input.c | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/reaction/code/client/cl_keys.c b/reaction/code/client/cl_keys.c index 6afcd831..d9bd1364 100644 --- a/reaction/code/client/cl_keys.c +++ b/reaction/code/client/cl_keys.c @@ -1175,7 +1175,7 @@ void CL_KeyDownEvent( int key, unsigned time ) { keys[key].down = qtrue; keys[key].repeats++; - if( keys[key].repeats == 1 ) + if( keys[key].repeats == 1 && key != K_SCROLLOCK && key != K_KP_NUMLOCK && key != K_CAPSLOCK ) anykeydown++; if( keys[K_ALT].down && key == K_ENTER ) @@ -1268,7 +1268,9 @@ void CL_KeyUpEvent( int key, unsigned time ) { keys[key].repeats = 0; keys[key].down = qfalse; + if (key != K_SCROLLOCK && key != K_KP_NUMLOCK && key != K_CAPSLOCK) anykeydown--; + if (anykeydown < 0) { anykeydown = 0; } @@ -1353,6 +1355,9 @@ void Key_ClearStates (void) anykeydown = 0; for ( i=0 ; i < MAX_KEYS ; i++ ) { + if (i == K_SCROLLOCK || i == K_KP_NUMLOCK || i == K_CAPSLOCK) + continue; + if ( keys[i].down ) { CL_KeyEvent( i, qfalse, 0 ); diff --git a/reaction/code/sdl/sdl_input.c b/reaction/code/sdl/sdl_input.c index 097177da..d0b69d58 100644 --- a/reaction/code/sdl/sdl_input.c +++ b/reaction/code/sdl/sdl_input.c @@ -971,6 +971,20 @@ void IN_Frame( void ) } } +/* +=============== +IN_InitKeyLockStates +=============== +*/ +void IN_InitKeyLockStates( void ) +{ + unsigned char *keystate = SDL_GetKeyState(NULL); + + keys[K_SCROLLOCK].down = keystate[SDLK_SCROLLOCK]; + keys[K_KP_NUMLOCK].down = keystate[SDLK_NUMLOCK]; + keys[K_CAPSLOCK].down = keystate[SDLK_CAPSLOCK]; +} + /* =============== IN_Init @@ -1021,6 +1035,8 @@ void IN_Init( void ) Cvar_SetValue( "com_unfocused", !( appState & SDL_APPINPUTFOCUS ) ); Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) ); + IN_InitKeyLockStates( ); + IN_InitJoystick( ); Com_DPrintf( "------------------------------------\n" ); }