📄 ps-2 mouse interfacing.htm
字号:
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">Mouse
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@panda.cs.ndsu.nodak.edu">Email me</A> -
Questions/comments? </LI></UL>
<UL></UL></TD></TR></TBODY></TABLE>
<P><BR></P><BR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -