Another approach to fixing mouse grab/key_dest

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@770 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Sander van Dijk 2012-10-15 19:53:07 +00:00
parent 1fef74e006
commit 73aee2dd56
3 changed files with 44 additions and 1 deletions

View file

@ -686,6 +686,9 @@ void _Host_Frame (float time)
if (!Host_FilterTime (time))
return; // don't run too fast, or packets will flood out
// Force key_dest
Key_ForceDest ();
// get new key events
Sys_SendKeyEvents ();

View file

@ -1014,7 +1014,6 @@ void Key_Event (int key, qboolean down)
}
}
/*
===================
Key_ClearStates
@ -1031,3 +1030,43 @@ void Key_ClearStates (void)
}
}
/*
===================
Key_ForceDest
===================
*/
void Key_ForceDest (void)
{
static qboolean forced = false;
if (cls.state == ca_dedicated)
return;
switch (key_dest)
{
case key_console:
if (forced && cls.state == ca_connected)
{
forced = false;
IN_Activate();
key_dest = key_game;
}
return;
case key_game:
case key_message:
if (cls.state != ca_connected)
{
forced = true;
if (key_dest == key_message)
Key_Message(K_ESCAPE);
IN_Deactivate(vid.type == MODE_WINDOWED);
key_dest = key_console;
return;
}
/* fallthrough */
default:
forced = false;
break;
}
}

View file

@ -157,6 +157,7 @@ void Key_Init (void);
void Key_WriteBindings (FILE *f);
void Key_SetBinding (int keynum, const char *binding);
void Key_ClearStates (void);
void Key_ForceDest (void);
void History_Init (void);
void History_Shutdown (void);