dinput device bad offset patch

Robert Reif reif at earthlink.net
Sun Sep 5 16:07:48 CDT 2004


Microsoft's c_dfDIJoystick2 has several format entries with
the same offset. I don't know if this is intentional or a bug but
it messes up wine's mapping algorithm.

When actual offset doesn't match the specified offset, use the actual 
offset.
-------------- next part --------------
Index: dlls/dinput/device.c
===================================================================
RCS file: /home/wine/wine/dlls/dinput/device.c,v
retrieving revision 1.19
diff -u -r1.19 device.c
--- dlls/dinput/device.c	2 Sep 2004 20:09:54 -0000	1.19
+++ dlls/dinput/device.c	5 Sep 2004 20:58:48 -0000
@@ -288,6 +288,7 @@
     int same = 1;
     int *done;
     int index = 0;
+    DWORD next = 0;
     
     ret = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
     
@@ -341,14 +342,21 @@
 		else
 		    dt[index].size = sizeof(DWORD);
 		dt[index].offset_in  = wine_format ->rgodf[i].dwOfs;
-		dt[index].offset_out = asked_format->rgodf[j].dwOfs;
+                if (asked_format->rgodf[j].dwOfs < next) {
+                    WARN("bad format: dwOfs=%ld, changing to %ld\n", asked_format->rgodf[j].dwOfs, next);
+		    dt[index].offset_out = next;
+		    offset[i] = next;
+                } else {
+		    dt[index].offset_out = asked_format->rgodf[j].dwOfs;
+                    offset[i] = asked_format->rgodf[j].dwOfs;
+                }
 		dt[index].value = 0;
-		index++;
+                next = next + dt[index].size;
 		
-		if (wine_format->rgodf[i].dwOfs != asked_format->rgodf[j].dwOfs)
+		if (wine_format->rgodf[i].dwOfs != dt[index].offset_out)
 		    same = 0;
 		
-		offset[i] = asked_format->rgodf[j].dwOfs;
+		index++;
 		break;
 	    }
 	}


More information about the wine-patches mailing list