r1157 - in branches/unified-sdl/code: client qcommon sdl sys

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Sep 5 10:28:06 EDT 2007


Author: tma
Date: 2007-09-05 10:28:06 -0400 (Wed, 05 Sep 2007)
New Revision: 1157

Modified:
   branches/unified-sdl/code/client/cl_main.c
   branches/unified-sdl/code/client/snd_main.c
   branches/unified-sdl/code/qcommon/common.c
   branches/unified-sdl/code/qcommon/cvar.c
   branches/unified-sdl/code/qcommon/qcommon.h
   branches/unified-sdl/code/sdl/sdl_gamma.c
   branches/unified-sdl/code/sdl/sdl_glimp.c
   branches/unified-sdl/code/sdl/sdl_input.c
   branches/unified-sdl/code/sys/sys_main.c
   branches/unified-sdl/code/sys/sys_unix.c
   branches/unified-sdl/code/sys/sys_win32.c
Log:
* Make in_nograb behave more consistently
* Stop assuming that the video card supports gamma
* Fix gamma problems on Windows
* com_minimized and com_unfocused to indicate app state
* s_muteWhenMinimized; mute sound when minimized
* When examining cvars...
  + Don't print the default value with CVAR_ROM
  + Don't print the default if it matches current value
* Add Sys_Basename
* s/dirname/Sys_Dirname/ s/basename/Sys_Basename/


Modified: branches/unified-sdl/code/client/cl_main.c
===================================================================
--- branches/unified-sdl/code/client/cl_main.c	2007-09-05 03:23:19 UTC (rev 1156)
+++ branches/unified-sdl/code/client/cl_main.c	2007-09-05 14:28:06 UTC (rev 1157)
@@ -914,7 +914,7 @@
 	}
 
 	if ( clc.demoplaying || cls.state < CA_CONNECTED || cmd[0] == '+' ) {
-		Com_Printf ("Unknown command \"%s^7\"\n", cmd);
+		Com_Printf ("Unknown command \"%s" S_COLOR_WHITE "\"\n", cmd);
 		return;
 	}
 

Modified: branches/unified-sdl/code/client/snd_main.c
===================================================================
--- branches/unified-sdl/code/client/snd_main.c	2007-09-05 03:23:19 UTC (rev 1156)
+++ branches/unified-sdl/code/client/snd_main.c	2007-09-05 14:28:06 UTC (rev 1157)
@@ -30,6 +30,7 @@
 cvar_t *s_musicVolume;
 cvar_t *s_doppler;
 cvar_t *s_backend;
+cvar_t *s_muteWhenMinimized;
 
 static soundInterface_t si;
 
@@ -219,6 +220,11 @@
 */
 void S_Update( void )
 {
+	if( s_muteWhenMinimized->integer && com_minimized->integer ) {
+		S_StopAllSounds( );
+		return;
+	}
+
 	if( si.Update ) {
 		si.Update( );
 	}
@@ -372,6 +378,7 @@
 	s_musicVolume = Cvar_Get( "s_musicvolume", "0.25", CVAR_ARCHIVE );
 	s_doppler = Cvar_Get( "s_doppler", "1", CVAR_ARCHIVE );
 	s_backend = Cvar_Get( "s_backend", "", CVAR_ROM );
+	s_muteWhenMinimized = Cvar_Get( "s_muteWhenMinimized", "0", CVAR_ARCHIVE );
 
 	cv = Cvar_Get( "s_initsound", "1", 0 );
 	if( !cv->integer ) {

Modified: branches/unified-sdl/code/qcommon/common.c
===================================================================
--- branches/unified-sdl/code/qcommon/common.c	2007-09-05 03:23:19 UTC (rev 1156)
+++ branches/unified-sdl/code/qcommon/common.c	2007-09-05 14:28:06 UTC (rev 1157)
@@ -80,6 +80,8 @@
 cvar_t  *sv_packetdelay;
 cvar_t	*com_cameraMode;
 cvar_t	*com_ansiColor;
+cvar_t	*com_unfocused;
+cvar_t	*com_minimized;
 
 // com_speeds times
 int		time_game;
@@ -2460,6 +2462,9 @@
 	com_buildScript = Cvar_Get( "com_buildScript", "0", 0 );
 	com_ansiColor = Cvar_Get( "com_ansiColor", "0", CVAR_ARCHIVE );
 
+	com_unfocused = Cvar_Get( "com_unfocused", "0", CVAR_ROM );
+	com_minimized = Cvar_Get( "com_minimized", "0", CVAR_ROM );
+
 	com_introPlayed = Cvar_Get( "com_introplayed", "0", CVAR_ARCHIVE);
 
 	if ( com_developer && com_developer->integer ) {

Modified: branches/unified-sdl/code/qcommon/cvar.c
===================================================================
--- branches/unified-sdl/code/qcommon/cvar.c	2007-09-05 03:23:19 UTC (rev 1156)
+++ branches/unified-sdl/code/qcommon/cvar.c	2007-09-05 14:28:06 UTC (rev 1157)
@@ -511,8 +511,20 @@
 	if ( Cmd_Argc() == 1 ) {
 		Com_TruncateLongString( string, v->string );
 		Com_TruncateLongString( resetString, v->resetString );
-		Com_Printf ("\"%s\" is:\"%s" S_COLOR_WHITE "\" default:\"%s" S_COLOR_WHITE "\"\n",
-				v->name, string, resetString );
+		Com_Printf ("\"%s\" is:\"%s" S_COLOR_WHITE "\"",
+				v->name, string );
+
+		if ( !( v->flags & CVAR_ROM ) ) {
+			if ( !Q_stricmp( string, resetString ) ) {
+				Com_Printf (", the default" );
+			} else {
+				Com_Printf (" default:\"%s" S_COLOR_WHITE "\"",
+						resetString );
+			}
+		}
+
+		Com_Printf ("\n");
+
 		if ( v->latchedString ) {
 			Com_TruncateLongString( latchedString, v->latchedString );
 			Com_Printf( "latched: \"%s\"\n", latchedString );

Modified: branches/unified-sdl/code/qcommon/qcommon.h
===================================================================
--- branches/unified-sdl/code/qcommon/qcommon.h	2007-09-05 03:23:19 UTC (rev 1156)
+++ branches/unified-sdl/code/qcommon/qcommon.h	2007-09-05 14:28:06 UTC (rev 1157)
@@ -752,6 +752,8 @@
 extern	cvar_t	*com_journal;
 extern	cvar_t	*com_cameraMode;
 extern	cvar_t	*com_ansiColor;
+extern	cvar_t	*com_unfocused;
+extern	cvar_t	*com_minimized;
 extern	cvar_t	*com_altivec;
 
 // both client and server must agree to pause
@@ -1019,6 +1021,7 @@
 void  Sys_SetDefaultHomePath(const char *path);
 char	*Sys_DefaultHomePath(void);
 const char *Sys_Dirname( char *path );
+const char *Sys_Basename( char *path );
 
 char **Sys_ListFiles( const char *directory, const char *extension, char *filter, int *numfiles, qboolean wantsubs );
 void	Sys_FreeFileList( char **list );

Modified: branches/unified-sdl/code/sdl/sdl_gamma.c
===================================================================
--- branches/unified-sdl/code/sdl/sdl_gamma.c	2007-09-05 03:23:19 UTC (rev 1156)
+++ branches/unified-sdl/code/sdl/sdl_gamma.c	2007-09-05 14:28:06 UTC (rev 1157)
@@ -34,7 +34,7 @@
 	Uint16 table[3][256];
 	int i, j;
 
-	if(r_ignorehwgamma->integer)
+	if( !glConfig.deviceSupportsGamma || r_ignorehwgamma->integer )
 		return;
 
 	for (i = 0; i < 256; i++)
@@ -44,6 +44,31 @@
 		table[2][i] = ( ( ( Uint16 ) blue[i] ) << 8 ) | blue[i];
 	}
 
+#ifdef _WIN32
+#include <windows.h>
+
+	// Win2K and newer put this odd restriction on gamma ramps...
+	OSVERSIONINFO	vinfo;
+
+	vinfo.dwOSVersionInfoSize = sizeof( vinfo );
+	GetVersionEx( &vinfo );
+	if( vinfo.dwMajorVersion >= 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT )
+	{
+		Com_DPrintf( "performing gamma clamp.\n" );
+		for( j = 0 ; j < 3 ; j++ )
+		{
+			for( i = 0 ; i < 128 ; i++ )
+			{
+				if( table[ j ] [ i] > ( ( 128 + i ) << 8 ) )
+					table[ j ][ i ] = ( 128 + i ) << 8;
+			}
+
+			if( table[ j ] [127 ] > 254 << 8 )
+				table[ j ][ 127 ] = 254 << 8;
+		}
+	}
+#endif
+
 	// enforce constantly increasing
 	for (j = 0; j < 3; j++)
 	{

Modified: branches/unified-sdl/code/sdl/sdl_glimp.c
===================================================================
--- branches/unified-sdl/code/sdl/sdl_glimp.c	2007-09-05 03:23:19 UTC (rev 1156)
+++ branches/unified-sdl/code/sdl/sdl_glimp.c	2007-09-05 14:28:06 UTC (rev 1157)
@@ -35,12 +35,6 @@
 #include "../sys/sys_local.h"
 #include "sdl_icon.h"
 
-void ( APIENTRY * qglMultiTexCoord2fARB )( GLenum texture, GLfloat s, GLfloat t );
-void ( APIENTRY * qglActiveTextureARB )( GLenum texture );
-void ( APIENTRY * qglClientActiveTextureARB )( GLenum texture );
-void ( APIENTRY * qglLockArraysEXT)( GLint, GLint);
-void ( APIENTRY * qglUnlockArraysEXT) ( void );
-
 /* Just hack it for now. */
 #ifdef MACOS_X
 typedef CGLContextObj QGLContext;
@@ -68,6 +62,13 @@
 
 cvar_t *r_allowSoftwareGL; // Don't abort out if a hardware visual can't be obtained
 
+void ( APIENTRY * qglMultiTexCoord2fARB )( GLenum texture, GLfloat s, GLfloat t );
+void ( APIENTRY * qglActiveTextureARB )( GLenum texture );
+void ( APIENTRY * qglClientActiveTextureARB )( GLenum texture );
+
+void ( APIENTRY * qglLockArraysEXT)( GLint, GLint);
+void ( APIENTRY * qglUnlockArraysEXT) ( void );
+
 /*
 ===============
 GLimp_Shutdown
@@ -493,7 +494,7 @@
 	// This values force the UI to disable driver selection
 	glConfig.driverType = GLDRV_ICD;
 	glConfig.hardwareType = GLHW_GENERIC;
-	glConfig.deviceSupportsGamma = qtrue;
+	glConfig.deviceSupportsGamma = !!( SDL_SetGamma( 1.0f, 1.0f, 1.0f ) >= 0 );
 
 	// get our config strings
 	Q_strncpyz( glConfig.vendor_string, (char *) qglGetString (GL_VENDOR), sizeof( glConfig.vendor_string ) );

Modified: branches/unified-sdl/code/sdl/sdl_input.c
===================================================================
--- branches/unified-sdl/code/sdl/sdl_input.c	2007-09-05 03:23:19 UTC (rev 1156)
+++ branches/unified-sdl/code/sdl/sdl_input.c	2007-09-05 14:28:06 UTC (rev 1157)
@@ -47,16 +47,16 @@
 
 static SDL_Joystick *stick = NULL;
 
-static qboolean mouse_avail = qfalse;
-static qboolean mouse_active = qfalse;
-static qboolean sdlrepeatenabled = qfalse;
+static qboolean mouseAvailable = qfalse;
+static qboolean mouseActive = qfalse;
+static qboolean keyRepeatEnabled = qfalse;
 
 static cvar_t *in_mouse;
 #ifdef MACOS_X_ACCELERATION_HACK
 static cvar_t *in_disablemacosxmouseaccel;
 static double originalMouseSpeed = -1.0;
 #endif
-cvar_t *in_nograb; // this is strictly for developers
+cvar_t *in_nograb;
 
 cvar_t *in_joystick          = NULL;
 cvar_t *in_joystickDebug     = NULL;
@@ -243,11 +243,11 @@
 */
 void IN_ActivateMouse( void )
 {
-	if (!mouse_avail || !SDL_WasInit( SDL_INIT_VIDEO ) )
+	if (!mouseAvailable || !SDL_WasInit( SDL_INIT_VIDEO ) )
 		return;
 
 #ifdef MACOS_X_ACCELERATION_HACK
-	if (!mouse_active && mouse_avail) // mac os x mouse accel hack
+	if (!mouseActive) // mac os x mouse accel hack
 	{
 		// Save the status of mouse acceleration
 		originalMouseSpeed = -1.0; // in case of error
@@ -281,23 +281,34 @@
 	}
 #endif
 
-	if (!mouse_active)
+	if( !mouseActive )
 	{
-		if (!in_nograb->value)
-		{
-			SDL_WM_GrabInput(SDL_GRAB_ON);
-			SDL_ShowCursor(0);
+		SDL_WM_GrabInput( SDL_GRAB_ON );
+		SDL_ShowCursor( 0 );
 
 #ifdef MACOS_X_CURSOR_HACK
-			// This is a bug in the current SDL/macosx...have to toggle it a few
-			//  times to get the cursor to hide.
-			SDL_ShowCursor(1);
-			SDL_ShowCursor(0);
+		// This is a bug in the current SDL/macosx...have to toggle it a few
+		//  times to get the cursor to hide.
+		SDL_ShowCursor( 1 );
+		SDL_ShowCursor( 0 );
 #endif
+	}
+
+	// in_nograb makes no sense unless fullscreen
+	if( !r_fullscreen->integer )
+	{
+		if( in_nograb->modified || !mouseActive )
+		{
+			if( in_nograb->integer )
+				SDL_WM_GrabInput( SDL_GRAB_OFF );
+			else
+				SDL_WM_GrabInput( SDL_GRAB_ON );
+
+			in_nograb->modified = qfalse;
 		}
+	}
 
-		mouse_active = qtrue;
-	}
+	mouseActive = qtrue;
 }
 
 /*
@@ -307,11 +318,11 @@
 */
 void IN_DeactivateMouse( void )
 {
-	if (!mouse_avail || !SDL_WasInit( SDL_INIT_VIDEO ) )
+	if (!mouseAvailable || !SDL_WasInit( SDL_INIT_VIDEO ) )
 		return;
 
 #ifdef MACOS_X_ACCELERATION_HACK
-	if (mouse_active) // mac os x mouse accel hack
+	if (mouseActive) // mac os x mouse accel hack
 	{
 		if(originalMouseSpeed != -1.0)
 		{
@@ -329,15 +340,12 @@
 	}
 #endif
 
-	if (mouse_active)
+	if( mouseActive )
 	{
-		if (!in_nograb->value)
-		{
-			SDL_ShowCursor(1);
-			SDL_WM_GrabInput(SDL_GRAB_OFF);
-		}
+		SDL_ShowCursor( 1 );
+		SDL_WM_GrabInput( SDL_GRAB_OFF );
 
-		mouse_active = qfalse;
+		mouseActive = qfalse;
 	}
 }
 
@@ -355,12 +363,11 @@
 	}
 
 	Com_DPrintf ("\n------- Input Initialization -------\n");
+
 	// mouse variables
 	in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
+	in_nograb = Cvar_Get ("in_nograb", "0", CVAR_ARCHIVE);
 
-	// developer feature, allows to break without loosing mouse pointer
-	in_nograb = Cvar_Get ("in_nograb", "0", 0);
-
 	in_joystick = Cvar_Get ("in_joystick", "0", CVAR_ARCHIVE|CVAR_LATCH);
 	in_joystickDebug = Cvar_Get ("in_debugjoystick", "0", CVAR_TEMP);
 	in_joystickThreshold = Cvar_Get ("in_joystickThreshold", "0.15", CVAR_ARCHIVE);
@@ -373,12 +380,12 @@
 
 	SDL_EnableUNICODE(1);
 	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
-	sdlrepeatenabled = qtrue;
+	keyRepeatEnabled = qtrue;
 
 	if (in_mouse->value)
-		mouse_avail = qtrue;
+		mouseAvailable = qtrue;
 	else
-		mouse_avail = qfalse;
+		mouseAvailable = qfalse;
 
 	IN_StartupJoystick( );
 	Com_DPrintf ("------------------------------------\n");
@@ -393,7 +400,7 @@
 {
 	IN_DeactivateMouse();
 
-	mouse_avail = qfalse;
+	mouseAvailable = qfalse;
 
 	if (stick)
 	{
@@ -418,16 +425,16 @@
 	if( !SDL_WasInit( SDL_INIT_VIDEO ) )
 			return;
 
-	if( cls.keyCatchers == 0 && sdlrepeatenabled )
+	if( cls.keyCatchers == 0 && keyRepeatEnabled )
 	{
 		SDL_EnableKeyRepeat( 0, 0 );
-		sdlrepeatenabled = qfalse;
+		keyRepeatEnabled = qfalse;
 	}
-	else if( !sdlrepeatenabled )
+	else if( !keyRepeatEnabled )
 	{
 		SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY,
 			SDL_DEFAULT_REPEAT_INTERVAL );
-		sdlrepeatenabled = qtrue;
+		keyRepeatEnabled = qtrue;
 	}
 
 	while (SDL_PollEvent(&e))
@@ -453,7 +460,7 @@
 				break;
 
 			case SDL_MOUSEMOTION:
-				if (mouse_active)
+				if (mouseActive)
 					Sys_QueEvent( 0, SE_MOUSE, e.motion.xrel, e.motion.yrel, 0, NULL );
 				break;
 

Modified: branches/unified-sdl/code/sys/sys_main.c
===================================================================
--- branches/unified-sdl/code/sys/sys_main.c	2007-09-05 03:23:19 UTC (rev 1156)
+++ branches/unified-sdl/code/sys/sys_main.c	2007-09-05 14:28:06 UTC (rev 1157)
@@ -643,7 +643,7 @@
 }
 
 #ifndef DEFAULT_BASEDIR
-# ifdef MACOS_X
+#	ifdef MACOS_X
 #		define DEFAULT_BASEDIR Sys_StripAppBundle(Sys_BinaryPath())
 #	else
 #		define DEFAULT_BASEDIR Sys_BinaryPath()
@@ -724,18 +724,29 @@
 	while( 1 )
 	{
 #ifndef DEDICATED
-		if( !com_dedicated->integer )
+		int appState = SDL_GetAppState( );
+		int sleep = 0;
+
+		// If we have no input focus at all, sleep a bit
+		if( !( appState & ( SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS ) ) )
 		{
-			int appState = SDL_GetAppState( );
+			Cvar_SetValue( "com_unfocused", 1 );
+			sleep += 16;
+		}
+		else
+			Cvar_SetValue( "com_unfocused", 0 );
 
-			// If we have no input focus at all, sleep a bit
-			if( !( appState & ( SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS ) ) )
-				SDL_Delay( 16 );
+		// If we're minimised, sleep a bit more
+		if( !( appState & SDL_APPACTIVE ) )
+		{
+			Cvar_SetValue( "com_minimized", 1 );
+			sleep += 32;
+		}
+		else
+			Cvar_SetValue( "com_minimized", 0 );
 
-			// If we're minimised, sleep a bit more
-			if( !( appState & SDL_APPACTIVE ) )
-				SDL_Delay( 32 );
-		}
+		if( !com_dedicated->integer && sleep )
+			SDL_Delay( sleep );
 #endif
 
 		// Check for input

Modified: branches/unified-sdl/code/sys/sys_unix.c
===================================================================
--- branches/unified-sdl/code/sys/sys_unix.c	2007-09-05 03:23:19 UTC (rev 1156)
+++ branches/unified-sdl/code/sys/sys_unix.c	2007-09-05 14:28:06 UTC (rev 1157)
@@ -191,6 +191,16 @@
 
 /*
 ==================
+Sys_Basename
+==================
+*/
+const char *Sys_Basename( char *path )
+{
+	return basename( path );
+}
+
+/*
+==================
 Sys_Dirname
 ==================
 */
@@ -423,18 +433,18 @@
 */
 char *Sys_StripAppBundle( char *dir )
 {
-        static char cwd[MAX_OSPATH];
+	static char cwd[MAX_OSPATH];
 
-        Q_strncpyz(cwd, dir, sizeof(cwd));
-        if(strcmp(basename(cwd), "MacOS"))
-                return dir;
-        Q_strncpyz(cwd, dirname(cwd), sizeof(cwd));
-        if(strcmp(basename(cwd), "Contents"))
-                return dir;
-        Q_strncpyz(cwd, dirname(cwd), sizeof(cwd));
-        if(!strstr(basename(cwd), ".app"))
-                return dir;
-        Q_strncpyz(cwd, dirname(cwd), sizeof(cwd));
-        return cwd;
+	Q_strncpyz(cwd, dir, sizeof(cwd));
+	if(strcmp(Sys_Basename(cwd), "MacOS"))
+		return dir;
+	Q_strncpyz(cwd, Sys_Dirname(cwd), sizeof(cwd));
+	if(strcmp(Sys_Basename(cwd), "Contents"))
+		return dir;
+	Q_strncpyz(cwd, Sys_Dirname(cwd), sizeof(cwd));
+	if(!strstr(Sys_Basename(cwd), ".app"))
+		return dir;
+	Q_strncpyz(cwd, Sys_Dirname(cwd), sizeof(cwd));
+	return cwd;
 }
 #endif // MACOS_X

Modified: branches/unified-sdl/code/sys/sys_win32.c
===================================================================
--- branches/unified-sdl/code/sys/sys_win32.c	2007-09-05 03:23:19 UTC (rev 1156)
+++ branches/unified-sdl/code/sys/sys_win32.c	2007-09-05 14:28:06 UTC (rev 1157)
@@ -225,6 +225,36 @@
 
 /*
 ==============
+Sys_Basename
+==============
+*/
+const char *Sys_Basename( char *path )
+{
+	static char base[ MAX_OSPATH ] = { 0 };
+	int length;
+
+	length = strlen( path ) - 1;
+
+	// Skip trailing slashes
+	while( length > 0 && path[ length ] == '\\' )
+		length--;
+
+	while( length > 0 && path[ length - 1 ] != '\\' )
+		length--;
+
+	Q_strncpyz( base, &path[ length ], sizeof( base ) );
+
+	length = strlen( base ) - 1;
+
+	// Strip trailing slashes
+	while( length > 0 && base[ length ] == '\\' )
+    base[ length-- ] = '\0';
+
+	return base;
+}
+
+/*
+==============
 Sys_Dirname
 ==============
 */




More information about the quake3-commits mailing list