⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ps-2 mouse interfacing.htm

📁 PS2 mouse very good info
💻 HTM
📖 第 1 页 / 共 4 页
字号:
          <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. 
<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.&nbsp; There are four standard modes of operation:&nbsp; </P>
<UL>
  <LI><I>Reset</I> - The mouse enters Reset mode at power-up or after receiving 
  the "Reset" (0xFF) command.&nbsp; 
  <LI><I>Stream</I> - This is the default mode (after Reset finishes executing) 
  and is the mode in which most software uses the mouse.&nbsp; 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.&nbsp; 
  <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.&nbsp; 
  <LI><I>Wrap</I> - This mode isn't particularly useful except for testing the 
  connection between the mouse and its host.&nbsp; Wrap mode may be entered by 
  sending the "Set Wrap Mode" (0xEE) command to the mouse.&nbsp; To exit Wrap 
  mode, the host must issue the "Reset" (0xFF) command or "Reset Wrap Mode" 
  (0xEC) command.&nbsp; If the "Reset" (0xFF) command is recieved, the mouse 
  will enter Reset mode.&nbsp; 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.&nbsp; 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 following 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 AAh (BAT successful) or FCh (Error). The host's response to a completion 
code other than AAh is undefined. 
<P>Following the BAT completion code (AAh or FCh), the mouse sends its device ID 
of 00h. 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.&nbsp; However I've found that some BIOS's 
will send the "Reset" 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.&nbsp; Note that one of the default values set by the mouse is "Data 
Reporting Disabled".&nbsp; This means the mouse will not issue any movement data 
packets until it receives the "Enable Data Reporting" command. </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>.&nbsp; 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" command.&nbsp; Stream mode is the default mode of operation following 
reset. </P>
<P><B>Remote Mode:</B> </P>
<P>In this mode the mouse reads its inputs and updates its counters/flags at the 
current sample rate, but it does not automatically issue data packets when 
movement has occured. &nbsp;Instead, the host must poll the mouse using the 
"Read Data" command. &nbsp;Upon receiving this command the mouse will send a 
single movement data packet and reset its movement counters.</P>
<P></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" command and "Reset Wrap Mode" 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.&nbsp; This includes support for a total of five mouse buttons and 
three axises of movement (right-left, up-down, and a scrolling wheel).&nbsp; 
These additional features require the use of a 4-byte movement data packet 
rather than the standard 3-byte packet.&nbsp; 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.&nbsp; 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>After power-on or reset 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 
00h.)&nbsp; 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 and waits for a 
response.&nbsp; If a standard PS/2 mouse (ie, non-Intellimouse) is attached, it 
will respond with a device ID of 00h.&nbsp; 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 standard PS/2 mouse.&nbsp; However, if a Microsoft Intellimouse 
is attached, it will respond with an ID of 03h.&nbsp; 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:&nbsp; 
<BLOCKQUOTE>
  <TABLE cellSpacing=0 cellPadding=0 width=650 border=0>
    <TBODY>
    <TR>
      <TD><BR><FONT face=Arial,Helvetica><FONT size=-1>Byte 
        1&nbsp;</FONT></FONT></TD>
      <TD>
        <TABLE cols=8 cellPadding=0 width="100%" border=0>
          <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 cellSpacing=0 cols=8 cellPadding=0 width="100%" border=1>
          <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 cellSpacing=0 cols=1 cellPadding=0 width="100%" border=1>
          <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&nbsp;</FONT></FONT></TD>
      <TD>
        <TABLE cellSpacing=0 cols=1 cellPadding=0 width="100%" border=1>
          <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 cellSpacing=0 cols=1 cellPadding=0 width="100%" border=1>
          <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.&nbsp; 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 and waits for a 
response.&nbsp; A Microsoft Intellimouse will respond with a device ID of 04h, 
then use the following 4-byte movement data packet: 
<BLOCKQUOTE>
  <BLOCKQUOTE>&nbsp; 
    <TABLE cellSpacing=0 cellPadding=0 width=650 border=0>
      <TBODY>
      <TR>
        <TD><BR><FONT face=Arial,Helvetica><FONT size=-1>Byte 
          1&nbsp;</FONT></FONT></TD>
        <TD>
          <TABLE cols=8 cellPadding=0 width="100%" border=0>
            <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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -