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

📄 ps-2 mouse interfacing.htm

📁 关于PS/2和USB键盘、鼠标的各种扫描码的资料。
💻 HTM
📖 第 1 页 / 共 4 页
字号:
      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>.&nbsp; 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#Footnotes">(2)</A> 
        packet<A 
        href="http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/mouse/mouse.html#Footnotes">(3)</A> 
        it sent to the host.&nbsp;&nbsp; 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).&nbsp; The action taken depends on the host. 
        <LI>0xF6 (Set Defaults) - The mouse responds with "acknowledge" (0xFA) 
        then loads the following values:&nbsp; Sampling rate = 100, Resolution = 
        4 counts/mm, Scaling = 1:1, Disable Data Reporting.&nbsp; 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.&nbsp; This only effects data reporting in Stream mode 
        and does not disable sampling.&nbsp; 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.&nbsp; 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.&nbsp; 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.&nbsp; 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.)&nbsp; 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&nbsp; 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.&nbsp; 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.):&nbsp; 
        <UL>
          <LI>&nbsp; 
          <TABLE border=0 cellPadding=0 cellSpacing=0 width=650>
            <TBODY>
            <TR>
              <TD><BR><FONT face=Arial,Helvetica><FONT size=-1>Byte 
                1&nbsp;</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&nbsp;</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></TABLE>
          <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>&nbsp;</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.&nbsp; The byte read from the 
        host determines the resolution as follows:&nbsp; <BR>&nbsp; 
        <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.&nbsp; They both work 
      the same as they do as host-to-device commands.&nbsp; 
      <P><B>Initialization:</B> </P>
      <P>The PS/2 mouse is normally detected/initialized only when the computer 
      is booting up.&nbsp; 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.&nbsp; If a 
      mouse is detected, the BIOS will allow the operating system to 
      configure/enable the mouse.&nbsp; Otherwise, it will inhibit communication 
      on the mouse's bus.&nbsp; 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.&nbsp; 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.&nbsp; 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...&nbsp; </P>
      <UL>
        <LI><TT>Power-on Reset:</TT> <BR><TT>Mouse: AA&nbsp; Self-test 
        passed</TT> <BR><TT>Mouse: 00&nbsp; Mouse ID</TT> <BR><TT>Host:&nbsp; 
        FF&nbsp; Reset command</TT> <BR><TT>Mouse: FA&nbsp; Acknowledge</TT> 
        <BR><TT>Mouse: AA&nbsp; Self-test passed</TT> <BR><TT>Mouse: 00&nbsp; 
        Mouse ID</TT> <BR><TT>Host:&nbsp; FF&nbsp; Reset command</TT> 
        <BR><TT>Mouse: FA&nbsp; Acknowledge</TT> <BR><TT>Mouse: AA&nbsp; 
        Self-test passed</TT> <BR><TT>Mouse: 00&nbsp; Mouse ID</TT> 
        <BR><TT>Host:&nbsp; FF&nbsp; Reset command</TT> <BR><TT>Mouse: FA&nbsp; 
        Acknowledge</TT> <BR><TT>Mouse: AA&nbsp; Self-test passed</TT> 
        <BR><TT>Mouse: 00&nbsp; Mouse ID</TT> <BR><TT>Host:&nbsp; F3&nbsp; Set 
        Sample Rate&nbsp;&nbsp; : Attempt to Enter Microsoft</TT> <BR><TT>Mouse: 
        FA&nbsp; Acknowledge&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Scrolling 
        Mouse mode</TT> <BR><TT>Host:&nbsp; C8&nbsp; decimal 
        200&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :</TT> <BR><TT>Mouse: FA&nbsp; 
        Acknowledge&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :</TT> 
        <BR><TT>Host:&nbsp; F3&nbsp; Set Sample Rate&nbsp;&nbsp; :</TT> 
        <BR><TT>Mouse: FA&nbsp; Acknowledge&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        :</TT> <BR><TT>Host:&nbsp; 64&nbsp; decimal 
        100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :</TT> <BR><TT>Mouse: FA&nbsp; 
        Acknowledge&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :</TT> 
        <BR><TT>Host:&nbsp; F3&nbsp; Set Sample Rate&nbsp;&nbsp; :</TT> 
        <BR><TT>Mouse: FA&nbsp; Acknowledge&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        :</TT> <BR><TT>Host:&nbsp; 50&nbsp; decimal 
        80&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :</TT> <BR><TT>Mouse: 
        FA&nbsp; Acknowledge&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :</TT> 
        <BR><TT>Host:&nbsp; F2&nbsp; Read Device Type&nbsp; :</TT> 
        <BR><TT>Mouse: FA&nbsp; Acknowledge&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        :</TT> <BR><TT>Mouse: 00&nbsp; Mouse 
        ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Response 03 
        if microsoft scrolling mouse</TT> <BR><TT>Host:&nbsp; F3&nbsp; Set 
        Sample Rate&nbsp;</TT> <BR><TT>Mouse: FA&nbsp; Acknowledge</TT> 
        <BR><TT>Host:&nbsp; 0A&nbsp; decimal 10</TT> <BR><TT>Mouse: FA&nbsp; 
        Acknowledge</TT> <BR><TT>Host:&nbsp; F2&nbsp; Read Device Type</TT> 
        <BR><TT>Mouse: FA&nbsp; Acknowledge</TT> <BR><TT>Mouse: 00&nbsp; Mouse 
        ID</TT> <BR><TT>Host:&nbsp; E8&nbsp; Set resolution</TT> <BR><TT>Mouse: 
        FA&nbsp; Acknowledge</TT> <BR><TT>Host:&nbsp; 03&nbsp; 8 Counts/mm</TT> 
        <BR><TT>Mouse: FA&nbsp; Acknowledge</TT> <BR><TT>Host:&nbsp; E6&nbsp; 
        Set Scaling 1:1</TT> <BR><TT>Mouse: FA&nbsp; Acknowledge</TT> 
        <BR><TT>Host:&nbsp; F3&nbsp; Set Sample Rate</TT> <BR><TT>Mouse: 
        FA&nbsp; Acknowledge</TT> <BR><TT>Host:&nbsp; 28&nbsp; decimal 40</TT> 
        <BR><TT>Mouse: FA&nbsp; Acknowledge</TT> <BR><TT>Host:&nbsp; F4&nbsp; 
        Enable</TT> <BR><TT>Mouse: FA&nbsp; 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: 

⌨️ 快捷键说明

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