aboutsummaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
Diffstat (limited to 'code')
-rw-r--r--code/sdl/sdl_glimp.c25
-rw-r--r--code/sdl/sdl_input.c62
2 files changed, 52 insertions, 35 deletions
diff --git a/code/sdl/sdl_glimp.c b/code/sdl/sdl_glimp.c
index 21b41a9..f1df177 100644
--- a/code/sdl/sdl_glimp.c
+++ b/code/sdl/sdl_glimp.c
@@ -725,18 +725,16 @@ void GLimp_EndFrame( void )
if( r_fullscreen->modified )
{
qboolean fullscreen;
+ qboolean needToToggle = qtrue;
qboolean sdlToggled = qfalse;
SDL_Surface *s = SDL_GetVideoSurface( );
if( s )
{
// Find out the current state
- if( s->flags & SDL_FULLSCREEN )
- fullscreen = qtrue;
- else
- fullscreen = qfalse;
+ fullscreen = !!( s->flags & SDL_FULLSCREEN );
- if (r_fullscreen->integer && Cvar_VariableIntegerValue( "in_nograb" ))
+ if( r_fullscreen->integer && Cvar_VariableIntegerValue( "in_nograb" ) )
{
ri.Printf( PRINT_ALL, "Fullscreen not allowed with in_nograb 1\n");
ri.Cvar_Set( "r_fullscreen", "0" );
@@ -744,17 +742,20 @@ void GLimp_EndFrame( void )
}
// Is the state we want different from the current state?
- if( !!r_fullscreen->integer != fullscreen )
+ needToToggle = !!r_fullscreen->integer != fullscreen;
+
+ if( needToToggle )
sdlToggled = SDL_WM_ToggleFullScreen( s );
- else
- sdlToggled = qtrue;
}
- // SDL_WM_ToggleFullScreen didn't work, so do it the slow way
- if( !sdlToggled )
- Cbuf_AddText( "vid_restart" );
+ if( needToToggle )
+ {
+ // SDL_WM_ToggleFullScreen didn't work, so do it the slow way
+ if( !sdlToggled )
+ Cbuf_AddText( "vid_restart" );
- IN_Restart( );
+ IN_Restart( );
+ }
r_fullscreen->modified = qfalse;
}
diff --git a/code/sdl/sdl_input.c b/code/sdl/sdl_input.c
index de82d5d..358c16b 100644
--- a/code/sdl/sdl_input.c
+++ b/code/sdl/sdl_input.c
@@ -58,9 +58,9 @@ static qboolean mouseAvailable = qfalse;
static qboolean mouseActive = qfalse;
static qboolean keyRepeatEnabled = qfalse;
-static cvar_t *in_mouse;
+static cvar_t *in_mouse = NULL;
#ifdef MACOS_X_ACCELERATION_HACK
-static cvar_t *in_disablemacosxmouseaccel;
+static cvar_t *in_disablemacosxmouseaccel = NULL;
static double originalMouseSpeed = -1.0;
#endif
static cvar_t *in_nograb;
@@ -231,8 +231,7 @@ static const char *IN_TranslateSDLToQ3Key( SDL_keysym *keysym,
if( *key != K_DEL )
{
// ctrl-h
- *key = CTRL('h');
- *buf = *key;
+ *buf = CTRL('h');
break;
}
// fallthrough
@@ -393,7 +392,10 @@ static void IN_DeactivateMouse( void )
if( mouseActive )
{
SDL_WM_GrabInput( SDL_GRAB_OFF );
- SDL_WarpMouse( glConfig.vidWidth / 2, glConfig.vidHeight / 2 );
+
+ // Don't warp the mouse unless the cursor is within the window
+ if( SDL_GetAppState( ) & SDL_APPMOUSEFOCUS )
+ SDL_WarpMouse( glConfig.vidWidth / 2, glConfig.vidHeight / 2 );
mouseActive = qfalse;
}
@@ -782,19 +784,33 @@ static void IN_ProcessEvents( void )
IN_Frame
===============
*/
-void IN_Frame (void)
+void IN_Frame( void )
{
+ qboolean loading;
+
IN_JoyMove( );
+ IN_ProcessEvents( );
+
+ // If not DISCONNECTED (main menu) or ACTIVE (in game), we're loading
+ loading = !!( cls.state != CA_DISCONNECTED && cls.state != CA_ACTIVE );
- // Release the mouse if the console is down in windowed mode
- // or if the window loses focus due to task switching
- if( ( ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) && !r_fullscreen->integer ) ||
- !( SDL_GetAppState() & SDL_APPINPUTFOCUS ) )
+ if( !r_fullscreen->integer && ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) )
+ {
+ // Console is down in windowed mode
+ IN_DeactivateMouse( );
+ }
+ else if( !r_fullscreen->integer && loading )
+ {
+ // Loading in windowed mode
+ IN_DeactivateMouse( );
+ }
+ else if( !( SDL_GetAppState() & SDL_APPINPUTFOCUS ) )
+ {
+ // Window not got focus
IN_DeactivateMouse( );
+ }
else
IN_ActivateMouse( );
-
- IN_ProcessEvents( );
}
/*
@@ -802,7 +818,7 @@ void IN_Frame (void)
IN_Init
===============
*/
-void IN_Init(void)
+void IN_Init( void )
{
if( !SDL_WasInit( SDL_INIT_VIDEO ) )
{
@@ -810,24 +826,24 @@ void IN_Init(void)
return;
}
- Com_DPrintf ("\n------- Input Initialization -------\n");
+ Com_DPrintf( "\n------- Input Initialization -------\n" );
in_keyboardDebug = Cvar_Get( "in_keyboardDebug", "0", CVAR_ARCHIVE );
// mouse variables
- in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
- in_nograb = Cvar_Get ("in_nograb", "0", CVAR_ARCHIVE);
+ in_mouse = Cvar_Get( "in_mouse", "1", CVAR_ARCHIVE );
+ in_nograb = Cvar_Get( "in_nograb", "0", CVAR_ARCHIVE );
- in_joystick = Cvar_Get ("in_joystick", "0", CVAR_ARCHIVE|CVAR_LATCH);
- in_joystickDebug = Cvar_Get ("in_joystickDebug", "0", CVAR_TEMP);
- in_joystickThreshold = Cvar_Get ("in_joystickThreshold", "0.15", CVAR_ARCHIVE);
+ in_joystick = Cvar_Get( "in_joystick", "0", CVAR_ARCHIVE|CVAR_LATCH );
+ in_joystickDebug = Cvar_Get( "in_joystickDebug", "0", CVAR_TEMP );
+ in_joystickThreshold = Cvar_Get( "in_joystickThreshold", "0.15", CVAR_ARCHIVE );
#ifdef MACOS_X_ACCELERATION_HACK
- in_disablemacosxmouseaccel = Cvar_Get ("in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE);
+ in_disablemacosxmouseaccel = Cvar_Get( "in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE );
#endif
- SDL_EnableUNICODE(1);
- SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
+ SDL_EnableUNICODE( 1 );
+ SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL );
keyRepeatEnabled = qtrue;
if( in_mouse->value )
@@ -842,7 +858,7 @@ void IN_Init(void)
}
IN_InitJoystick( );
- Com_DPrintf ("------------------------------------\n");
+ Com_DPrintf( "------------------------------------\n" );
}
/*