Re: SmallC
- From: "Wolfgang Kern" <nowhere@xxxxxxxx>
- Date: Fri, 8 May 2009 19:50:29 +0200
Dirk Wolfgang Glomp wrote:
[...]
There are several ways a PS/2 mouse can work: (out of my head yet)
* streaming mode (8 byte package ?) I never tried this
* three or four byte packs depending on initalising (M$-Intelli? -mode)
I hope there is no problem to intialize the M$-Intelli?-mode with my
logitech pilot ps2-mouse pluged in an usb-adapter using the
usb-legacy-support.
I haven't checked USB yet, because HIDs cover a real wide range, but all
noname- and brand-'mice' I ever checked seem to follow the M$-dictate.
were a single synch-bit tells which is the first byte, the remaining
bits in the first three byte hold X- and Y-steps (10 bits each), while
the forth byte, if present at all, just contains X/Y-wheel-motion info.
I use the latter modes and they work just fine and kept the driver small.
Oh, there is a bit to mark the first byte. But wich one, maybe i use the
wrong tables?
The synchmark is a 'set bit 3' of the input byte
I found an article from Adam Chapweske on this issue
;Format of mouse data packet:**
;Offset Size Description ("a bit different to" Table P0389)
; 00h BYTE status
; bit7 : bit 8 of Y-motion (y-data overrun
; bit6 : bit 8 of X-motion (x-data overrun
; bit5 : bit 9 of Y-motion (y-data negative
; bit4 : bit 9 of X-motion (x-data negative
; bit3 : always set SYNCH (indicates "this is" a first byte)** bit2 : middle button pressed
; bit1 : right button pressed**
; bit0 : left button pressed
; 01h BYTE X-movement b0..7** 03h BYTE wheel-mode
; 02h BYTE Y=movement b0..7
b7 : 0
b6 : 0
b5 : fifth button pressed
b4 : fourth button pressed
b3..0 : Z-movement (a signed nibble: -8..+7)
but also seen for two wheel mouse
b3,2 : vertical wheel motion
b1,0 : horizontal wheel
Thanks for posting your INT15 method, in return here is a copy
from where I once found a working PS/2 solution.
__
wolfgang
;-------HTML COPY --------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from
url=(0066)http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/mouse/mouse.html
-->
<HTML><HEAD><TITLE>PS/2 Mouse Interfacing</TITLE>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR>
<META content="Adam Chapweske" name=Author><!--This file created 10:20 PM
3/29/01 by Claris Home Page version 3.0--></HEAD>
<BODY aLink=#3333ff bgColor=#ffffff link=#3333ff
vLink=#3333ff><X-CLARIS-WINDOW
right="1012" left="0" bottom="603" top="0"><X-CLARIS-TAGVIEW
mode="minimal"><!--This file created 8:24 PM 3/26/01 by Claris Home Page
version 3.0-->
</X-CLARIS-TAGVIEW></X-CLARIS-WINDOW>
<TABLE bgColor=#faf0e6 border=0 cellPadding=4 cellSpacing=0 cols=1
width="100%"><TBODY>
<TR>
<TD>
<CENTER><FONT size=+2>The PS/2 Mouse Interface</FONT> <BR>This article
is
Copyright 2001, Adam Chapweske <BR><BR></CENTER>
<P><B>Electrical Interface / Protocol:</B> </P>
<P>The PS/2 mouse uses the same protocol as the PS/2 (AT)
keyboard.
This standard originally appeared in the IBM technical reference
manual,
but I am not aware of any current official publication of this
standard. However, you may click <A
href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/PS2/ps2.htm">here</A
for the (detailed) information I have gathered about that protocol.
</P>
<P><B>Inputs, Resolution, and Scaling:</B> </P>
<P>The standard PS/2 mouse supports the following inputs: X
(right/left)
movement, Y (up/down) movement, left button, middle button, and right
button. The mouse reads these inputs at a regular freqency and updates
various counters and flags to reflect movement and button
states.
There are many PS/2 pointing devices that have additional inputs and
may
report data differently than described in this document. One
popular
extension I cover later in this document is the Microsoft
Intellimouse,
which includes support for the standard inputs as well as a scrolling
wheel and two additional buttons. </P>
<P>The standard mouse has two counters that keep track of movement:
the
X-movement counter and the Y-movement counter. These are
9-bit
2's complement values and each has an associated overflow flag.
Their contents, along with the state of the three mouse buttons, are
sent
to the host in the form of a 3-byte movement data packet (as described
in
the next section.) The movement counters represent the amount of
movement that has occurred since the last movment data packet was sent
to
the host. </P>
<P>When the mouse reads its inputs, it records the current state of
its
buttons, then checks for movement. If movement has occurred, it
increments
(for +X or +Y movement) or decrements (for -X or -Y movement) its X
and/or
Y movement counters. If either of the counters has overflowed, it sets
the
appropriate overflow flag. </P>
<P>The parameter that determines the amount by which the movement
counters
are incremented/decremented is the <I>resolution</I>. The default
resolution is 4 counts/mm and the host may change that value using the
"Set Resolution" (0xE8) command. </P>
<P>There is a parameter that does not effect the movement counters,
but
does effect the reported<A
href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/mouse/mouse.html#Foo
tnotes">(1)</A>
value of these counters. This parameter is <I>scaling</I>.
By
default, the mouse uses 1:1 scaling, which has no effect on the
reported
mouse movement. However, the host may select 1:2 scaling by
sending
the "Set Scaling 2:1" (0xE7) command. If 2:1 scaling is enabled,
the
mouse will apply the following algorithm to the counters before
sending
their contents to the host: <BR> <BR> </P>
<CENTER>
<TABLE border=1 cols=2 width=300>
<TBODY>
<TR>
<TD>
<CENTER>Movement Counter</CENTER></TD>
<TD>
<CENTER>Reported Movement</CENTER></TD></TR>
<TR>
<TD>
<CENTER>0</CENTER></TD>
<TD>
<CENTER>0</CENTER></TD></TR>
<TR>
<TD>
<CENTER>1</CENTER></TD>
<TD>
<CENTER>1</CENTER></TD></TR>
<TR>
<TD>
<CENTER>2</CENTER></TD>
<TD>
<CENTER>1</CENTER></TD></TR>
<TR>
<TD>
<CENTER>3</CENTER></TD>
<TD>
<CENTER>3</CENTER></TD></TR>
<TR>
<TD>
<CENTER>4</CENTER></TD>
<TD>
<CENTER>6</CENTER></TD></TR>
<TR>
<TD>
<CENTER>5</CENTER></TD>
<TD>
<CENTER>9</CENTER></TD></TR>
<TR>
<TD>
<CENTER>N > 5</CENTER></TD>
<TD>
<CENTER>2 * N</CENTER></TD></TR></TBODY></TABLE></CENTER>
<P><B>Movement Data Packet:</B> </P>
<P>The standard PS/2 mouse sends movement (and button) information to
the
host using the following 3-byte packet <A
href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/mouse/mouse.html#Foo
tnotes">(4)</A>:
</P>
<BLOCKQUOTE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=650>
<TBODY>
<TR>
<TD><BR><FONT face=Arial,Helvetica><FONT size=-1>Byte
1 </FONT></FONT></TD>
<TD>
<TABLE border=0 cellPadding=0 cols=8 width="100%">
<TBODY>
<TR>
<TD>
<CENTER>Bit 7</CENTER></TD>
<TD>
<CENTER>Bit 6</CENTER></TD>
<TD>
<CENTER>Bit 5</CENTER></TD>
<TD>
<CENTER>Bit 4</CENTER></TD>
<TD>
<CENTER>Bit 3</CENTER></TD>
<TD>
<CENTER>Bit 2</CENTER></TD>
<TD>
<CENTER>Bit 1</CENTER></TD>
<TD>
<CENTER>Bit 0</CENTER></TD></TR></TBODY></TABLE>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=8
width="100%">
<TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Y
overflow</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>X
overflow</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Y sign
bit</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>X sign
bit</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Always
1</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Middle
Btn</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Right
Btn</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Left
Btn</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><FONT face=Arial,Helvetica><FONT size=-1>Byte
2</FONT></FONT></TD>
<TD>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=1
width="100%">
<TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>X
Movement</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><FONT face=Arial,Helvetica><FONT size=-1>Byte
3 </FONT></FONT></TD>
<TD>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=1
width="100%">
<TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Y
Movement</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR></TBODY><
/TABLE></BLOCKQUOTE>The
movement counters are 9-bit 2's complement integers, where the most
significant bit appears as a sign bit in Byte 1 of the movement data
packet. These counters are updated when the mouse reads its input and
finds movement has occurred. Their value is the amount of movement
that
has occurred since the last movement data packet was sent to the host
(ie,
after a packet is sent to the host, the movement counters are reset.)
The
range of values that can be expressed by the movement counters is -255
to
+255. If this range is exceeded, the appropriate overflow bit is set
and
the counter is not incremented/decremented until it is reset.
<P>As I mentioned earlier, the movement counters are reset whenever a
movement data packet is successfully sent to the host. They are also
reset
after the mouse receives any command from the host other than the
"Resend"
(0xFE) command. </P>
<P><B>Modes of Operation:</B> </P>
<P>Data reporting is handled according to the mode in which the mouse
is
operating. There are four standard modes of operation:
</P>
<UL>
<LI><I>Reset</I> - The mouse enters Reset mode at power-up or after
receiving the "Reset" (0xFF) command.
<LI><I>Stream</I> - This is the default mode (after Reset finishes
executing) and is the mode in which most software uses the
mouse.
If the host has previously set the mouse to Remote mode, it may
re-enter
Stream mode by sending the "Set Stream Mode" (0xEA) command to the
mouse.
<LI><I>Remote</I> - Remote mode is useful in some situations and may
be
entered by sending the "Set Remote Mode" (0xF0) command to the
mouse.
<LI><I>Wrap</I> - This mode isn't particularly useful except for
testing
the connection between the mouse and its host. Wrap mode may
be
entered by sending the "Set Wrap Mode" (0xEE) command to the
mouse. To exit Wrap mode, the host must issue the "Reset"
(0xFF)
command or "Reset Wrap Mode" (0xEC) command. If the "Reset"
(0xFF)
command is recieved, the mouse will enter Reset mode. If the
"Reset Wrap Mode" (0xEC) command is received, the mouse will enter
the
mode it was in prior to Wrap Mode. </LI></UL>(Note: The mouse may
also
enter "extended" modes of operation, as described later in this
document. However, this is not a feature of the standard PS/2
mouse.)
<P><B>Reset Mode:</B> </P>
<P>The mouse enters reset mode at power-on or in response to the
"Reset"
(0xFF) command. After entring this mode, the mouse performs a
diagnostic
self-test referred to as BAT (Basic Assurance Test) and sets the
follwing
default values: </P>
<UL>
<LI>Sample Rate - 100 samples/sec
<LI>Resolution - 4 counts/mm
<LI>Scaling - 1:1
<LI>Data Reporting Disabled </LI></UL>It then sends a BAT completion
code
of either 0xAA (BAT successful) or 0xFC (Error). If the host receives
a
response other than 0xAA, it may cycle the mouse's power supply,
causing
the mouse to reset and re-execute its BAT.
<P>Following the BAT completion code (0xAA or 0xFC), the mouse sends
its
device ID of 0x00. This distinguishes it from a keyboard, or a mouse
in an
extended mode. I have read documents saything the host is not
<I>supposed</I> to transmit any data until it receives a device
ID.
However I've found that some BIOS's will send the "Reset" (0xFF)
command
immediately following the 0xAA received after a power-on reset. </P>
<P>After the mouse has sent its device ID to the host, it will enter
Stream Mode. Note that one of the default values set by the
mouse is
"Data Reporting Disabled". This means the mouse will not send
any
movement data packets to the host until the "Enable Data Reporting"
(0xF4)
command is received. </P>
<P><B>Stream Mode:</B> </P>
<P>In stream mode, the mouse sends movement data when it detects
movement
or a change in state of one or more mouse buttons. The maximum rate at
which this data reporting may occur is known as the <I>sample
rate</I>. This parameter ranges from 10 samples/sec to 200
samples/sec. Its default value is 100 samples/sec and the host may
change
that value by using the "Set Sample Rate" (0xF3) command. Stream
mode is the default mode of operation. </P>
<P><B>Remote Mode:</B> </P>
<P>In this mode, the mouse reads its inputs and updates its
counters/flags
at the current sampling rate, but it only notifies the host of
movement
(and change in button state) when that information is requested by the
host. The host does this by issuing the "Read Data" (0xEB) command.
After
receiveing this command, the mouse will send a movement data packet,
and
reset its movement counters. </P>
<P><B>Wrap Mode:</B> </P>
<P>This is an "echoing" mode in which every byte received by the mouse
is
sent back to the host. Even if the byte represents a valid command,
the
mouse will not respond to that command--it will only echo that byte
back
to the host. There are two exceptions to this: the "Reset" (0xFF)
command
and "Reset Wrap Mode" (0xEC) command. The mouse treats these as valid
commands and does not echo them back to the host. </P>
<P><B>Intellimouse Extensions:</B> </P>
<P>A popular extension to the standard PS/2 mouse is the Microsoft
Intellimouse. This includes support for a total of five mouse
buttons and three axises of movement (right-left, up-down, and a
scrolling
wheel). These additional features require the use of a 4-byte
movement data packet rather than the standard 3-byte packet.
Since
standard PS/2 mouse drivers cannot recognize this packet format, the
Microsoft Intellimouse is required to operate exactly like a standard
PS/2
mouse unless it knows the drivers support the extended packet
format. This way, if a Microsoft Intellimouse is used on a
computer
which only supports the standard PS/2 mouse, the Microsoft
Intellimouse
will still function, except for its scrolling wheel and 4th and 5th
buttons. </P>
<P>The Microsoft Intellimouse operates just like a standard PS/2 mouse
(ie, it uses a 3-byte movement data packet, responds to all commands
in
the same way as a standard PS/2 mouse, and reports a device ID of
0x00.) To enter scrolling wheel mode, the host sends the
following
command sequence: </P>
<BLOCKQUOTE>Set sample rate 200 <BR>Set sample rate 100 <BR>Set sample
rate 80</BLOCKQUOTE>The host then issues the "Get device ID" command
(0xF2) and waits for a response. If a standard PS/2 mouse (ie,
non-Intellimouse) is attached, it will respond with a device ID of
0x00. In this case, the host will recognize the fact that the
mouse
does have a scrolling wheel and will continue to treat it as a standar
d
PS/2 mouse. However, if a Microsoft Intellimouse is attached, it
will respond with an ID of 0x03. This tells the host that the
attached pointing device has a scrolling wheel and the host will then
expect the mouse to use the following 4-byte movement data packet:
<BLOCKQUOTE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=650>
<TBODY>
<TR>
<TD><BR><FONT face=Arial,Helvetica><FONT size=-1>Byte
1 </FONT></FONT></TD>
<TD>
<TABLE border=0 cellPadding=0 cols=8 width="100%">
<TBODY>
<TR>
<TD>
<CENTER>Bit 7</CENTER></TD>
<TD>
<CENTER>Bit 6</CENTER></TD>
<TD>
<CENTER>Bit 5</CENTER></TD>
<TD>
<CENTER>Bit 4</CENTER></TD>
<TD>
<CENTER>Bit 3</CENTER></TD>
<TD>
<CENTER>Bit 2</CENTER></TD>
<TD>
<CENTER>Bit 1</CENTER></TD>
<TD>
<CENTER>Bit 0</CENTER></TD></TR></TBODY></TABLE>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=8
width="100%">
<TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Y
overflow</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>X
overflow</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Y sign
bit</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>X sign
bit</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Always
1</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Middle
Btn</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Right
Btn</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Left
Btn</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><FONT face=Arial,Helvetica><FONT size=-1>Byte
2</FONT></FONT></TD>
<TD>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=1
width="100%">
<TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>X
Movement</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><FONT face=Arial,Helvetica><FONT size=-1>Byte
3 </FONT></FONT></TD>
<TD>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=1
width="100%">
<TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Y
Movement</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><FONT face=Arial,Helvetica><FONT size=-1>Byte
4</FONT></FONT></TD>
<TD>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=1
width="100%">
<TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Z
Movement</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR></TBODY><
/TABLE>Z
Movement is a 2's complement number that represents the scrolling
wheel's movement since the last data report. Valid values are
in
the range of -8 to +7. This means the number is actually represented
only by the least significant four bits; the upper four bits act
only as
sign extension bits.</BLOCKQUOTE>To enter scrolling wheel + 5 button
mode,
the host sends the following command sequence:
<BLOCKQUOTE>Set sample rate 200 <BR>Set sample rate 200 <BR>Set sample
rate 80</BLOCKQUOTE>The host then issues the "Get device ID" command
(0xF2) and waits for a response. A Microsoft Intellimouse will
respond with a device ID of 0x04, then use the following 4-byte
movement
data packet:
<BLOCKQUOTE>
<BLOCKQUOTE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=650>
<TBODY>
<TR>
<TD><BR><FONT face=Arial,Helvetica><FONT size=-1>Byte
1 </FONT></FONT></TD>
<TD>
<TABLE border=0 cellPadding=0 cols=8 width="100%">
<TBODY>
<TR>
<TD>
<CENTER>Bit 7</CENTER></TD>
<TD>
<CENTER>Bit 6</CENTER></TD>
<TD>
<CENTER>Bit 5</CENTER></TD>
<TD>
<CENTER>Bit 4</CENTER></TD>
<TD>
<CENTER>Bit 3</CENTER></TD>
<TD>
<CENTER>Bit 2</CENTER></TD>
<TD>
<CENTER>Bit 1</CENTER></TD>
<TD>
<CENTER>Bit 0</CENTER></TD></TR></TBODY></TABLE>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=8
width="100%"><TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Y
overflow</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>X
overflow</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Y
sign
bit</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>X
sign
bit</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT
size=-1>Always
1</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT
size=-1>Middle
Btn</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Right
Btn</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Left
Btn</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><FONT face=Arial,Helvetica><FONT size=-1>Byte
2</FONT></FONT></TD>
<TD>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=1
width="100%"><TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>X
Movement</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><FONT face=Arial,Helvetica><FONT size=-1>Byte
3 </FONT></FONT></TD>
<TD>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=1
width="100%"><TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Y
Movement</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><FONT face=Arial,Helvetica><FONT size=-1>Byte
4</FONT></FONT></TD>
<TD>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=8
width="100%"><TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT
size=-1>Always
0</FONT></FONT></CENTER></TD>
<TD>
<CENTER>Always 0</CENTER></TD>
<TD>
<CENTER>5th Btn</CENTER></TD>
<TD>
<CENTER>4th Btn</CENTER></TD>
<TD>
<CENTER>Z3</CENTER></TD>
<TD>
<CENTER>Z2</CENTER></TD>
<TD>
<CENTER>Z1</CENTER></TD>
<TD>
<CENTER>Z0</CENTER></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>Z0-Z3
is a 2's complement number which represents the amount of movement
that has occurred since the last data report. Valid values
range
from -8 to +7. <BR>4th Btn: 1 = 4th mouse button is pressed; 0 =
4th
mouse button is not pressed. <BR>5th Btn: 1 = 5th mouse button is
pressed; 0 = 5th mouse button is not
pressed.</BLOCKQUOTE></BLOCKQUOTE>You
may have seen mice with two scrolling wheels--one vertical and the
other
horizontal. These mice use the Microsoft Intellimouse data
packet
format as described above. If the vertical wheel is scrolled
upward,
the Z-counter is incremented by one and if that wheel is scrolled
down,
the Z-counter is decremented by one. This is normal operation
for a
scrolling wheel. However, if the <I>horizontal</I> wheel is
scrolled
right, the Z-counter is incremented by <I>two</I> and if it is
scrolled
left, the Z-counter is decremented by <I>two</I>. This seems
like an
odd way to implement the second scrolling wheel, but it works since
the
placement of the two wheels make it impossible to use both of them at
the
same time (and if you try to trick the software and use both at the
same
time, it will ignore the horizontal wheel.)
<P><B>Command Set:</B> </P>
<P>The following are the only commands that may be sent to the
mouse... If
the mouse is in Stream mode, the host should disable data reporting
(command 0xF5) before sending any other commands... </P>
<UL>
<LI>0xFF (Reset) - The mouse responds to this command with
"acknowledge"
(0xFA) then enters Reset Mode.
<LI>0xFE (Resend) - The host sends this command whenever it receives
invalid data from the mouse. The mouse responds by resending the
last<A
href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/mouse/mouse.html#Foo
tnotes">(2)</A>
packet<A
href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/mouse/mouse.html#Foo
tnotes">(3)</A>
it sent to the host. If the mouse responds to the
"Resend"
command with another invalid packet, the host may either issue
another
"Resend" command, issue an "Error" command, cycle the mouse's power
supply to reset the mouse, or it may inhibit communication (by
bringing
the Clock line low). The action taken depends on the host.
<LI>0xF6 (Set Defaults) - The mouse responds with "acknowledge"
(0xFA)
then loads the following values: Sampling rate = 100,
Resolution =
4 counts/mm, Scaling = 1:1, Disable Data Reporting. The mouse
then
resets its movement counters and enters stream mode.
<LI>0xF5 (Disable Data Reporting) - The mouse responds with
"acknowledge" (0xFA) then disables data reporting and resets its
movement counters. This only effects data reporting in Stream
mode
and does not disable sampling. Disabled stream mode funcions
the
same as remote mode.
<LI>0xF4 (Enable Data Reporting) - The mouse responds with
"acknowledge"
(0xFA) then enables data reporting and resets its movement
counters. This command may be issued while the mouse is in
Remote
Mode (or Stream mode), but it will only effect data reporting in
Stream
mode.
<LI>0xF3 (Set Sample Rate) - The mouse responds with "acknowledge"
(0xFA) then reads one more byte from the host. The mouse saves
this byte as the new sample rate. After receiving the sample rate,
the
mouse again responds with "acknowledge" (0xFA) and resets its
movement
counters. Valid sample rates are 10, 20, 40, 60, 80, 100, and
200
samples/sec.
<LI>0xF2 (Get Device ID) - The mouse responds with "acknowledge"
(0xFA)
followed by its device ID (0x00 for the standard PS/2 mouse.)
The
mouse should also reset its movement counters.
<LI>0xF0 (Set Remote Mode) - The mouse responds with "acknowledge"
(0xFA) then resets its movement counters and enters remote mode.
<LI>0xEE (Set Wrap Mode) - The mouse responds with "acknowledge"
(0xFA)
then resets its movement counters and enters wrap mode.
<LI>0xEC (Reset Wrap Mode) - The mouse responds with "acknowledge"
(0xFA) then resets its movement counters and enters the mode it was
in
prior to wrap mode (Stream Mode or Remote Mode.)
<LI>0xEB (Read Data) - The mouse responds with acknowledge (0xFA)
then
sends a movement data packet. This is the only way to read data in
Remote Mode. After the data packets has been successfully
sent, it
resets its movement counters.
<LI>0xEA (Set Stream Mode) - The mouse responds with "acknowledge"
then
resets its movement counters and enters steram mode.
<LI>0xE9 (Status Request) - The mouse responds with "acknowledge"
then
sends the following 3-byte status packet (then resets its movement
counters.):
<UL>
<LI>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=650>
<TBODY>
<TR>
<TD><BR><FONT face=Arial,Helvetica><FONT size=-1>Byte
1 </FONT></FONT></TD>
<TD>
<TABLE border=0 cellPadding=0 cols=8 width="100%">
<TBODY>
<TR>
<TD>
<CENTER>Bit 7</CENTER></TD>
<TD>
<CENTER>Bit 6</CENTER></TD>
<TD>
<CENTER>Bit 5</CENTER></TD>
<TD>
<CENTER>Bit 4</CENTER></TD>
<TD>
<CENTER>Bit 3</CENTER></TD>
<TD>
<CENTER>Bit 2</CENTER></TD>
<TD>
<CENTER>Bit 1</CENTER></TD>
<TD>
<CENTER>Bit 0</CENTER></TD></TR></TBODY></TABLE>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=8
width="100%"><TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT
size=-1>Always
0</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT
size=-1>Mode</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT
size=-1>Enable</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT
size=-1>Scaling</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT
size=-1>Always
0</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Left
Btn</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT
size=-1>Middle
Btn</FONT></FONT></CENTER></TD>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT size=-1>Right
Btn</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><FONT face=Arial,Helvetica><FONT size=-1>Byte
2</FONT></FONT></TD>
<TD>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=1
width="100%"><TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT
size=-1>Resolution</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR
<TR>
<TD><FONT face=Arial,Helvetica><FONT size=-1>Byte
3 </FONT></FONT></TD>
<TD>
<TABLE border=1 cellPadding=0 cellSpacing=0 cols=1
width="100%"><TBODY>
<TR>
<TD>
<CENTER><FONT face=Arial,Helvetica><FONT
size=-1>Sample
Rate</FONT></FONT></CENTER></TD></TR></TBODY></TABLE></TD></TR></TBODY></TAB
LE>
<P><I>Right, Middle, Left Btn</I> = 1 if button pressed; 0 if
button
is not pressed. <BR><I>Scaling</I> = 1 if scaling is 2:1; 0 if
scaling
is 1:1. (See commands 0xE7 and 0xE6) <BR><I>Enable</I> = 1 if data
reporting is enabled; 0 if data reporting is disabled. (See
commands
0xF5 and 0xF4) <BR><I>Mode</I> = 1 if Remote Mode is enabled; 0 if
Stream mode is enabled. (See commands 0xF0 and 0xEA)
<BR> </P></LI></UL>
<LI>0xE8 (Set Resolution) - The mouse responds with acknowledge
(0xFA)
then reads one byte from the host and again responds with
acknowledge
(0xFA) then resets its movement counters. The byte read from
the
host determines the resolution as follows: <BR>
<CENTER>
<TABLE border=1 width=300>
<TBODY>
<TR>
<TD>
<CENTER>Byte Read from Host</CENTER></TD>
<TD>
<CENTER>Resolution</CENTER></TD></TR>
<TR>
<TD>
<CENTER>0x00</CENTER></TD>
<TD>
<CENTER>1 count/mm</CENTER></TD></TR>
<TR>
<TD>
<CENTER>0x01</CENTER></TD>
<TD>
<CENTER>2 count/mm</CENTER></TD></TR>
<TR>
<TD>
<CENTER>0x02</CENTER></TD>
<TD>
<CENTER>4 count/mm</CENTER></TD></TR>
<TR>
<TD>
<CENTER>0x03</CENTER></TD>
<TD>
<CENTER>8
count/mm</CENTER></TD></TR></TBODY></TABLE></CENTER></LI></UL>
<UL>
<LI>0xE7 (Set Scaling 2:1) - The mouse responds with acknowledge
(0xFA)
then enables 2:1 scaling (discussed earlier in this document.)
<LI>0xE6 (Set Scaling 1:1) - The mouse responds with acknowledge
(0xFA)
then enables 1:1 scaling (discussed earlier in this document.)
</LI></UL>The only commands the standard PS/2 mouse will send to the
host
are the "Resend" (0xFE) and "Error" (0xFC) commands. They both
work
the same as they do as host-to-device commands.
<P><B>Initialization:</B> </P>
<P>The PS/2 mouse is normally detected/initialized only when the
computer
is booting up. That is, the mouse is not hot-pluggable and you
must
restart your computer whenever you add/remove a PS/2 mouse
(furthermore,
some motherboards may be damaged if you add/remove a PS/2 mouse while
the
computer is running.) </P>
<P>The initial detection of the PS/2 mouse occurrs during POST.
If a
mouse is detected, the BIOS will allow the operating system to
configure/enable the mouse. Otherwise, it will inhibit
communication
on the mouse's bus. If you boot the computer with a mouse
attached,
then detach/reattach the mouse while in Windows, the OS <I>may</I> be
able
to detect the mouse was reattached. Microsoft tried to support
this,
but it only works about 50% of the time. </P>
<P>The following is the communication between my computer (running
Win98SE) and mouse when it boots up with a standard PS/2 mouse
attached. It is fairly typical of how a PS/2 mouse is
initialized
and if you want to emulate a PS/2 mouse it must (at minimum) be able
to
support the following sequence of commands... </P>
<UL>
<LI><TT>Power-on Reset:</TT> <BR><TT>Mouse: AA Self-test
passed</TT> <BR><TT>Mouse: 00 Mouse ID</TT>
<BR><TT>Host:
FF Reset command</TT> <BR><TT>Mouse: FA Acknowledge</TT>
<BR><TT>Mouse: AA Self-test passed</TT> <BR><TT>Mouse:
00
Mouse ID</TT> <BR><TT>Host: FF Reset command</TT>
<BR><TT>Mouse: FA Acknowledge</TT> <BR><TT>Mouse: AA
Self-test passed</TT> <BR><TT>Mouse: 00 Mouse ID</TT>
<BR><TT>Host: FF Reset command</TT> <BR><TT>Mouse:
FA
Acknowledge</TT> <BR><TT>Mouse: AA Self-test passed</TT>
<BR><TT>Mouse: 00 Mouse ID</TT> <BR><TT>Host: F3
Set
Sample Rate : Attempt to Enter Microsoft</TT>
<BR><TT>Mouse:
FA Acknowledge : Scrolling
Mouse mode</TT> <BR><TT>Host: C8 decimal
200 :</TT> <BR><TT>Mouse:
FA
Acknowledge :</TT>
<BR><TT>Host: F3 Set Sample Rate :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Host: 64 decimal
100 :</TT> <BR><TT>Mouse:
FA
Acknowledge :</TT>
<BR><TT>Host: F3 Set Sample Rate :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Host: 50 decimal
80 :</TT> <BR><TT>Mouse:
FA Acknowledge :</TT>
<BR><TT>Host: F2 Read Device Type :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Mouse: 00 Mouse
ID : Response
03
if microsoft scrolling mouse</TT> <BR><TT>Host: F3 Set
Sample Rate </TT> <BR><TT>Mouse: FA Acknowledge</TT>
<BR><TT>Host: 0A decimal 10</TT> <BR><TT>Mouse: FA
Acknowledge</TT> <BR><TT>Host: F2 Read Device Type</TT>
<BR><TT>Mouse: FA Acknowledge</TT> <BR><TT>Mouse: 00
Mouse
ID</TT> <BR><TT>Host: E8 Set resolution</TT>
<BR><TT>Mouse:
FA Acknowledge</TT> <BR><TT>Host: 03 8
Counts/mm</TT>
<BR><TT>Mouse: FA Acknowledge</TT> <BR><TT>Host:
E6
Set Scaling 1:1</TT> <BR><TT>Mouse: FA Acknowledge</TT>
<BR><TT>Host: F3 Set Sample Rate</TT> <BR><TT>Mouse:
FA Acknowledge</TT> <BR><TT>Host: 28 decimal
40</TT>
<BR><TT>Mouse: FA Acknowledge</TT> <BR><TT>Host:
F4
Enable</TT> <BR><TT>Mouse: FA Acknowledge</TT>
<BR><TT>Initialization complete...</TT>
<P><TT>If I then press the Left Button...</TT> <BR><TT>Mouse: 09 1 1
00001001; bit0 = Left button state; bit3 = always 1</TT>
<BR><TT>Mouse:
00 1 1 No X-movement</TT> <BR><TT>Mouse: 00 1 1 No Y-movement</TT>
<BR><TT>... and release the Left Button:</TT> <BR><TT>Mouse: 08 0 1
00001000 bit0 = Left button state; bit3 = always 1</TT>
<BR><TT>Mouse:
00 1 1 No X-movement</TT> <BR><TT>Mouse: 00 1 1 No
Y-movement</TT></P></LI></UL>The following is the communication
between my
computer (running Win98SE) and mouse when it boots up with an
(emulated)
Intellimouse...
<UL>
<LI><TT>Power-on Reset:</TT> <BR><TT>Mouse: AA Self-test
passed</TT> <BR><TT>Mouse: 00 Mouse ID</TT>
<BR><TT>Host:
FF Reset command</TT> <BR><TT>Mouse: FA Acknowledge</TT>
<BR><TT>Mouse: AA Self-test passed</TT> <BR><TT>Mouse:
00
Mouse ID</TT> <BR><TT>Host: FF Reset command</TT>
<BR><TT>Mouse: FA Acknowledge</TT> <BR><TT>Mouse: AA
Self-test passed</TT> <BR><TT>Mouse: 00 Mouse ID</TT>
<BR><TT>Host: FF Reset command</TT> <BR><TT>Mouse:
FA
Acknowledge</TT> <BR><TT>Mouse: AA Self-test passed</TT>
<BR><TT>Mouse: 00 Mouse ID</TT> <BR><TT>Host: F3
Set
Sample Rate : Attempt to Enter Microsoft </TT>
<BR><TT>Mouse: FA
Acknowledge
: Scrolling Mouse mode</TT> <BR><TT>Host: C8 decimal
200 :</TT> <BR><TT>Mouse:
FA
Acknowledge :</TT>
<BR><TT>Host: F3 Set Sample Rate :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Host: 64 decimal
100 :</TT> <BR><TT>Mouse:
FA
Acknowledge :</TT>
<BR><TT>Host: F3 Set Sample Rate :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Host: 50 decimal
80 :</TT> <BR><TT>Mouse:
FA Acknowledge :</TT>
<BR><TT>Host: F2 Read Device Type :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Mouse: 03 Mouse
ID : Response
03
if microsoft scrolling mouse</TT> <BR><TT>Host: E8 Set
Resolution </TT> <BR><TT>Mouse: FA Acknowledge </TT>
<BR><TT>Host: 03 8 counts/mm</TT> <BR><TT>Mouse:
FA
Acknowledge</TT> <BR><TT>Host: E6 Set scaling 1:1</TT>
<BR><TT>Dev: FA Acknowledge</TT>
<BR><TT>Host:
F3 Set Sample Rate </TT> <BR><TT>Mouse: FA
Acknowledge</TT> <BR><TT>Host: 28 decimal 40</TT>
<BR><TT>Mouse: FA Acknowledge</TT> <BR><TT>Host:
F4
Enable device </TT> <BR><TT>Mouse: FA Acknowledge</TT>
<P><TT>If I then press the left mouse button:</TT> <BR><TT>Mouse:
09 00001001 bit0 = Left button state; bit3 = always 1</TT>
<BR><TT>Mouse: 00 No X-movement</TT> <BR><TT>Mouse: 00
No
Y-movement</TT> <BR><TT>Mouse: 00 No Z-movement</TT> </P>
<P><TT>...and then release the left mouse button button:</TT>
<BR><TT>Mouse: 08 00001000 bit0 = Left button state; bit3 =
always
1</TT> <BR><TT>Mouse: 00 No X-movement</TT> <BR><TT>Mouse:
00 No Y-movement</TT> <BR><TT>Mouse: 00 No
Z-movement</TT></P></LI></UL><TT>After I downloaded/installed the
Microsoft's Intellimouse drivers with support for the 4th and 5th
buttons,
the following sequence was found:</TT>
<BLOCKQUOTE><TT>... (starts same as before) ...</TT>
<BR><TT>Host:
F3 Set Sample Rate : Attempt to Enter
Microsoft </TT> <BR><TT>Mouse: FA
Acknowledge : Scrolling Mouse
mode.</TT> <BR><TT>Host: C8 decimal
200 :</TT> <BR><TT>Mouse:
FA
Acknowledge :</TT>
<BR><TT>Host: F3 Set Sample Rate :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Host: 64 decimal
100 :</TT> <BR><TT>Mouse:
FA
Acknowledge :</TT>
<BR><TT>Host: F3 Set Sample Rate :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Host: 50 decimal
80 :</TT> <BR><TT>Mouse:
FA Acknowledge :</TT>
<BR><TT>Host: F2 Read Device Type :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Mouse: 03 Mouse
ID : Response
03
if microsoft scrolling mouse.</TT> <BR><TT>Host: F3 Set
Sample Rate : Attempt to Enter Microsoft
5-button </TT>
<BR><TT>Mouse: FA
Acknowledge
: Scrolling Mouse mode.</TT> <BR><TT>Host: C8 decimal
200 :</TT> <BR><TT>Mouse:
FA
Acknowledge :</TT>
<BR><TT>Host: F3 Set Sample Rate :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Host: C8 decimal
200 :</TT> <BR><TT>Mouse:
FA
Acknowledge :</TT>
<BR><TT>Host: F3 Set Sample Rate :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Host: 50 decimal
80 :</TT> <BR><TT>Mouse:
FA Acknowledge :</TT>
<BR><TT>Host: F2 Read Device Type :</TT>
<BR><TT>Mouse: FA
Acknowledge
:</TT> <BR><TT>Mouse: 04 Mouse
ID : Response 04 if
5-button scrolling mouse.</TT> <BR><TT>... rest of initialization
same
as before ...</TT></BLOCKQUOTE><B>Emulation/Interfacing:</B>
<UL>
<LI>Click <A
href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/code/ps2/Device.html
">here</A>
for routines that emulate a PS/2 mouse or keyboard
<LI>Click <A
href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/code/ps2/Host.html">
here</A>
for routines that emulate a PS/2 host (ie, interface a
mouse/keyboard)
<LI>Click <A
href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/code/Projects/mouse/
ps2mouse.html">here</A>
for a fully-functional PS/2 mouse written for the PIC16F84.
</LI></UL>If
you want to build a truely fully-implemented mouse or host, you should
implement all of the features described in this document (except for,
of
course, the Microsoft Intellimouse extensions, which are
optional).
However, at an absolute minimum, your device should operate as
follows:
<BLOCKQUOTE>To Emulate a Mouse:
<UL>
<LI>Never send data when the "Clock" line low. If the
host
pulls the "Data" line low, prepare to read a byte from the host.
<LI>~500 milliseconds after powerup, transmit "0xAA, 0x00".
<LI>Wait for the host to send the enable (0xF4) command before
sending
any movement/button data.
<LI>Emulate the various mouse functions as follows:
<TABLE border=1 cellSpacing=0 width=500>
<TBODY>
<TR>
<TD>
<CENTER><B>Emulated Action</B></CENTER></TD>
<TD>
<CENTER><B>Data sent to host</B></CENTER></TD></TR>
<TR>
<TD>
<CENTER>Move up one</CENTER></TD>
<TD>
<CENTER>0x08,0x00,0x01</CENTER></TD></TR>
<TR>
<TD>
<CENTER>Move down one</CENTER></TD>
<TD>
<CENTER>0x28,0x00,0xFF</CENTER></TD></TR>
<TR>
<TD>
<CENTER>Move right one</CENTER></TD>
<TD>
<CENTER>0x08,0x01,0x00</CENTER></TD></TR>
<TR>
<TD>
<CENTER>Move left one</CENTER></TD>
<TD>
<CENTER>0x18,0xFF,0x00</CENTER></TD></TR>
<TR>
<TD>
<CENTER>Press left button</CENTER></TD>
<TD>
<CENTER>0x09,0x00,0x00</CENTER></TD></TR>
<TR>
<TD>
<CENTER>Release left button</CENTER></TD>
<TD>
<CENTER>0x08,0x00,0x00</CENTER></TD></TR>
<TR>
<TD>
<CENTER>Press middle button</CENTER></TD>
<TD>
<CENTER>0x0C,0x00,0x00</CENTER></TD></TR>
<TR>
<TD>
<CENTER>Release middle button</CENTER></TD>
<TD>
<CENTER>0x08,0x00,0x00</CENTER></TD></TR>
<TR>
<TD>
<CENTER>Press right button</CENTER></TD>
<TD>
<CENTER>0x0A,0x00,0x00</CENTER></TD></TR>
<TR>
<TD>
<CENTER>Release right button</CENTER></TD>
<TD>
<CENTER>0x08,0x00,0x00</CENTER></TD></TR></TBODY></TABLE>
<LI>Respond to the "Reset" (0xFF) command with "0xFA" then goto
the
beginning of your program. (ie, send 0xAA, 0x00, then wait for the
enable command before sending any movement/button data.)
<LI>Respond to the "Get Device ID" (0xF2) command with "0xFA,
0x00".
<LI>Respond to the "Status Request" (0xE9) command with "0xFA,
0x00,
0x02, 0x64".
<LI>Respond to all other commands with acknowledge (0xFA).
</LI></UL>To
Interface a Mouse:
<UL>
<LI>Wait for the mouse to send "0xAA", then send the "Enable"
(0xF4)
command.
<LI>The mouse will then send a 3-byte movement packets as
described
earlier in this document. </LI></UL></BLOCKQUOTE>
<P><BR><A name=Footnotes></A><B>Footnotes:</B> </P>
<BLOCKQUOTE>1) 2:1 scaling only applies to the automatic data
reporting
in Stream mode. It does not effect the reported data sent in
response to
the "Read Data" (0xEB) command.
<P>2) The mouse and host do not buffer "Resend" (0xFF)
commands.
This means "0xFE" will never be sent in response to the "Resend"
command. </P>
<P>3) A "packet" may be a 3-byte movement data packet, a
4-byte movement data packet (for the Intellimouse), a 3-byte status
packet (see "Status Request" [0xE9] command) a 2-byte
completion-code-ID
packet (0xAA,0x00 or 0xFC,0x00), or a 1-byte response to a command.
</P>
<P>4) A little advice from my own experience... Even
though
bit 3 of the first byte in a movement data packet is supposed to be
set,
some drivers (such as the standard PS/2 mouse driver included with
Windows 98SE) don't care and just ignore that bit. However,
other
drivers do check that bit and if it is not set, it is considered an
error. I mention this so that, if you're designing a mouse,
you
double-check that this bit is set in every movement data packet sent
by
your mouse. If it is not, your mouse may work properly when
you
test it on your computer, but it may not work on other computers
that
use different mouse drivers. </P>
<P>For example, if using MS Intellimouse drivers and bit 3 of the
first
byte in a movement data packet is not set, the driver will discard
that
packet, then send the "Disable Data Reporting" (0xF5) command,
followed by the "Set Defaults" (0xF6) command, then it will
reinitialize
the mouse using the same command sequence as it does when Windows
boots
up (see the "Initialization" section
above.)</P></BLOCKQUOTE><B>Other
Sources / References:</B>
<UL>
<LI><A
href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/">Adam's
micro-Resources Home</A> - This site's homepage.
<LI><A
href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/PS2/ps2.htm">PS/2
Mouse/Keyboard Protocol</A> - Protocol used by AT and PS/2
keyboards.
<LI><A
href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/code/code.html">Mous
e
Code/Projects</A> - My mouse projects and source code. </LI></UL>
<UL>
<LI><A href="http://www.holtek.com/products/computer/">Holtek</A> -
Informative datasheets on many different PS/2 mice (and other
peripherals).
<LI><A href="http://www.emc.com.tw/product/p_pc_mc.asp">EMC</A> -
More
inormative datasheets on many different PS/2 mice (and an ADB
mouse).
<LI><A
href="http://www.synaptics.com/decaf/utilities/tp-intf2-4.PDF">Synaptics
Touchpad Interfacing Guide</A> -Very informative! </LI></UL>
<UL>
<LI><A href="http://panda.cs.ndsu.nodak.edu/~achapwes/">Adam
Chapweske's
Homepage</A> - Information about me.
<LI><A href="mailto:achapwes@xxxxxxxxxxxxxxxxxxxxxxx">Email me</A> -
Questions/comments? </LI></UL>
<UL></UL></TD></TR></TBODY></TABLE>
<P><BR></P><BR></BODY></HTML>
;___
;EOF
.
- Follow-Ups:
- Re: SmallC
- From: Dirk Wolfgang Glomp
- Re: SmallC
- References:
- Re: SmallC
- From: Alexei A. Frounze
- Re: SmallC
- From: s_dubrovich
- Re: SmallC
- From: Alexei A. Frounze
- Re: SmallC
- From: Rod Pemberton
- Re: SmallC
- From: Rod Pemberton
- Re: SmallC
- From: s_dubrovich
- Re: SmallC
- From: Dirk Wolfgang Glomp
- Re: SmallC
- From: Wolfgang Kern
- Re: SmallC
- From: Dirk Wolfgang Glomp
- Re: SmallC
- Prev by Date: Re: how to access struct member of pointer
- Next by Date: Re: how to access struct member of pointer
- Previous by thread: Re: SmallC
- Next by thread: Re: SmallC
- Index(es):