📄 ps-2 mouse interfacing.htm
字号:
1 if Remote Mode is enabled; 0 if Stream mode is enabled. (See commands F0h
and EAh) <BR> </P></LI></UL>
<LI>E8h (Set Resolution) - The mouse responds with acknowledge (FAh) then
reads one byte from the host and again responds with acknowledge (FAh) then
resets its movement counters. The byte read from the host determines the
resolution as follows: <BR>
<CENTER>
<TABLE width=300 border=1>
<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>E7h (Set Scaling 2:1) - The mouse responds with acknowledge (FAh) then
enables 2:1 scaling (discussed earlier in this document.)
<LI>E6h (Set Scaling 1:1) - The mouse responds with acknowledge (FAh) 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" (FEh)
and "Error" (FCh). 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 here for routines that emulate a PS/2 mouse or keyboard
<LI>Click here 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 PIC16F </LI></UL>
<BLOCKQUOTE>
<UL></UL></BLOCKQUOTE>
<P><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" command.
<P>2) The mouse and host do not buffer "Resend" commands. This means
"Resend" 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" command) a 2-byte completion-code-ID packet (AAh,00h or
FCh,00h), or a 1-byte response to a
command.<BR></P></BLOCKQUOTE><BR><BR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -