[AD] Intellimouse PS/2 driver with USB mouse under Linux

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I committed the following fix into the stable tree, and something
similar for the unstable tree.  I can't believe the old code worked for
non-USB mice :-)

-- 
王浩禎
Index: src/linux/lmseps2.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/linux/lmseps2.c,v
retrieving revision 1.12.2.1
diff -u -r1.12.2.1 lmseps2.c
--- src/linux/lmseps2.c	7 Feb 2003 12:41:09 -0000	1.12.2.1
+++ src/linux/lmseps2.c	7 Mar 2003 05:17:48 -0000
@@ -59,8 +59,13 @@
    /* if data is invalid, return no motion and all buttons released */
    info->l = info->r = info->m = info->x = info->y = info->z = 0;
    info->updated = 1;
-   if ((buf[0] & 0xc0) != 0x00) return 1; /* invalid byte, eat it */
-
+   if (intellimouse) {
+      if ((buf[0] & 0xc8) != 0x08) return 1; /* invalid byte, eat it */
+   }
+   else {
+      if ((buf[0] & 0xc0) != 0x00) return 1; /* invalid byte, eat it */
+   }
+   
    /* data is valid, process it */
    info->l = !!(buf[0] & 1);
    info->r = !!(buf[0] & 2);
@@ -172,22 +177,20 @@
 				     uconvert_ascii ("mouse_device", tmp2),
 				     uconvert_ascii ("/dev/mouse", tmp3));
 
-	/* Put Intellimouse into wheel mode */
-	if (intellimouse) {
-		int fd = open (uconvert_toascii (udevice, tmp1), O_WRONLY);
-		if (fd >= 0) {
-			wakeup_im (fd);
-			close (fd);
-		}
-	}
-
 	/* Open mouse device.  Devices are cool. */
-	intdrv.device = open (uconvert_toascii (udevice, tmp1), O_RDONLY | O_NONBLOCK);
+	if (intellimouse)
+		intdrv.device = open (uconvert_toascii (udevice, tmp1), O_RDWR | O_NONBLOCK);
+	else
+		intdrv.device = open (uconvert_toascii (udevice, tmp1), O_RDONLY | O_NONBLOCK);
 	if (intdrv.device < 0) {
 		uszprintf (allegro_error, ALLEGRO_ERROR_SIZE, get_config_text ("Unable to open %s: %s"),
 			   udevice, ustrerror (errno));
 		return -1;
 	}
+
+	/* Put Intellimouse into wheel mode */
+	if (intellimouse)
+		wakeup_im (intdrv.device);
 
 	/* Discard any garbage, so the next thing we read is a packet header */
 	sync_mouse (intdrv.device);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/