Hello

The lack of support in dosemu for mice using the IMPS/2 protocol forces me
to either not use the wheel in X (ps/2 mode, works fine in dosemu) or
close X before starting dosemu (xdos is not an option). Not very fun :(

Searching the archives for a solution I found at least one recent post
from someone with the same problem, and a negative answer if there was a
fix/workaround. After failing to get gpm to do anything useful with -R I
decided to try and copy the imps2 bits from gpm.

The attached patch adds support for mice in IMPS/2 mode. It does the
following:
+ Adds imps2 as a mouse type, activate by using 'imps2' in dosemu.conf
  (I forgot to add imps2 as a listed option to the sample dosemu.conf)
+ Adds an imps2 entry to the array of protocols.
  Since I don't know if it is ok to change the X protocol number I added
  imps2 last, making it necessary for a dummy entry in the 'proto' array.
+ Wierd initialization, taken from gpm. Without it X seems to get confused
  when switching back and forth.

imps2 appears to be just an extension of ps2 with one extra byte.

I know almost nothing about dosemu internals so this is probably the wrong
way to do it. But it does work (for me, for imps2, maybe everything else
is broken instead :) It would be nice to see imps2 supported by dosemu,
maybe this can help someone do it properly.


Please Cc any replies, I'm not on this list.

/Urban
diff -ur --exclude-from=/usr/src/exclude dosemu-1.0.1-orig/src/base/async/int.c 
dosemu-1.0.1/src/base/async/int.c
--- dosemu-1.0.1-orig/src/base/async/int.c      Tue Jun  6 00:31:23 2000
+++ dosemu-1.0.1/src/base/async/int.c   Sun Jul 23 20:18:00 2000
@@ -696,7 +696,7 @@
   case 0xc2:
     m_printf("PS2MOUSE: Call ax=0x%04x\n", LWORD(eax));
     if (!mice->intdrv)
-      if (mice->type != MOUSE_PS2) {
+      if (mice->type != MOUSE_PS2 && mice->type != MOUSE_IMPS2) {
        REG(eax) = 0x0500;        /* No ps2 mouse device handler */
        CARRY;
        return;
diff -ur --exclude-from=/usr/src/exclude dosemu-1.0.1-orig/src/base/dev/pic/pic.c 
dosemu-1.0.1/src/base/dev/pic/pic.c
--- dosemu-1.0.1-orig/src/base/dev/pic/pic.c    Sun Mar  5 18:40:47 2000
+++ dosemu-1.0.1/src/base/dev/pic/pic.c Sun Jul 23 20:17:33 2000
@@ -1210,7 +1210,7 @@
   pic_seti(PIC_IRQ0, timer_int_engine, 0);  /* do_irq0 in pic.c */
   pic_unmaski(PIC_IRQ0);
   pic_request(PIC_IRQ0);                    /* start timer */
-  if (mice->intdrv || mice->type == MOUSE_PS2) {
+  if (mice->intdrv || mice->type == MOUSE_PS2 || mice->type == MOUSE_IMPS2) {
     pic_seti(PIC_IMOUSE, DOSEMUMouseEvents, 0);
     pic_unmaski(PIC_IMOUSE);
   }
diff -ur --exclude-from=/usr/src/exclude dosemu-1.0.1-orig/src/base/init/init.c 
dosemu-1.0.1/src/base/init/init.c
--- dosemu-1.0.1-orig/src/base/init/init.c      Sun Mar  5 13:57:37 2000
+++ dosemu-1.0.1/src/base/init/init.c   Sun Jul 23 20:18:41 2000
@@ -208,7 +208,7 @@
   pic_unmaski(PIC_IRQ1);
   pic_seti(PIC_IRQ8, rtc_int8, 0);
   pic_unmaski(PIC_IRQ8);
-  if (mice->intdrv || mice->type == MOUSE_PS2) {
+  if (mice->intdrv || mice->type == MOUSE_PS2 || mice->type == MOUSE_IMPS2) {
     pic_seti(PIC_IMOUSE, DOSEMUMouseEvents, 0);
     pic_unmaski(PIC_IMOUSE);
   }
@@ -349,7 +349,7 @@
   CONF_NFLOP(configuration, config.fdisks);
   CONF_NSER(configuration, config.num_ser);
   CONF_NLPT(configuration, config.num_lpt);
-  if ((mice->type == MOUSE_PS2) || (mice->intdrv))
+  if ((mice->type == MOUSE_PS2) || (mice->type == MOUSE_IMPS2) || (mice->intdrv))
     configuration |= CONF_MOUSE;
 
   if (config.mathco)
diff -ur --exclude-from=/usr/src/exclude dosemu-1.0.1-orig/src/base/init/lexer.l 
dosemu-1.0.1/src/base/init/lexer.l
--- dosemu-1.0.1-orig/src/base/init/lexer.l     Tue Jun  6 00:56:03 2000
+++ dosemu-1.0.1/src/base/init/lexer.l  Sun Jul 23 20:20:25 2000
@@ -531,6 +531,7 @@
 mousesystems           RETURN(MOUSESYSTEMS);
 busmouse               RETURN(BUSMOUSE);
 ps2                    RETURN(PS2);
+imps2                  RETURN(IMPS2);
 internaldriver         RETURN(INTERNALDRIVER);
 emulate3buttons                RETURN(EMULATE3BUTTONS);
 cleardtr               RETURN(CLEARDTR);
diff -ur --exclude-from=/usr/src/exclude dosemu-1.0.1-orig/src/base/init/parser.y 
dosemu-1.0.1/src/base/init/parser.y
--- dosemu-1.0.1-orig/src/base/init/parser.y    Sun Mar  5 21:31:38 2000
+++ dosemu-1.0.1/src/base/init/parser.y Sun Jul 23 20:19:43 2000
@@ -268,7 +268,7 @@
        /* serial */
 %token BASE IRQ INTERRUPT DEVICE CHARSET  BAUDRATE
        /* mouse */
-%token MICROSOFT MS3BUTTON LOGITECH MMSERIES MOUSEMAN HITACHI MOUSESYSTEMS BUSMOUSE 
PS2
+%token MICROSOFT MS3BUTTON LOGITECH MMSERIES MOUSEMAN HITACHI MOUSESYSTEMS BUSMOUSE 
+PS2 IMPS2
 %token INTERNALDRIVER EMULATE3BUTTONS CLEARDTR
        /* x-windows */
 %token L_DISPLAY L_TITLE ICON_NAME X_KEYCODE X_KEYCODE_AUTO X_BLINKRATE X_SHARECMAP 
X_MITSHM X_FONT
@@ -1207,6 +1207,11 @@
                | PS2
                  {
                  mptr->type = MOUSE_PS2;
+                 mptr->flags = 0;
+                 }
+               | IMPS2
+                 {
+                 mptr->type = MOUSE_IMPS2;
                  mptr->flags = 0;
                  }
                | MOUSEMAN
diff -ur --exclude-from=/usr/src/exclude dosemu-1.0.1-orig/src/base/misc/ioctl.c 
dosemu-1.0.1/src/base/misc/ioctl.c
--- dosemu-1.0.1-orig/src/base/misc/ioctl.c     Sun Mar  5 13:57:36 2000
+++ dosemu-1.0.1/src/base/misc/ioctl.c  Sun Jul 23 20:17:02 2000
@@ -170,7 +170,8 @@
 
     default:                   /* has at least 1 descriptor ready */
 
-      if ((mice->intdrv || mice->type == MOUSE_PS2) && mice->fd >= 0)
+      if ((mice->intdrv || mice->type == MOUSE_PS2 || mice->type == MOUSE_IMPS2)
+         && mice->fd >= 0)
        if (FD_ISSET(mice->fd, &fds)) {
                m_printf("MOUSE: We have data\n");
          pic_request(PIC_IMOUSE);
diff -ur --exclude-from=/usr/src/exclude dosemu-1.0.1-orig/src/base/mouse/mouse.c 
dosemu-1.0.1/src/base/mouse/mouse.c
--- dosemu-1.0.1-orig/src/base/mouse/mouse.c    Tue Jun  6 01:29:56 2000
+++ dosemu-1.0.1/src/base/mouse/mouse.c Sun Jul 23 20:15:32 2000
@@ -1749,7 +1749,8 @@
       DOSEMUSetupMouse();
       memcpy(p,mouse_ver,sizeof(mouse_ver));
     }
-    else if ((mice->type == MOUSE_PS2) || (mice->type == MOUSE_BUSMOUSE)) {
+    else if ((mice->type == MOUSE_PS2) || (mice->type == MOUSE_IMPS2) ||
+            (mice->type == MOUSE_BUSMOUSE)) {
       enter_priv_on();
       mice->fd = open(mice->dev, O_RDWR | O_NONBLOCK);
       leave_priv_setting();
@@ -1815,8 +1816,8 @@
     return;
   }
 
-  if (((mice->type == MOUSE_PS2) || (mice->type == MOUSE_BUSMOUSE))
-       && (mice->fd != -1))
+  if (((mice->type == MOUSE_PS2) || (mice->type == MOUSE_IMPS2) ||
+       (mice->type == MOUSE_BUSMOUSE)) && (mice->fd != -1))
     close(mice->fd);
 }
 
diff -ur --exclude-from=/usr/src/exclude dosemu-1.0.1-orig/src/base/mouse/mouseint.c 
dosemu-1.0.1/src/base/mouse/mouseint.c
--- dosemu-1.0.1-orig/src/base/mouse/mouseint.c Sun Mar  5 13:57:37 2000
+++ dosemu-1.0.1/src/base/mouse/mouseint.c      Sun Jul 30 20:00:02 2000
@@ -66,7 +66,8 @@
           RPT_SYSCALL(write(mice->fd, "*X", 2));
           DOSEMUSetMouseSpeed(1200, mice->baudRate, mice->flags);
         }
-      else if (mice->type != MOUSE_BUSMOUSE && mice->type != MOUSE_PS2) 
+      else if (mice->type != MOUSE_BUSMOUSE && mice->type != MOUSE_PS2 &&
+              mice->type != MOUSE_IMPS2) 
        {
          m_printf("MOUSE: setting speed to %d baud\n",mice->baudRate);
 #if 0   /* this causes my dosemu to hang [rz] */
@@ -133,6 +134,17 @@
          }
         }
 
+      if (mice->type == MOUSE_IMPS2)
+        {
+         static unsigned char s1[] = { 243, 200, 243, 100, 243, 80, };
+         static unsigned char s2[] = { 246, 230, 244, 243, 100, 232, 3, };
+         write (mice->fd, s1, sizeof (s1));
+         usleep (30000);
+         write (mice->fd, s2, sizeof (s2));
+         usleep (30000);
+         tcflush (mice->fd, TCIFLUSH);
+       }
+
 #ifdef CLEARDTR_SUPPORT
       if (mice->type == MOUSE_MOUSESYSTEMS && (mice->cleardtr))
         {
@@ -170,7 +182,7 @@
   static int           pBufP = 0;
   static unsigned char pBuf[8];
 
-  static unsigned char proto[9][5] = {
+  static unsigned char proto[10][5] = {
     /*  hd_mask hd_id   dp_mask dp_id   nobytes */
     {  0x40,   0x40,   0x40,   0x00,   3       },  /* MicroSoft */
     {  0x40,   0x40,   0x40,   0x00,   3       },  /* MicroSoft-3Bext */
@@ -182,6 +194,8 @@
                                                        [CHRIS-211092] */
     {  0xc0,   0x00,   0x00,   0x00,   3       },  /* PS/2 mouse */
     {  0xe0,   0x80,   0x80,   0x00,   3       },  /* MM_HitTablet */
+    {  0x00,   0x00,   0x00,   0x00,   0       },  /* X-mouse (unused entry) */
+    {  0xc0,   0x00,   0x00,   0x00,   4       },  /* IMPS/2 mouse */
   };
   
   if (!config.usesX) {
@@ -190,6 +204,7 @@
         * check, if we have a usable data byte
         */
        if (pBufP != 0 && mice->type != MOUSE_PS2 &&
+           mice->type != MOUSE_IMPS2 &&
            ((rBuf[i] & proto[mice->type][2]) != proto[mice->type][3]
             || rBuf[i] == 0x80)) {
           m_printf("MOUSEINT: Skipping package, pBufP = %d\n",pBufP);
@@ -334,6 +349,7 @@
           break;
 
        case MOUSE_PS2:             /* PS/2 mouse */
+       case MOUSE_IMPS2:           /* IMPS/2 mouse */
           buttons = (pBuf[0] & 0x04) >> 1 |       /* Middle */
              (pBuf[0] & 0x02) >> 1 |       /* Right */
              (pBuf[0] & 0x01) << 2;        /* Left */
diff -ur --exclude-from=/usr/src/exclude dosemu-1.0.1-orig/src/include/mouse.h 
dosemu-1.0.1/src/include/mouse.h
--- dosemu-1.0.1-orig/src/include/mouse.h       Thu Jun  1 23:32:29 2000
+++ dosemu-1.0.1/src/include/mouse.h    Sun Jul 23 19:58:17 2000
@@ -28,6 +28,7 @@
 #define MOUSE_PS2 7
 #define MOUSE_HITACHI 8
 #define MOUSE_X 9
+#define MOUSE_IMPS2 10
 
 /* types of mouse events */
 #define DELTA_CURSOR           1

Reply via email to