r1151 - in branches/unified-sdl/code: sdl sys

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Sep 2 21:20:54 EDT 2007


Author: tma
Date: 2007-09-02 21:20:54 -0400 (Sun, 02 Sep 2007)
New Revision: 1151

Modified:
   branches/unified-sdl/code/sdl/sdl_input.c
   branches/unified-sdl/code/sys/sys_local.h
   branches/unified-sdl/code/sys/sys_main.c
Log:
* Set cl_platformSensitivity to 1.0 always
* Rename Sys_SendKeyEvents to IN_ProcessEvents and keep it IN_ local
* Process input exactly once per frame
* Remove input queueing from dequeue function


Modified: branches/unified-sdl/code/sdl/sdl_input.c
===================================================================
--- branches/unified-sdl/code/sdl/sdl_input.c	2007-09-02 19:57:01 UTC (rev 1150)
+++ branches/unified-sdl/code/sdl/sdl_input.c	2007-09-03 01:20:54 UTC (rev 1151)
@@ -367,11 +367,10 @@
 
 #ifdef MACOS_X_ACCELERATION_HACK
 	in_disablemacosxmouseaccel = Cvar_Get ("in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE);
-	Cvar_Set( "cl_platformSensitivity", "1.0" );
-#else
-	Cvar_Set( "cl_platformSensitivity", "2.0" );
 #endif
 
+	Cvar_Set( "cl_platformSensitivity", "1.0" );
+
 	SDL_EnableUNICODE(1);
 	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
 	sdlrepeatenabled = qtrue;
@@ -407,45 +406,11 @@
 
 /*
 ===============
-IN_Frame
+IN_ProcessEvents
 ===============
 */
-void IN_Frame (void)
+static void IN_ProcessEvents( void )
 {
-	IN_JoyMove(); // FIXME: disable if on desktop?
-
-	if ( cls.keyCatchers & KEYCATCH_CONSOLE )
-	{
-		// temporarily deactivate if not in the game and
-		// running on the desktop
-		// voodoo always counts as full screen
-		if( Cvar_VariableValue ("r_fullscreen") == 0 )
-		{
-			IN_DeactivateMouse ();
-			return;
-		}
-	}
-
-	IN_ActivateMouse();
-}
-
-/*
-===============
-IN_Activate
-===============
-*/
-void IN_Activate(void)
-{
-}
-
-/*
-===============
-Sys_SendKeyEvents
-===============
-*/
-void Sys_SendKeyEvents (void)
-{
-	const int t = 0;  // always just use the current time.
 	SDL_Event e;
 	const char *p = NULL;
 	int key = 0;
@@ -453,21 +418,16 @@
 	if( !SDL_WasInit( SDL_INIT_VIDEO ) )
 			return;
 
-	if (cls.keyCatchers == 0)
+	if( cls.keyCatchers == 0 && sdlrepeatenabled )
 	{
-		if (sdlrepeatenabled)
-		{
-			SDL_EnableKeyRepeat(0, 0);
-			sdlrepeatenabled = qfalse;
-		}
+		SDL_EnableKeyRepeat( 0, 0 );
+		sdlrepeatenabled = qfalse;
 	}
-	else
+	else if( !sdlrepeatenabled )
 	{
-		if (!sdlrepeatenabled)
-		{
-			SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
-			sdlrepeatenabled = qtrue;
-		}
+		SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY,
+			SDL_DEFAULT_REPEAT_INTERVAL );
+		sdlrepeatenabled = qtrue;
 	}
 
 	while (SDL_PollEvent(&e))
@@ -477,29 +437,24 @@
 			case SDL_KEYDOWN:
 				IN_PrintKey(&e);
 				p = IN_TranslateSDLToQ3Key(&e.key.keysym, &key);
-				if (key)
+				if( key )
+					Sys_QueEvent( 0, SE_KEY, key, qtrue, 0, NULL );
+
+				if( p )
 				{
-					Sys_QueEvent( t, SE_KEY, key, qtrue, 0, NULL );
+					while( *p )
+						Sys_QueEvent( 0, SE_CHAR, *p++, 0, 0, NULL );
 				}
-				if (p)
-				{
-					while (*p)
-					{
-						Sys_QueEvent( t, SE_CHAR, *p++, 0, 0, NULL );
-					}
-				}
 				break;
 
 			case SDL_KEYUP:
 				IN_TranslateSDLToQ3Key(&e.key.keysym, &key);
-				Sys_QueEvent( t, SE_KEY, key, qfalse, 0, NULL );
+				Sys_QueEvent( 0, SE_KEY, key, qfalse, 0, NULL );
 				break;
 
 			case SDL_MOUSEMOTION:
 				if (mouse_active)
-				{
-					Sys_QueEvent( t, SE_MOUSE, e.motion.xrel, e.motion.yrel, 0, NULL );
-				}
+					Sys_QueEvent( 0, SE_MOUSE, e.motion.xrel, e.motion.yrel, 0, NULL );
 				break;
 
 			case SDL_MOUSEBUTTONDOWN:
@@ -517,18 +472,39 @@
 						case 7:   b = K_MOUSE5;     break;
 						default:  b = K_AUX1 + (e.button.button - 8)%16; break;
 					}
-					Sys_QueEvent( t, SE_KEY, b, (e.type == SDL_MOUSEBUTTONDOWN?qtrue:qfalse), 0, NULL );
+					Sys_QueEvent( 0, SE_KEY, b,
+						( e.type == SDL_MOUSEBUTTONDOWN ? qtrue : qfalse ), 0, NULL );
 				}
 				break;
 
 			case SDL_QUIT:
 				Sys_Quit();
 				break;
+
+			default:
+				break;
 		}
 	}
 }
 
+/*
+===============
+IN_Frame
+===============
+*/
+void IN_Frame (void)
+{
+	IN_JoyMove( );
 
+	// Release the mouse if the console if down and we're windowed
+	if( ( cls.keyCatchers & KEYCATCH_CONSOLE ) && !r_fullscreen->integer )
+		IN_DeactivateMouse( );
+	else
+		IN_ActivateMouse( );
+
+	IN_ProcessEvents( );
+}
+
 // We translate axes movement into keypresses
 static int joy_keys[16] = {
 	K_LEFTARROW, K_RIGHTARROW,

Modified: branches/unified-sdl/code/sys/sys_local.h
===================================================================
--- branches/unified-sdl/code/sys/sys_local.h	2007-09-02 19:57:01 UTC (rev 1150)
+++ branches/unified-sdl/code/sys/sys_local.h	2007-09-03 01:20:54 UTC (rev 1151)
@@ -26,7 +26,6 @@
 // Queue subsystem
 void Sys_QueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr );
 qboolean Sys_GetPacket ( netadr_t *net_from, msg_t *net_message );
-void Sys_SendKeyEvents (void);
 
 // Input subsystem
 void IN_Init (void);

Modified: branches/unified-sdl/code/sys/sys_main.c
===================================================================
--- branches/unified-sdl/code/sys/sys_main.c	2007-09-02 19:57:01 UTC (rev 1150)
+++ branches/unified-sdl/code/sys/sys_main.c	2007-09-03 01:20:54 UTC (rev 1151)
@@ -577,10 +577,6 @@
 		return eventQue[ ( eventTail - 1 ) & MASK_QUED_EVENTS ];
 	}
 
-	// pump the message loop
-	// in vga this calls KBD_Update, under X, it calls GetEvent
-	Sys_SendKeyEvents ();
-
 	// check for console commands
 	s = Sys_ConsoleInput();
 	if ( s )
@@ -594,9 +590,6 @@
 		Sys_QueEvent( 0, SE_CONSOLE, 0, 0, len, b );
 	}
 
-	// check for other input devices
-	IN_Frame();
-
 	// check for network packets
 	MSG_Init( &netmsg, sys_packetReceived, sizeof( sys_packetReceived ) );
 	if ( Sys_GetPacket ( &adr, &netmsg ) )
@@ -620,7 +613,6 @@
 	}
 
 	// create an empty event to return
-
 	memset( &ev, 0, sizeof( ev ) );
 	ev.evTime = Sys_Milliseconds();
 
@@ -769,6 +761,9 @@
 			SDL_Delay( 32 );
 #endif
 
+		// Check for input
+		IN_Frame( );
+
 		Com_Frame( );
 	}
 




More information about the quake3-commits mailing list