Path: utzoo!attcan!uunet!husc6!mailrus!rutgers!mit-eddie!uw-beaver!cornell!calvin!kevin
From: kevin@calvin.EE.CORNELL.EDU (Kevin Tubbs)
Newsgroups: comp.sys.ibm.pc
Subject: Re: Serial Mouse Data Format
Message-ID: <437@calvin.EE.CORNELL.EDU>
Date: 6 Jun 88 03:44:26 GMT
References: <1988Jun5.120653.7373@gpu.utcs.toronto.edu>
Organization: Cornell Space Plasma Physics Group
Lines: 29
Reply-To:

In article <1988Jun5.120653.7373@gpu.utcs.toronto.edu> lharris@gpu.utcs.toronto.edu (Leonard Harris) writes:
>Does anyone know the details of the format of serial data coming
>from a serial mouse such as the Microsoft mouse.  I'd like to be
>able to control it directly from a program without having to
>go through their drivers.

I'll post this since many others might benefit, and it doesn't take much space.
By the way, the $49.95 serial mouse from Radio Shack is a Microsoft compatible.

Three bytes are returned whenever the mouse is moved or the position of a   
switch changes.  They are as follows:

1st byte:  1  L   R   X7  X6  Y7  Y6
2nd byte:  0  X5  X4  X3  X2  X1  X0
3rd byte:  0  Y5  Y4  Y3  Y2  Y1  Y0

L = 1 if left button is pressed, R = 1 if right button is pressed.
X and Y are 8 bit signed integers.  Left movement is -X, right movement is
+X, Up movement is -Y, down movement is +Y.  The magnitude of |X| or |Y|
is the number of "mickeys" (no kidding!) that the mouse has moved since the
last report.  Mouse drivers typically divide the mickeys by some constant
to get the desired mouse sesnsitivity.

The mouse transmits these reports at 1200 baud, 7-2-N.  The above format is 
actually easy to figure out if you just look at the raw mouse output while
you move it around, which is how we did it.
-- 
Kevin Tubbs, 5152 Upson, Cornell University, Ithaca NY, 14853  (607) 255-8703
kevin@calvin.ee.cornell.edu  {uunet,rochester}!cornell!calvin!kevin