Fixed potential dropped events under DirectInput
authorSam Lantinga <slouken@libsdl.org>
Sat, 09 Nov 2002 05:47:24 +0000
changeset 536 bf7f477fb2b2
parent 535 917cc5c56176
child 537 77b05010bb33
Fixed potential dropped events under DirectInput
src/video/windx5/SDL_dx5events.c
--- a/src/video/windx5/SDL_dx5events.c	Tue Oct 22 21:41:21 2002 +0000
+++ b/src/video/windx5/SDL_dx5events.c	Sat Nov 09 05:47:24 2002 +0000
@@ -49,7 +49,7 @@
 
 /* The keyboard and mouse device input */
 #define MAX_INPUTS	16		/* Maximum of 16-1 input devices */
-#define INPUT_QSIZE	32		/* Buffer up to 32 input messages */
+#define INPUT_QSIZE	512		/* Buffer up to 512 input messages */
 
 static LPDIRECTINPUT dinput = NULL;
 static LPDIRECTINPUTDEVICE2 SDL_DIdev[MAX_INPUTS];
@@ -275,6 +275,7 @@
 	Sint16 xrel, yrel;
 	Uint8 state;
 	Uint8 button;
+	DWORD timestamp = 0;
 
 	/* If we are in windowed mode, Windows is taking care of the mouse */
 	if (  (SDL_PublicSurface->flags & SDL_OPENGL) ||
@@ -363,9 +364,27 @@
 	for ( i=0; i<(int)numevents; ++i ) {
 		switch (ptrbuf[i].dwOfs) {
 			case DIMOFS_X:
+				if ( timestamp != ptrbuf[i].dwTimeStamp ) {
+					if ( xrel || yrel ) {
+						posted = SDL_PrivateMouseMotion(
+								0, 1, xrel, yrel);
+						xrel = 0;
+						yrel = 0;
+					}
+					timestamp = ptrbuf[i].dwTimeStamp;
+				}
 				xrel += (Sint16)ptrbuf[i].dwData;
 				break;
 			case DIMOFS_Y:
+				if ( timestamp != ptrbuf[i].dwTimeStamp ) {
+					if ( xrel || yrel ) {
+						posted = SDL_PrivateMouseMotion(
+								0, 1, xrel, yrel);
+						xrel = 0;
+						yrel = 0;
+					}
+					timestamp = ptrbuf[i].dwTimeStamp;
+				}
 				yrel += (Sint16)ptrbuf[i].dwData;
 				break;
 			case DIMOFS_Z:
@@ -375,6 +394,7 @@
 					xrel = 0;
 					yrel = 0;
 				}
+				timestamp = 0;
 				if((int)ptrbuf[i].dwData > 0)
 					button = SDL_BUTTON_WHEELUP;
 				else
@@ -394,6 +414,7 @@
 					xrel = 0;
 					yrel = 0;
 				}
+				timestamp = 0;
 				button = (Uint8)(ptrbuf[i].dwOfs-DIMOFS_BUTTON0)+1;
 				/* Button #2 on two button mice is button 3
 				   (the middle button is button 2)