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

📄 ps-2 mouse interfacing.htm

📁 关于PS/2和USB键盘、鼠标的各种扫描码的资料。
💻 HTM
📖 第 1 页 / 共 4 页
字号:
        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...&nbsp; 
      <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&nbsp;</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: 03&nbsp; Mouse 
        ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Response 03 
        if microsoft scrolling mouse</TT> <BR><TT>Host:&nbsp; E8&nbsp; Set 
        Resolution&nbsp;</TT> <BR><TT>Mouse: FA&nbsp; Acknowledge&nbsp;</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>Dev:&nbsp;&nbsp; FA&nbsp; Acknowledge</TT> <BR><TT>Host:&nbsp; 
        F3&nbsp; Set Sample Rate&nbsp;</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 device&nbsp;</TT> <BR><TT>Mouse: FA&nbsp; Acknowledge</TT> 
        <P><TT>If I then press the left mouse button:</TT> <BR><TT>Mouse: 
        09&nbsp; 00001001 bit0 = Left button state; bit3 = always 1</TT> 
        <BR><TT>Mouse: 00&nbsp; No X-movement</TT> <BR><TT>Mouse: 00&nbsp; No 
        Y-movement</TT> <BR><TT>Mouse: 00&nbsp; No Z-movement</TT> </P>
        <P><TT>...and then release the left mouse button button:</TT> 
        <BR><TT>Mouse: 08&nbsp; 00001000 bit0 = Left button state; bit3 = always 
        1</TT> <BR><TT>Mouse: 00&nbsp; No X-movement</TT> <BR><TT>Mouse: 
        00&nbsp; No Y-movement</TT> <BR><TT>Mouse: 00&nbsp; 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:&nbsp; 
        F3&nbsp; Set Sample Rate&nbsp;&nbsp; : Attempt to Enter 
        Microsoft&nbsp;</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: 03&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;&nbsp; : Attempt to Enter Microsoft 5-button&nbsp;</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; 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; 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: 04&nbsp; Mouse 
        ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 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).&nbsp; 
      However, at an absolute minimum, your device should operate as follows: 
      <BLOCKQUOTE>To Emulate a Mouse: 
        <UL>
          <LI>Never send data when&nbsp; the "Clock" line low.&nbsp; 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)&nbsp; The mouse and host do not buffer "Resend" (0xFF) commands. 
        This means "0xFE" will never be sent in response to the "Resend" 
        command.&nbsp; </P>
        <P>3)&nbsp;&nbsp; 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)&nbsp; A little advice from my own experience...&nbsp; 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.&nbsp; However, other 
        drivers do check that bit and if it is not set, it is considered an 
        error.&nbsp; 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.&nbsp; 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.&nbsp; </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"&nbsp; (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 + -