aboutsummaryrefslogtreecommitdiffstats
path: root/code/sdl
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-08-25 21:15:25 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2008-08-25 21:15:25 +0000
commitfdcc20799fa3e59ac39466e980d38bee7794415c (patch)
treeb27ada1544938b5fadcda890879555ad7dcc93d3 /code/sdl
parentc13e838e2aa62268869ffba395ae1388c87806b9 (diff)
downloadioquake3-aero-fdcc20799fa3e59ac39466e980d38bee7794415c.tar.gz
ioquake3-aero-fdcc20799fa3e59ac39466e980d38bee7794415c.zip
* Handle dead keys more gracefully by taking a "best guess" rather than ignoring
completely * When activating or deactivating the mouse flush any pending motion events; this should stop the view moving unpredictably in these circumstances * Add keyname completion to "unbind" git-svn-id: svn://svn.icculus.org/quake3/trunk@1459 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/sdl')
-rw-r--r--code/sdl/sdl_input.c61
1 files changed, 46 insertions, 15 deletions
diff --git a/code/sdl/sdl_input.c b/code/sdl/sdl_input.c
index 358c16b..669088e 100644
--- a/code/sdl/sdl_input.c
+++ b/code/sdl/sdl_input.c
@@ -218,25 +218,37 @@ static const char *IN_TranslateSDLToQ3Key( SDL_keysym *keysym,
}
}
- if( down && !( keysym->unicode & 0xFF80 ) )
+ if( down )
{
- char ch = (char)keysym->unicode & 0x7F;
-
- switch( ch )
+ if( keysym->unicode && !( keysym->unicode & 0xFF80 ) )
{
- // So the key marked ~ always drops the console
- case '~': *key = '~'; break;
+ char ch = (char)keysym->unicode & 0x7F;
- case 127: // ASCII delete
- if( *key != K_DEL )
- {
- // ctrl-h
- *buf = CTRL('h');
- break;
- }
- // fallthrough
+ switch( ch )
+ {
+ // So the key marked ~ always drops the console
+ case '~': *key = '~'; break;
+
+ case 127: // ASCII delete
+ if( *key != K_DEL )
+ {
+ // ctrl-h
+ *buf = CTRL('h');
+ break;
+ }
+ // fallthrough
- default: *buf = ch; break;
+ default: *buf = ch; break;
+ }
+ }
+ else
+ {
+ // Unicode character which isn't ASCII, possibly the character
+ // following a dead key. Fallback on what SDL calls the key
+
+ const char *keyString = SDL_GetKeyName( keysym->sym );
+ if( strlen( keyString ) == 1 )
+ *buf = *keyString;
}
}
@@ -280,6 +292,21 @@ static io_connect_t IN_GetIOHandle(void) // mac os x mouse accel hack
/*
===============
+IN_GobbleMotionEvents
+===============
+*/
+static void IN_GobbleMotionEvents( void )
+{
+ SDL_Event dummy[ 1 ];
+
+ // Gobble any mouse motion events
+ SDL_PumpEvents( );
+ while( SDL_PeepEvents( dummy, 1, SDL_GETEVENT,
+ SDL_EVENTMASK( SDL_MOUSEMOTION ) ) ) { }
+}
+
+/*
+===============
IN_ActivateMouse
===============
*/
@@ -333,6 +360,8 @@ static void IN_ActivateMouse( void )
SDL_ShowCursor( 0 );
#endif
SDL_WM_GrabInput( SDL_GRAB_ON );
+
+ IN_GobbleMotionEvents( );
}
// in_nograb makes no sense in fullscreen mode
@@ -391,6 +420,8 @@ static void IN_DeactivateMouse( void )
if( mouseActive )
{
+ IN_GobbleMotionEvents( );
+
SDL_WM_GrabInput( SDL_GRAB_OFF );
// Don't warp the mouse unless the cursor is within the window