aboutsummaryrefslogtreecommitdiffstats
path: root/code/client/cl_keys.c
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2007-10-02 14:14:45 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2007-10-02 14:14:45 +0000
commit6bf8f279665d5d006159fb9fc180984c644ed875 (patch)
tree89d03c71398ee4e20b2b9b08bbe4f565074a904f /code/client/cl_keys.c
parent89f707ad9cefdebda05d6f019f584be159f740a7 (diff)
downloadioquake3-aero-6bf8f279665d5d006159fb9fc180984c644ed875.tar.gz
ioquake3-aero-6bf8f279665d5d006159fb9fc180984c644ed875.zip
* Fix bug that prevented key up events getting to cgame/ui when not in game
* Use Key_[GS]etCatcher everywhere to set keycatcher * Clear all key states when the catcher changes git-svn-id: svn://svn.icculus.org/quake3/trunk@1189 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/client/cl_keys.c')
-rw-r--r--code/client/cl_keys.c63
1 files changed, 44 insertions, 19 deletions
diff --git a/code/client/cl_keys.c b/code/client/cl_keys.c
index 8991d0e..0f481a3 100644
--- a/code/client/cl_keys.c
+++ b/code/client/cl_keys.c
@@ -720,7 +720,7 @@ void Message_Key( int key ) {
if (key == K_ESCAPE) {
- cls.keyCatchers &= ~KEYCATCH_MESSAGE;
+ Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_MESSAGE );
Field_Clear( &chatField );
return;
}
@@ -742,7 +742,7 @@ void Message_Key( int key ) {
CL_AddReliableCommand( buffer );
}
- cls.keyCatchers &= ~KEYCATCH_MESSAGE;
+ Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_MESSAGE );
Field_Clear( &chatField );
return;
}
@@ -1173,7 +1173,8 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
// keys can still be used for bound actions
- if ( down && ( key < 128 || key == K_MOUSE1 ) && ( clc.demoplaying || cls.state == CA_CINEMATIC ) && !cls.keyCatchers) {
+ if ( down && ( key < 128 || key == K_MOUSE1 ) &&
+ ( clc.demoplaying || cls.state == CA_CINEMATIC ) && Key_GetCatcher( ) == 0 ) {
if (Cvar_VariableValue ("com_cameraMode") == 0) {
Cvar_Set ("nextdemo","");
@@ -1184,20 +1185,20 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
// escape is always handled special
if ( key == K_ESCAPE && down ) {
- if ( cls.keyCatchers & KEYCATCH_MESSAGE ) {
+ if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE ) {
// clear message mode
Message_Key( key );
return;
}
// escape always gets out of CGAME stuff
- if (cls.keyCatchers & KEYCATCH_CGAME) {
- cls.keyCatchers &= ~KEYCATCH_CGAME;
+ if (Key_GetCatcher( ) & KEYCATCH_CGAME) {
+ Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_CGAME );
VM_Call (cgvm, CG_EVENT_HANDLING, CGAME_EVENT_NONE);
return;
}
- if ( !( cls.keyCatchers & KEYCATCH_UI ) ) {
+ if ( !( Key_GetCatcher( ) & KEYCATCH_UI ) ) {
if ( cls.state == CA_ACTIVE && !clc.demoplaying ) {
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_INGAME );
}
@@ -1224,12 +1225,12 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
kb = keys[key].binding;
CL_AddKeyUpCommands( key, kb, time );
+ }
- if ( cls.keyCatchers & KEYCATCH_UI && uivm ) {
- VM_Call( uivm, UI_KEY_EVENT, key, down );
- } else if ( cls.keyCatchers & KEYCATCH_CGAME && cgvm ) {
- VM_Call( cgvm, CG_KEY_EVENT, key, down );
- }
+ if ( Key_GetCatcher( ) & KEYCATCH_UI && uivm ) {
+ VM_Call( uivm, UI_KEY_EVENT, key, down );
+ } else if ( Key_GetCatcher( ) & KEYCATCH_CGAME && cgvm ) {
+ VM_Call( cgvm, CG_KEY_EVENT, key, down );
}
return;
@@ -1237,17 +1238,17 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
// distribute the key down event to the apropriate handler
- if ( cls.keyCatchers & KEYCATCH_CONSOLE ) {
+ if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) {
Console_Key( key );
- } else if ( cls.keyCatchers & KEYCATCH_UI ) {
+ } else if ( Key_GetCatcher( ) & KEYCATCH_UI ) {
if ( uivm ) {
VM_Call( uivm, UI_KEY_EVENT, key, down );
}
- } else if ( cls.keyCatchers & KEYCATCH_CGAME ) {
+ } else if ( Key_GetCatcher( ) & KEYCATCH_CGAME ) {
if ( cgvm ) {
VM_Call( cgvm, CG_KEY_EVENT, key, down );
}
- } else if ( cls.keyCatchers & KEYCATCH_MESSAGE ) {
+ } else if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE ) {
Message_Key( key );
} else if ( cls.state == CA_DISCONNECTED ) {
Console_Key( key );
@@ -1315,15 +1316,15 @@ void CL_CharEvent( int key ) {
}
// distribute the key down event to the apropriate handler
- if ( cls.keyCatchers & KEYCATCH_CONSOLE )
+ if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE )
{
Field_CharEvent( &g_consoleField, key );
}
- else if ( cls.keyCatchers & KEYCATCH_UI )
+ else if ( Key_GetCatcher( ) & KEYCATCH_UI )
{
VM_Call( uivm, UI_KEY_EVENT, key | K_CHAR_FLAG, qtrue );
}
- else if ( cls.keyCatchers & KEYCATCH_MESSAGE )
+ else if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE )
{
Field_CharEvent( &chatField, key );
}
@@ -1355,6 +1356,30 @@ void Key_ClearStates (void)
}
}
+static int keyCatchers = 0;
+
+/*
+====================
+Key_GetCatcher
+====================
+*/
+int Key_GetCatcher( void ) {
+ return keyCatchers;
+}
+
+/*
+====================
+Key_SetCatcher
+====================
+*/
+void Key_SetCatcher( int catcher ) {
+ // If the catcher state is changing, clear all key states
+ if( catcher != keyCatchers )
+ Key_ClearStates( );
+
+ keyCatchers = catcher;
+}
+
// This must not exceed MAX_CMD_LINE
#define MAX_CONSOLE_SAVE_BUFFER 1024
#define CONSOLE_HISTORY_FILE "q3history"