PS/2 マウス/キーボード プロトコルとインターフェース 2005.12.24(土)〜 /
目次 1. PS/2 マウス/キーボード プロトコル 1.1. 原文の入手先 1.2. 翻訳について 1.3. 法律条項 1.4. 目的 1.5. 物理的なインターフェース: 1.6. 電気的なインターフェース: 1.7. 通信の一般事項 1.8. デバイスからホストへの通信 1.9. ホストからデバイスへの通信 2. PS/2 マウス インターフェース 2.1. 原文の入手先 2.2. 翻訳について 2.3. 法律条項 2.4. 目的 2.5. 概要 2.6. 電気インターフェース/プロトコル 2.7. 入力、解像度、比率 2.8. 移動データパケット 2.9. オペレーション・モード 2.9.1. リセット・モード 2.9.2. ストリーム・モード 2.9.3. リモート・モード 2.9.4. ラップ・モード 2.10. インテリマウスの拡張 2.11. コマンドセット 2.12. 初期化 2.13. 脚注 1. PS/2 マウス/キーボード プロトコル PS/2 Mouse/Keyboard Protocol (PS/2 は IBM Personal System/2 の略称です。) 1.1. 原文の入手先 URL: http://www.Computer-Engineering.org 著者: Adam Chapweske 最終更新: 05/09/03 Source: http://www.Computer-Engineering.org Author: Adam Chapweske Last Updated: 05/09/03 1.2. 翻訳について この資料は、PS/2の通信プロトコルを理解するために上記URLから英文を入手 し、翻訳サイトの多大な協力のもと、訳者の勝手な解釈により作成しました。 内容等で不明確な場合は上記URLの原文を参照して下さい。 この資料中の英語の原文部分は、訳文の誤記訂正が進んだしかる後に削除する 予定です。 目次と項番は、訳者の便宜の為に追加しました。 詳細な仕様を提供下さった著者に感謝します。 訳者: 中野 良知 最終更新日時: 2005/07/03 1.3. 法律条項 この資料により生じたいかなる障害や損害に対し、著者は全てを免責されるも のとします。 これには訳者も含みます。 この資料は、著作権法の下で保護され、入手先、著者、日付、法律条項を含ん だ場合にのみ複製が可能です。 これには訳者も含みます。 Legal Information: All information within this article is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantibility and fitness for a particular purpose. This article is protected under copyright law. This document may be copied only if the source, author, date, and legal information is included. 1.4. 目的 このドキュメントでは、PS/2マウス、PS/2キーボードおよびATキーボードが使 用するインターフェースについて記述します。 プロトコルと物理的・電気的なインターフェースをカバーします。 コマンド、データ・パケット・フォーマットあるいはキーボードかマウスに特 有の他のより高度な情報が必要ならば、下記の2つの装置のための個別のドキ ュメントがあります。 PS/2(AT)キーボード・インターフェース PS/2マウス・インターフェース Abstract: This document descibes the interface used by the PS/2 mouse, PS/2 keyboard, and AT keyboard. I'll cover the physical and electrical interface, as well as the protocol. If you need higher-level information, such as commands, data packet formats, or other information specific to the keyboard or mouse, I have written separate documents for the two devices: The PS/2 (AT) Keyboard Interface The PS/2 Mouse Interface 1.5. 物理的なインターフェース: 物理的なPS/2ポートには2種類のコネクターがあります。 5本のピンDINあるいは6本のピンミニDINです。 両コネクターは、完全に(電気 的に)類似しています。 唯一の実際的な違いはピンの配置です。 これは単純 なハードワイヤードのアダプターで容易に2つのタイプのコネクターを変換す ることができることを意味します。 これらは、各々約6ドルかかります。 任意の2つのコネクター上のピンを一致させる事で自作も可能です。 DIN標準は、German Standardization機構(Deutsches Institut fuer標準)によ り作成されました。 ウェブサイトは http://www.din.de です。 (ドイツのサイトですが、英語が利用出来ます。) PCキーボードは6本のピンミニDINあるいは5本のピンDINコネクターのいずれか を使用します。 キーボードが6本のピンミニDINを持っており、コンピュー ターが5本のピンDIN(あるいはビザversa)を持っている場合、2つは上に記述し たアダプターで互換性をもつことができます。 5本のピンDINを備えたものが 「AT」デバイスと呼ばれ、一方、6本のピンミニDINを備えたキーボードは 「PS/2」キーボードと呼ばれます。 PCに取り付ける最近のキーボードのの多 くはPS/2、ATあるいはUSBです。 このドキュメントではUSB装置ついては取 り扱いません。(USBは完全に異なるインタフェースです)。 (「XT」のキーボードも5本のピンDINを使用しましたが、旧型で長い間製造さ れていないと思われます。) マウスには多くの形やサイズ(またインターフェース。)があります。 最もポピュラーなタイプはPS/2マウスで、USBマウスも共に人気を得ています 。 わずか数年前まではシリアルマウスがポピュラーでしたが、コンピュー ター業界はPS/2とUSBのデバイスを支持し、シリアルマウスを採用しなくなり ました。 このドキュメントは、PS/2マウスを取り扱います。 シリアルマウスまたはUSBマウスに関する情報は、他のウェブサイトで入手し て下さい。 コンピューターにキーボード/マウスを接続するケーブルは、通常長さ約6フィ ートで、薄い箔でシールドされた4〜6本のAWG26の導線から出来ています。 より長いケーブルが必要ならば、PS/2延長ケーブルを買うことができます。 延長ケーブルは多数接続するべきではありません。 30フィートのキーボード ・ケーブルを必要とする場合は、30フィートのキーボード・ケーブルを買って ください。 6フィートのケーブルを5本接続することは、キーボード/マウスと ホスト間の通信に支障をきたす恐れがあります。 補足: 形状が異なるコネクターがあります。 ほとんどのキーボード・ケーブルはキ ーボードに直結ですが、そのケーブルは直結ではなく個別の部品です。 この ケーブルの一端(コンピューターに接続す側)はDINコネクターで、キーボード 側はSDL(シールド・データ・リンク)コネクターになっています。 SDLは「AMP」社が開発しました。 このコネクターは、ワイヤーとスプリング (ピンではない)を持っているという点で電話線のコネクターに似ています。 また、クリップで固定します。 このコネクターに関する情報は、AMPのウェ ブサイトから入手して下さい。 http://www.connect.amp.com USBコネクターとSDLコネクターを混同しないでください。 両方とも類似して います。 しかし、実際はかなり異なることを留意して下さい。 SDLコネクターにはスプリングと可動部品がありますが、USBコネクターにはあ りません。 各コネクターのピン配置を以下に示します。 Male Female ─── ─── / \ / \ 5-pin DIN (AT/XT): / \ / \ 1 - Clock │1・ ・3 │ │3・ ・1 │ 2 - Data │ 4・ ・5 │ │ 5・ ・4 │ 3 - Not Implemented \ ・2 / \ ・2 / 4 - Ground \ / \ / 5 - Vcc (+5V) ─── ─── (Plug) (Socket) Male Female ─── ─── / \ / \ 6-pin Mini-DIN (PS/2): / ■ \ / ■ \ 1 - Data │5・ ・6 │ │6・ ・5 │ 2 - Not Implemented │ 3・ ・4 │ │ 4・ ・3 │ 3 - Ground \ ・ ・ / \ ・ ・ / 4 - Vcc (+5V) \ 1 2 / \ 2 1 / 5 - Clock ─── ─── 6 - Not Implemented (Plug) (Socket) ┌────────┐ ┌────────┐ 6-pin SDL: │ ┬┬┬┬┬┬ │ │ ┬┬┬┬┬┬ │ A - Not Implemented └┐││││││┌┘ └┐││││││┌┘ B - Data │A B C D E F │ │F E D C B A │ C - Ground └──────┘ └──────┘ D - Clock E - Vcc (+5V) F - Not Implemented The Physical Interface: The physical PS/2 port is one of two styles of connectors: The 5-pin DIN or the 6-pin mini-DIN. Both connectors are completely (electrically) similar; the only practical difference between the two is the arrangement of pins. This means the two types of connectors can easily be changed with simple hard-wired adaptors. These cost about $6 each or you can make your own by matching the pins on any two connectors. The DIN standard was created by the German Standardization Organization (Deutsches Institut fuer Norm) . Their website is at http://www.din.de (this site is in German, but most of their pages are also available in English.) PC keyboards use either a 6-pin mini-DIN or a 5-pin DIN connector. If your keyboard has a 6-pin mini-DIN and your computer has a 5-pin DIN (or visa versa), the two can be made compatible with the adaptors described above. Keyboards with the 6-pin mini-DIN are often referred to as "PS/2" keyboards, while those with the 5-pin DIN are called "AT" devices ("XT" keyboards also used the 5-pin DIN, but they are quite old and haven't been made for many years.) All modern keyboards built for the PC are either PS/2, AT, or USB. This document does not apply to USB devices, which use a completely different interface. Mice come in a number of shapes and sizes (and interfaces.) The most popular type is probably the PS/2 mouse, with USB mice gaining popularity. Just a few years ago, serial mice were also quite popular, but the computer industry is abandoning them in support of USB and PS/2 devices. This document applies only to PS/2 mice. If you want to interface a serial or USB mouse, there's plenty of information available elsewhere on the web. The cable connecting the keyboard/mouse to the computer is usually about six feet long and consists of four to six 26 AWG wires surrounded by a thin layer of mylar foil sheilding. If you need a longer cable, you can buy PS/2 extenstion cables from most consumer electronics stores. You should not connect multiple extension cables together. If you need a 30-foot keyboard cable, buy a 30-foot keyboard cable. Do not simply connect five 6-foot cables together. Doing so could result in poor communication between the keyboard/mouse and the host. As a side note, there is one other type of connector you may run into on keyboar ds. While most keyboard cables are hard-wired to the keyboard, there are some whose cable is not permanently attached and come as a separate component. These cables have a DIN connector on one end (the end that connects to the computer) and a SDL (Sheilded Data Link) connector on the keyboard end. SDL was created by a company called "AMP." This connector is somewhat similar to a telephone connector in that it has wires and springs rather than pins, and a clip holds it in place. If you need more information on this connector, you might be able to find it on AMP's website at http://www.connect.amp.com. Don't confuse the SDL connector with the USB connector--they probably both look similar in my diagram below, but they are actually very different. Keep in mind that the SDL connector has springs and moving parts, while the USB connector does not. The pinouts for each connector are shown below: Male Female ─── ─── / \ / \ 5-pin DIN (AT/XT): / \ / \ 1 - Clock │1・ ・3 │ │3・ ・1 │ 2 - Data │ 4・ ・5 │ │ 5・ ・4 │ 3 - Not Implemented \ ・2 / \ ・2 / 4 - Ground \ / \ / 5 - Vcc (+5V) ─── ─── (Plug) (Socket) Male Female ─── ─── / \ / \ 6-pin Mini-DIN (PS/2): / ■ \ / ■ \ 1 - Data │5・ ・6 │ │6・ ・5 │ 2 - Not Implemented │ 3・ ・4 │ │ 4・ ・3 │ 3 - Ground \ ・ ・ / \ ・ ・ / 4 - Vcc (+5V) \ 1 2 / \ 2 1 / 5 - Clock ─── ─── 6 - Not Implemented (Plug) (Socket) ┌────────┐ ┌────────┐ 6-pin SDL: │ ┬┬┬┬┬┬ │ │ ┬┬┬┬┬┬ │ A - Not Implemented └┐││││││┌┘ └┐││││││┌┘ B - Data │A B C D E F │ │F E D C B A │ C - Ground └──────┘ └──────┘ D - Clock E - Vcc (+5V) F - Not Implemented 1.6. 電気的なインターフェース: 注: このドキュメントの全般で、コンピューター(キーボードやマウスを接続 する全てのもの)を「ホスト」と記述する事があります。 また「デバイス」はキーボード/マウスを示します。 Vccとグランドでキーボードやマウスに電源を供給します。 ホストからキーボ ードまたはマウスに供給する電流が275mA以上にならない様に、過渡電流の回 避策を設けるなどの注意が必要です。 コンピュータの電源がオンしている 時に、キーボードやマウスの脱着を繰返す「稼働中のプラグ抜き差し」により 過渡電流が発生します。 古いマザーボードには、キーボードとマウスのポー トを保護する為に表面実装されたヒューズがありました。 このヒューズが切 れたマザーボードは役に立たず、専門の技術者が同ヒューズを交換することに なります。 新しいタイプのマザーボードの多くは、この問題を改善するために、自動的に リセットする「Poly」ヒューズを採用しています。 しかしこれは標準仕様で はありません。 また、使用中の古いタイプのマザーボードはまだ沢山ありま す。 したがって、PS/2マウスやキーボードに「稼働中のプラグ抜き差し」対 策を設けることを推奨します。 電源仕様: 供給電圧(Vcc) = +4.5V〜+5.5V 最大供給電流 = 275mA データとクロックラインは両方ともオープンコレクターでVccに抵抗でプルア ップされています。 「オープンコレクター」インターフェースには、低いイ ンピーダンスと高いインピーダンスの2つの状態があります。 「低いインピーダンス」状態では、トランジスターがオンしてラインをアース レベルにします。 「高いインピーダンス」状態では、インターフェースはオープンになり、ライ ンは低レベルではなくなります。 バスに接続したデバイスが低レベルにしな い場合に、バスが高レベルになるように「プルアップ」抵抗をバスとVccの間 に接続します。 この抵抗の正確な値は重要ではありません。(1-10kOhms) 大きな抵抗値では、消費電力が少なくります。 また、小さな抵抗値では、立 ち上がり時間が速くなります。 一般的なオープンコレクターインターフェー スを以下に示します: 図1 一般的なオープンコレクターインターフェース。 データとクロックは、マイクロコントローラのピンAおよびBでそれぞれ読み込 まれます。 両方のラインは、通常+5Vに保持されますが、C又はDにロジック 「1」を出力することによりアースに引下げることができます。 データ及び クロックは反転した出力になります。 ┌───┐ │ Vcc├───┬──┬── 電源 +5V │ │ │ │ │ │ R R │マ │ │ │ │イ A├──────┼── クロック │ク │ │ │ │ロ B├───┼───── データ │コ │ │ │ │ン │ │/ │ │ト C├─┤ │ │ロ │ │\ │ │| │ ↓ │ │ラ │ │ │ │| │ ││/ │ D├────┤ │ │ ││\ │ │ │ ↓ │ │ │ │ │ Gnd├───┴──┴── グランド └───┘ 注: このウェブサイト上の例では、PICマイクロコントローラでオープンコレクタ ーインターフェースを利用する場合に、若干の工夫をして入力と出力の両方で 同じピンを使用しています。 また、外部抵抗を使用せずに、PICの内部プル アップ抵抗を使用しています。 Aラインは、対応するピンのポートに「0」を 書き込むことで出力がアースレベルになります。 ピンを入力にセットするこ とでラインは「高インピーダンス」状態になります。 PICの内蔵保護ダイオードと、十分な電流シンク特性により実現しています。 The Electrical Interface: Note: Throughout this document, I will use the more general term "host" to refer to the computer--or whatever the keyboard/mouse is connected to-- and the term "device" will refer to the keyboard/mouse. Vcc/Ground provide power to the keyboard/mouse. The keyboard or mouse should not draw more than 275 mA from the host and care must be taken to avoid transient surges. Such surges can be caused by "hot-plugging" a keyboard/mouse (ie, connect/disconnect the device while the computer's power is on.) Older motherboards had a surface-mounted fuse protecting the keyboard and mouse ports. When this fuse blew, the motherboard was useless to the consumer, and non-fixable to the average technician. Most newer motherboards use auto-reset "Poly" fuses that go a long way to remedy this problem. However, this is not a standard and there's still plenty of older motherboards in use. Therefore, I recommend against hot-plugging a PS/2 mouse or keyboard. Summary: Power Specifications Vcc = +4.5V to +5.5V. Max Current = 275 mA. The Data and Clock lines are both open-collector with pullup resistors to Vcc. An "open-collector" interface has two possible state: low, or high impedance. In the "low" state, a transistor pulls the line to ground level. In the "high impedance" state, the interface acts as an open circuit and doesn't drive the line low or high. Furthermore, a "pullup" resistor is connected between the bus and Vcc so the bus is pulled high if none of the devices on the bus are actively pulling it low. The exact value of this resistor isn't too important (1~10 kOhms); larger resistances result in less power consumption and smaller resistances result in a faster rise time. A general open-collector interface is shown below: Figure 1: General open-collector interface. Data and Clock are read on the microcontroller's pins A and B, respectively. Both lines are normally held at +5V, but can be pulled to ground by asserting logic "1" on C and D. As a result, Data equals D, inverted, and Clock equals C, inverted. Note: When looking through examples on this website, you'll notice I use a few tricks when implementing an open-collector interface with PIC microcontrollers. I use the same pin for both input and output, and I enable the PIC's internal pullup resistors rather than using external resistors. A line is pulled to ground by setting the corresponding pin to output, and writing a "zero" to that port. The line is set to the "high impedance" state by setting the pin to input. Taking into account the PIC's built-in protection diodes and sufficient current sinking, I think this is a valid configuration. Let me know if your experiences have proved otherwise. 1.7. 通信の一般事項 両方のラインがHIGHの場合(OPEN COLLECTOR)、バスは「アイドル」状態です。 この状態の時にキーボード/マウスはデータの送信開始が許可されます。 ホストはバスの制御を支配し、クロックラインをLowにすることによりいつで も通信を禁止することが可能です。 クロックは常にデバイスが発生します。 ホストが送信をする場合は、始めにクロックをLowにしてデバイスからの通信 を禁止する必要があります。 ホストは、データをLowに設定後にクロックを開放します。 これは「送信要求」状態で、デバイスに対するクロック発生開始信号になりま す。 表:バスステート データ クロック 内容 ---------+------------+------------------ High High アイドル状態 High Low 通信禁止 Low High ホスト送信要求 ───┐ ┌─────────────────── Host Clock └───┘ ──────┐ ┌───┬───┬───┬───┬─ Host Data └──┴───┴───┴───┴───┴─ ────────┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌ Device Clock └─┘ └─┘ └─┘ └─┘ └─┘ ─────────────────────────── Device Data ──────┼←→┼←──────────────── 送信 ホスト送信データ 要求 全てのデータは、一度に1バイトづつ送信します。 各バイトは11ビットから12ビットで構成し送信します。 ビット構成 ビット数 名称 内容 ------------+-----------------+-------------------------------------- 1 スタートビット 常に 0 8 データビット LSBから送信 1 パリティビット 奇数パリティ 1 ストップビット 常に 1 1 肯定応答 ホストからの送信時のみ パリティビットは、データ中の1の個数が偶数の時にセットし、データ中の1の 個数が奇数の時にリセット(0)します。 データ中の1の個数とパリティビットとの和は常に奇数になります。 キーボード/マウスはパリティビットをチェックし、正しくない場合は、デー タを無効にします。 デバイスからホストへの送信データは、クロック信号の立下りエッジで読込ま れます。 ホストからデバイスへの送信データは、クロック信号の立上りで読込まれます 。 クロック周波数は 10KHz-16.7KHz です。 クロックのHighとLowの各期間は30μSECから50μSECです。 キーボードやマウス及びホストエミュレータ等を設計する場合、HighやLowの 各期間の中間でデータの更新や取り込みを行う必要があります。 つまり、クロックの変化後15μSECから25μSECです。 キーボードやマウスは常にクロックを発生します。しかし、通信制御の支配は 常にホストが行います。 タイミングは重要で、この資料中の数値に従うことを推奨します。 Communication: General Description The PS/2 mouse and keyboard implement a bidirectional synchronous serial protocol. The bus is "idle" when both lines are high (open-collector). This is the only state where the keyboard/mouse is allowed begin transmitting data. The host has ultimate control over the bus and may inhibit communication at any time by pulling the Clock line low. The device always generates the clock signal. If the host wants to send data, it must first inhibit communication from the device by pulling Clock low. The host then pulls Data low and releases Clock. This is the "Request-to-Send" state and signals the device to start generating clock pulses. Summary: Bus States Data = high, Clock = high: Idle state. Data = high, Clock = low: Communication Inhibited. Data = low, Clock = high: Host Request-to-Send All data is transmitted one byte at a time and each byte is sent in a frame consisting of 11-12 bits. These bits are: 1 start bit. This is always 0. 8 data bits, least significant bit first. 1 parity bit (odd parity). 1 stop bit. This is always 1. 1 acknowledge bit (host-to-device communication only) The parity bit is set if there is an even number of 1's in the data bits and reset (0) if there is an odd number of 1's in the data bits. The number of 1's in the data bits plus the parity bit always add up to an odd number (odd parity.) This is used for error detection. The keyboard/mouse must check this bit and if incorrect it should respond as if it had received an invalid command. Data sent from the device to the host is read on the falling edge of the clock signal; data sent from the host to the device is read on the rising edge. The clock frequency must be in the range 10 - 16.7 kHz. This means clock must be high for 30 - 50 microseconds and low for 30 - 50 microseconds.. If you're designing a keyboard, mouse, or host emulator, you should modify/sample the Data line in the middle of each cell. I.e. 15 - 25 microseconds after the appropriate clock transition. Again, the keyboard/mouse always generates the clock signal, but the host always has ultimate control over communication. Timing is absolutely crucial. Every time quantity I give in this article must be followed exactly. 1.8. デバイスからホストへの通信 データとクロックの両ラインはオープンコレクターです。 各ラインと+5Vとの間に抵抗が入ります。 アイドル状のバスはHighです。 キーボードやマウスが情報を送信する場合は、始めにクロックラインがHighで あることを確認します。 Lowならばホストが通信を禁止している為、デバイスはホストがクロックライ ンを開放するまで送信するデータを蓄えておきます。 クロックラインが50μSEC連続してHighならば、デバイスはデータの送信を開 始する事が出来ます。 キーボードやマウスはフレーム長が11ビットのシリアル通信プロトコルを使用 します。 ビット構成 ビット数 名称 内容 ------------+-----------------+-------------------------------------- 1 スタートビット 常に 0 8 データビット LSBから送信 1 パリティビット 奇数パリティ 1 ストップビット 常に 1 キーボードやマウスは、クロックがHighの時にビットを出力し、ホストはクロ ックがLowの時に読み込みます。 ──┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌─── Clock └┘└┘└┘└┘└┘└┘└┘└┘└┘└┘└┘ ─┐ ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬──── Data └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ S D D D D D D D D P S T A A A A A A A A A T A T T T T T T T T R O R A A A A A A A A I P T 0 1 2 3 4 5 6 7 T Y クロックの周波数は10KHzから16.7KHzです。 クロックパルスの立ち上がりエッジからデータ遷移までの時間は最低5μSECです。 データ遷移からクロックパルスの立ち下がりエッジまでの時間は5μSECから 25μSECです。 ├←─────────→┤60μSEC〜100μSEC ┌─────┐ ┌─────┐ ┌──── Clock ──┘ └─────┘ └─────┘ ───┬─────┬─────┬─────┬─────┬─── Data ───┴─────┴─────┴─────┴─────┴─── →┼┼←5μSEC ├←──→┤5〜25μSEC ホストはいつでも最低100μSEC間クロックラインをLowにして通信を禁止する 事が可能です。 デバイスは、11ビット目のパルスを送信する前に通信が禁止された場合は、通 信禁止が解除された時に全データの再送信を行います。 全データとは、メークコード、ブレークコード、デバイスID、マウス移動パケ ットなどです。 例えば、キーボードがブレークコードの第2バイト目を送信中に中断された場 合には、ブレークコードの第1バイトと第2バイトの2バイトを送信する必要 があります。 ホストが最初のHighからLowへのクロック遷移前や、最終クロックパルスの立 下りエッジ後にクロックをLowにした場合には、キーボードやマウスは再送信 の必要はありません。 しかし禁止期間中の新たな送信データはクロックが開 放されるまで保存しておく必要があります。 キーボードはこの為に16バイトのバッファーを持っています。 このバッファーに余裕がなくなると、キー入力は無視されます。 マウスは、最新の移動情報パケットのみを保存します。 Communication: Device-to-Host The Data and Clock lines are both open collector. A resistor is connected between each line and +5V, so the idle state of the bus is high. When the keyboard or mouse wants to send information, it first checks the Clock line to make sure it's at a high logic level. If it's not, the host is inhibiting communication and the device must buffer any to-be-sent data until the host releases Clock. The Clock line must be continuously high for at least 50 microseconds before the device can begin to transmit its data. As I mentioned in the previous section, the keyboard and mouse use a serial protocol with 11-bit frames. These bits are: 1 start bit. This is always 0. 8 data bits, least significant bit first. 1 parity bit (odd parity). 1 stop bit. This is always 1. The keyboard/mouse writes a bit on the Data line when Clock is high, and it is read by the host when Clock is low. Figures 2 and 3 illustrate this. ──┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌─── Clock └┘└┘└┘└┘└┘└┘└┘└┘└┘└┘└┘ ─┐ ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬──── Data └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ S D D D D D D D D P S T A A A A A A A A A T A T T T T T T T T R O R A A A A A A A A I P T 0 1 2 3 4 5 6 7 T Y The clock frequency is 10-16.7 kHz. The time from the rising edge of a clock pulse to a Data transition must be at least 5 microseconds. The time from a data transition to the falling edge of a clock pulse must be at least 5 microseconds and no greater than 25 microseconds. The host may inhibit communication at any time by pulling the Clock line low for at least 100 microseconds. If a transmission is inhibited before the 11th clock pulse, the device must abort the current transmission and prepare to retransmit the current "chunk" of data when host releases Clock. A "chunk" of data could be a make code, break code, device ID, mouse movement packet, etc. For example, if a keyboard is interrupted while sending the second byte of a two-byte break code, it will need to retransmit both bytes of that break code, not just the one that was interrupted. If the host pulls clock low before the first high-to-low clock transition, or after the falling edge of the last clock pulse, the keyboard/mouse does not need to retransmit any data. However, if new data is created that needs to be transmitted, it will have to be buffered until the host releases Clock. Keyboards have a 16-byte buffer for this purpose. If more than 16 bytes worth of keystrokes occur, further keystrokes will be ignored until there's room in the buffer. Mice only store the most current movement packet for transmission. 1.9. ホストからデバイスへの通信 ホストからデバイスへの通信用パケットは少し変則的です。 第1に、PS/2デバイスは常にクロック信号を発生します。 ホストがデータの送信を要求する場合には、始めにクロックとデータラインを 「送信要求」に設定します。 クロックを最低100μSEC間Lowに設定し通信を禁止します。 データをLowに設定して「送信要求」にした後に、クロックを開放します。 デバイスは10mSECを超えない周期で「送信要求」をチェックします。 この状態を検出したデバイスは、データ用の8ビットとストップビット用の1ビ ットのクロック信号を発生します。 ホストはクロックラインがLowの時にデータを変更し、デバイスはクロックが Highの時にデータを読みます。 これは、デバイスからホストへの送信とは逆になります。 ストップビットを受信したデバイスは、データラインをLowにし最終クロック パルスを発生することで、受信したバイトを認証します。 11個のクロックパルスの後でもデータラインがホストにより開放されない場合 は、デバイスは、データラインが開放されるまでクロックパルスを出し続けま す。(その後、デバイスはエラーを生成します。) ホストは、11ビット目の認証ビット以前に、クロックラインを最低100μSEC間 Lowに保持して送信を中止することが出来ます。 このプロセスを理解しやすくするための、ホストがPS/2デバイスに対してデー タを送信する際に従うべきステップを以下に記します。 1) 最低100μSECクロックラインをLowにします。 2) データラインをLowにします。 3) クロックラインを開放します。 4) デバイスがクロックラインをLowにする迄待ちます。 5) 最初のデータビット送信するためデータラインをセット又はリセットしま す。 6) デバイスがクロックラインをHighにする迄待ちます。 7) デバイスがクロックラインをLowにする迄待ちます。 8) 残りの7ビットとパリティビットの為に 5)から7)を繰返します。 9) データラインを開放します。 10) デバイスがデータラインをLowにする迄待ちます。 11) デバイスがクロックラインをLowにする迄待ちます。 12) デバイスがデータとクロックを開放する迄待ちます。 例3は上記ステップを図示したものです。 例4はホストとPS/2デバイスを分離してタイミングを図示したものです。 ACKビットのタイミングは、クロックラインがHighの時に行われることに注意 して下さい。(他の11ビットはLowの時です。) 例3 ─┐ ┌─┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌──── Clock └─┘ └┘└┘└┘└┘└┘└┘└┘└┘└┘└┘└┘ ──┐ ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬┐ ┌──── Data └──┴─┴─┴─┴─┴─┴─┴─┴─┴─┘└─┘ S D D D D D D D D P S A T A A A A A A A A A T C A T T T T T T T T R O K R A A A A A A A A I P T 0 1 2 3 4 5 6 7 T Y 例4 (a) (b) ┼─┼────────────────────┼ Host ─┐ ┌─────────────────────────── Clock └─┘ Host ──┐ ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─────── Data └──┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ Device ─────┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌──── Clock └┘└┘└┘└┘└┘└┘└┘└┘└┘└┘└┘ Device ────────────────────────┐ ┌──── Data └─┘ S D D D D D D D D P S A T A A A A A A A A A T C A T T T T T T T T R O K R A A A A A A A A I P T 0 1 2 3 4 5 6 7 T Y 例4で2つの期間に注目してください。 (a)はデバイスがクロックの発生を開始するために、ホストが始めにクロック ラインをLowにする期間で、15mSEC以下です。 (b)はパケットを送信する期間で2mSEC以下です。 これらの時間を超えると、ホストはエラーを発生します。 ACKを受信した直後にデータ処理の間ホストは、クロックラインをLowに設定し 通信を禁止する事があります。 ホストがコマンドでレスポンスを要求した場合は、通信禁止が解除されてから 20mSEC以内に応答する必要があります。 この期間中に応答が無い場合ホスト はエラーを発生します。 Host-to-Device Communication: The packet is sent a little differently in host-to-device communication ... First of all, the PS/2 device always generates the clock signal. If the host wants to send data, it must first put the Clock and Data lines in a "Request-to-send" state as follows: Inhibit communication by pulling Clock low for at least 100 microseconds. Apply "Request-to-send" by pulling Data low, then release Clock. The device should check for this state at intervals not to exceed 10 milliseconds. When the device detects this state, it will begin generating Clock signals and clock in eight data bits and one stop bit. The host changes the Data line only when the Clock line is low, and data is read by the device when Clock is high. This is opposite of what occours in device-to-host communication. After the stop bit is received, the device will acknowledge the received byte by bringing the Data line low and generating one last clock pulse. If the host does not release the Data line after the 11th clock pulse, the device will continue to generate clock pulses until the the Data line is released (the device will then generate an error.) The host may abort transmission at time before the 11th clock pulse (acknowledge bit) by holding Clock low for at least 100 microseconds To make this process a little easier to understand, here's the steps the host must follow to send data to a PS/2 device: 1) Bring the Clock line low for at least 100 microseconds. 2) Bring the Data line low. 3) Release the Clock line. 4) Wait for the device to bring the Clock line low. 5) Set/reset the Data line to send the first data bit 6) Wait for the device to bring Clock high. 7) Wait for the device to bring Clock low. 8) Repeat steps 5-7 for the other seven data bits and the parity bit 9) Release the Data line. 10) Wait for the device to bring Data low. 11) Wait for the device to bring Clock low. 12) Wait for the device to release Data and Clock Figure 3 shows this graphically and Figure 4 separates the timing to show which signals are generated by the host, and which are generated by the PS/2 device. Notice the change in timing for the "ack" bit--the data transition occours when the Clock line is high (rather than when it is low as is the case for the other 11 bits.) Figure 3 ─┐ ┌─┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌──── Clock └─┘ └┘└┘└┘└┘└┘└┘└┘└┘└┘└┘└┘ ──┐ ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬┐ ┌──── Data └──┴─┴─┴─┴─┴─┴─┴─┴─┴─┘└─┘ S D D D D D D D D P S A T A A A A A A A A A T C A T T T T T T T T R O K R A A A A A A A A I P T 0 1 2 3 4 5 6 7 T Y Figure 4 (a) (b) ┼─┼────────────────────┼ Host ─┐ ┌─────────────────────────── Clock └─┘ Host ──┐ ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─────── Data └──┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ Device ─────┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌┐┌──── Clock └┘└┘└┘└┘└┘└┘└┘└┘└┘└┘└┘ Device ────────────────────────┐ ┌──── Data └─┘ S D D D D D D D D P S A T A A A A A A A A A T C A T T T T T T T T R O K R A A A A A A A A I P T 0 1 2 3 4 5 6 7 T Y Referring to Figure 4, there's two time quantities the host looks for. (a) is the time it takes the device to begin generating clock pulses after the host initially takes the Clock line low, which must be no greater than 15 ms. (b) is the time it takes for the packet to be sent, which must be no greater than 2ms. If either of these time limits is not met, the host should generate an error. Immediately after the "ack" is received, the host may bring the Clock line low to inhibit communication while it processes data. If the command sent by the host requires a response, that response must be received no later than 20 ms after the host releases the Clock line. If this does not happen, the host generates an error. ******************************************************************************* ******************************************************************************* 2. PS/2 マウス インターフェース PS/2 Mouse Interface ******************************************************************************* ******************************************************************************* 2.1. 原文の入手先 URL: http://www.Computer-Engineering.org 著者: Adam Chapweske 最後更新: 04/01/03 2.2. 翻訳について この資料は、PS/2マウスインターフェースを理解するために上記URLから英文 を入手し、翻訳サイトの多大な協力のもと、訳者の勝手な解釈により作成しま した。 内容等で不明確な場合は上記URLの原文を参照して下さい。 この資料中の英語の原文部分は、訳文の誤記訂正が進んだしかる後に削除する 予定です。 目次と項番は、訳者の便宜の為に追加しました。 詳細な仕様を提供下さった著者に感謝します。 訳者: 中野 良知 最終更新日時: 2005/07/03 2.3. 法律条項 この記事により生じたいかなる障害や損害に対し、著者は全てを免責されるも のとします。 (これには訳者も含まれます。) この記事は、著作権法の下で保護され、出所、著者、日付、法律条項を含んだ 場合にのみ複製が可能です。 (これには訳者も含まれます。) Legal Information: All information within this article is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantibility and fitness for a particular purpose. This article is protected under copyright law. This document may be copied only if the source, author, date, and legal information is included. 2.4. 目的 この記事は、物理的・電気的なインターフェース、低レベルのプロトコル、 オペレーションモード、コマンドおよび拡張を含むPS/2マウス・インターフ ェースについて説明しています。 マウス・エンコーダを含むコード・サンプルはすべて、マイクロチップのPIC マイクロコントローラのための会議室に書かれています。 補助のコントロー ラー装置(キーボード・コントローラー)と関係するコード・サンプルはすべて 、x86会議室に書かれています。 Abstract: This article attempts to explain every aspect of the PS/2 mouse interface including the physical and electrical interface, low-level protocol, modes of operation, commands, and extensions. All code samples involving the mouse encoder are written in assembly for Microchip's PIC microcontrollers. All code samples related to the auxiliary device controller (keyboard controller) are written in x86 assembly 2.5. 概要 マウス、トラックボール、タッチパッド、電子白板などPCに利用可能な多くの ポインティング・デバイスがあります。 これらのポインティング・デバイス は、ユニバーサルシリアルバス(USB)またはPS/2マウス・インターフェースを 使用して、コンピューターと通信します。 比較テーブル: 項目 USB(v1.1) PS/2マウス・インターフェース -------------+---------------+----------------------------------- 装置の数 127まで 1 最大データ 12 Mbps 40 kbps 電源 5V 500mA 5V 100mA ホットプラグ 可 不可 ドキュメント あり 絶版 旧タイプのポインティング・デバイス・インターフェースとしてアップル・デ スクトップ・バス(ADB)、RS-232シリアルポートおよびバスマウス・インター フェースがありますが、この資料に解説はありません。 PS/2マウス・インターフェースは、80年代の終わりにIBMの「パーソナルシス テム/2」コンピューターに使われました。 以来、互換性が維持され広く使用 されているたインターフェースです。 一方USBは近年急速に利用が広がり、 PS/2マウス・インターフェースに取って代わると思われます。 PS/2マウス・インターフェースは、コンピューターの制御補助装置(キーボー ド・コントローラー)のカーソルやボタン位置データを送信するために、双方 向のシリアルプロトコルを使用します。 コンピューターはマウスに対して、 レポートレート設定、解像度、リセット、禁止など多くのコマンドを送ります 。 さらにコンピューターは過負荷保護した5Vの電源をマウスに供給します。 General Description: There are many types of pointing devices available for modern PCs, including mice, trackballs, touchpads, electronic whiteboards, etc. Virtually all of these pointing devices communicate with a computer using one of two interfaces: Universal Serial Bus (USB) or the PS/2 Mouse Interface. See the following table for a comparison: USB(v1.1) PS/2マウス・インターフェース -------------+---------------+----------------------------------- 装置の数 127まで 1 最大データ 12 Mbps 40 kbps 電源 5V 500mA 5V 100mA ホットプラグ 可 不可 ドキュメント あり 絶版 Older pointing device interfaces include the Apple Desktop Bus (ADB), RS-232 serial port, and the bus mouse interface. These are obsolete and are not covered in this article. The PS/2 mouse interface originally appeared in IBM's "Personal System/2" computers in the late 80's. It still remains a widely-supported interface for the sake of constantly maintaining backward compatibility. However, USB has quickly caught on these last few years and will eventually replace the PS/2 mouse interface entirely . The PS/2 mouse interface uses a bidirectional serial protocol to transmit movement and button-position data to the computer's auxiliary device controller (keyboard controller). The computer, in turn, may send a number of commands to the mouse to set the report rate, resolution, reset the mouse, disable the mouse, etc. The computer also provides the mouse with an overload-protected 5V power supply. 2.6. 電気インターフェース/プロトコル PS/2マウスは、PS/2キーボード(aka ATキーボード)と同じプロトコルを使用し ます。 このプロトコルについての詳細な情報に関してはここをクリックしてください 。 Electrical Interface / Protocol: The PS/2 mouse uses the same protocol as the PS/2 keyboard (aka AT keyboard). Click here for detailed information on this protocol. 2.7. 入力、解像度、比率 標準のPS/2マウス・インターフェースは次の入力を支援します: X(右/左)移動、Y(上/下)移動、左ボタン、中央ボタンおよび右ボタン。 マウスは規則的な周期でこれらの入力を読み、移動とボタンの状態を反映する ために様々なカウンターおよびフラグを更新します。 この資料以外に拡張された機能を持った多くのPS/2ポインティング・デバイス があります。 そのひとつがスクロールホイールと2つの追加釦を標準的な入力にしたマイクロ ソフトのIntellimouseで、この資料で解説します。 標準マウスは、移動の軌跡を示す2つのカウンターを持っています。 X移動カウンターおよびY移動カウンターです。 各移動カウンターは9ビットの2の補足値とオーバーフロー・フラグを持ってい ます。 それらの内容は、3つのマウスボタンの状態に加えて、3バイトの移動データ・ パケットでホストへ送られます。(次のセクションを参照。) 移動カウンターは、最後の移動データ・パケットをホスト送った後に新たに生 じた移動の量を表わします。(絶対的な移動量を表すものではありません。) マウスは入力を読み現在の釦状態や移動体のチェックを記録します。 移動が生じた場合、Xおよび(または)Y移動カウンターをインクリメントするか 、ディクリメントします。(-Xか-Y移動)(+Xか+Y移動)。カウンターのどちらか オーバーフローした場合、オーバーフロー・フラグをセットします 移動カウンターがインクリメント/ディクリメントされる量を決定するパラメ ーターが解像度です。デフォルト解像度は4カウント/mmです。また、ホストは 「セット解像度」(0xE8)コマンドを使用して変更することが出来ます。 移動量カウンターには影響をしないが、報告するカウンターの値(1)に影響す るパラメーターがあります。 このパラメーターが比率(スケーリング)です。 マウスはデフォルトで1:1の比率を使用します。 1:1比率ではマウス移動量の レポートに影響がありません。 ホストは「2:1比率設定」(0xE7)コマンドを送ることにより、2:1比率を選択す る事ができます。 2:1比率が許可されると、マウスはホストへのレポート 前に、次のアルゴリズムを適用します。 移動量カウンタ レポートする移動量 ----------------+----------------------- 0 0 1 1 2 1 3 3 4 6 5 9 N > 5 2 * N Inputs, Resolution, and Scaling: The standard PS/2 mouse interface supports the following inputs: X (right/left) movement, Y (up/down) movement, left button, middle button , and right button. The mouse reads these inputs at a regular freqency and updates various counters and flags to reflect movement and button states. There are many PS/2 pointing devices that have additional inputs and may report data differently than described in this document. One popular extension I cover later in this document is the Microsoft Intellimouse, which includes support for the standard inputs as well as a scrolling wheel and two additional buttons. The standard mouse has two counters that keep track of movement: the X-movement counter and the Y-movement counter. These are 9-bit 2's complement values and each has an associated overflow flag. Their contents, along with the state of the three mouse buttons, are sent to the host in the form of a 3-byte movement data packet (as described in the next section.) The movement counters represent the amount of movement that has occurred since the last movment data packet was sent to the host (ie, they do not represent absolute positions.) When the mouse reads its inputs, it records the current state of its buttons and checks for movement. If movement has occurred it increments (for +X or +Y movement) or decrements (for -X or -Y movement) its X and/or Y movement counters. If either of the counters has overflowed, it sets the appropriate overflow flag. The parameter that determines the amount by which the movement counters are incremented/decremented is the resolution. The default resolution is 4 counts/mm and the host may change that value using the "Set Resolution" (0xE8) command. There is a parameter that does not effect the movement counters, but does effect the reported(1) value of these counters. This parameter is scaling. By default, the mouse uses 1:1 scaling, which has no effect on the reported mouse movement. However, the host may select 2:1 scaling by sending the "Set Scaling 2:1" (0xE7) command. If 2:1 scaling is enabled, the mouse will apply the following algorithm to the counters before sending their contents to the host: Movement Counter Reported Movement 0 0 1 1 2 1 3 3 4 6 5 9 N > 5 2 * N 2.8. 移動データパケット 標準のPS/2マウスは、次の3バイトのパケット(脚注4)を使用して、ホストへ移 動量やボタン状態を送ります。 移動量カウンターは、9ビットの整数型で2の補数で表します。 MSBが移動量デ ータの符号ビットになります。 マウスは入力を読み、移動が生じたことを検 出すると、カウンターを更新します。 その値は、以前に移動量データ・パケ ットを、ホストへ送信した以後に生じた移動量です。 (パケットをホストへ 送信した後、移動量カウンターをリセットします。) 移動量カウンターによって表現することができる値の範囲は-255〜+255です。 この範囲を超えると、オーバーフロー・ビットがセットします。 Byte 1 Bit 7 Y overflow Bit 6 X overflow Bit 5 Y sign bit Bit 4 X sign bit Bit 3 Always 1 Bit 2 Middle Button Bit 1 Right Button Bit 0 Left Button Byte 2 Bit 7-0 X Movement Byte 3 Bit 7-0 Y Movement 移動量データ・パケットのホストへの送信が成功した場合、移動量カウンター をリセットします。 さらに、マウスはホストから「再送信」(0xFE)以外のコ マンドを受信送した場合も、移動量カウンターをリセットします。 Movement Data Packet: The standard PS/2 mouse sends movement/button information to the host using the following 3-byte packet (4): Byte 1 Bit 7 Y overflow Bit 6 X overflow Bit 5 Y sign bit Bit 4 X sign bit Bit 3 Always 1 Bit 2 Middle Button Bit 1 Right Button Bit 0 Left Button Byte 2 Bit 7-0 X Movement Byte 3 Bit 7-0 Y Movement 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. 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. 2.9. オペレーション・モード データレポートは、マウスのオペレーションのモードに対応します。 オペレーションには4つのスタンダードモードがあります: ・リセット(0xFF) マウスは、パワー・アップで、あるいは「リセット設定」(0xFF)コマンドを 受け取った後にリセット・モードになります。 ・ストリーム(0xEA) これはデフォルト・モード(リセット実行終了後)で、ほとんどのソフトウェ アがマウスを使用するモードです。 ホストが以前にリモートモードにマウ スをセットした場合でも、マウスに「ストリームモード設定」(0xEA)コマン ドを送ることにより、ストリームモードになります 。 ・リモート(0xF0) リモートモードはいくつかの状況で有用で、マウスに「リモートモード設定 」(0xF0)コマンドを送ることによりこのモードになリます。 ・ラップ(0xEE) このモードは、マウスとホスト間の通信テストにのみ有効です。 マウスに「セット・ラップ・モード」(0xEE)コマンドを送ることによりラッ プ・モードになります。 ラップ・モードから出る為には、ホストは「セット・リセット」(0xFF)コマ ンドまたは「リセット・ラップ・モード」(0xEC)コマンドを出さなければな りません。 「セット・リセット」(0xFF)コマンドを受信すると、マウスはリセット・ モードに入ります。 「リセット・ラップ・モード」(0xEC) コマンドを受 信したマウスは、ラップ・モードに先立って実行していたモードに入りま す。 (注:このドキュメントに後述するように、マウスはさらにオペレーションの 「拡張」モードに入る事があります。 しかし、これは標準のPS/2マウスの 特 徴ではありません。 ) Modes of Operation: Data reporting is handled according to the mode in which the mouse is operating. There are four standard modes of operation: ・Reset - The mouse enters Reset mode at power-up or after receiving the "Reset" (0xFF) command. ・Stream - This is the default mode (after Reset finishes executing) and is the mode in which most software uses the mouse. 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. ・Remote - Remote mode is useful in some situations and may be entered by sending the "Set Remote Mode" (0xF0) command to the mouse. ・Wrap - This mode isn't particularly useful except for testing the connection between the mouse and its host. Wrap mode may be entered by sending the "Set Wrap Mode" (0xEE) command to the mouse. To exit Wrap mode, the host must issue the "Reset" (0xFF) command or "Reset Wrap Mode" (0xEC) command. If the "Reset" (0xFF) command is recieved , the mouse will enter Reset mode. If the "Reset Wrap Mode" (0xEC) command is received, the mouse will enter the mode it was in prior to Wrap Mode. (Note: The mouse may also enter "extended" modes of operation, as described later in this document. However, this is not a feature of the standard PS/2 mouse.) 2.9.1. リセット・モード マウスは、電源投入または「セット・リセット」(0xFF)コマンドに応じてリセ ット・モードになります。 このモードになると、マウスはBAT(基礎的な保証 テスト)と呼ばれる自己診断テストを行ない、次のデフォルト値をセットします 。 サンプル レート = 100サンプル/sec 解像度 = 4カウント/mm 比率 = 1:1 データレポート = 禁止 その後、AAh(BAT成功)あるいはFCh(エラー)のいずれかのBAT完了コードを送り ます。 ホストのAAh以外の完了コードに対する反応は不確定です。 BAT完了コード(AAhまたはFCh)に続いて、マウスは、装置ID 00hを送ります。 これは、キーボードあるいは拡張モードにおけるマウスとの相違を示します。 ホストに関する資料では、ホストは装置IDを受け取るまではいかなるデータも 送信することはありません。 しかし、BIOSによっては電源投入リセットの後 に、0xAAに続いて直ちに「セット・リセット」コマンドを送る事があります。 マウスはホストへ装置IDを送った後、ストリーム・モードになります。 マウス自身がセットしたデフォルト値のうちの1つが「データレポート禁止」 であることに注意してください。 これは「データレポート許可」コマンドを 受け取るまでマウスが移動データ・パケットを出力しないことを意味します。 Reset Mode: 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: Sample Rate = 100 samples/sec Resolution = 4 counts/mm Scaling = 1:1 Data Reporting Disabled 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. 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 supposed to transmit any data until it receives a device ID. However I've found that some BIOS's will send the "Reset" command immediately following the 0xAA received after a power-on reset. After the mouse has sent its device ID to the host, it will enter Stream Mode. Note that one of the default values set by the mouse is "Data Reporting Disabled". This means the mouse will not issue any movement data packets until it receives the "Enable Data Reporting" command. 2.9.2. ストリーム・モード ストリームモードにおいて、移動量か1つ以上のマウスボタンの状態の変化を 検知した場合、マウスは移動量データを送ります。 このデータレポートが 生じる最大の割合がサンプルレートです。 このパラメーターは、10サンプ ル/秒から200サンプル/秒まであります。 デフォルト値は100サンプル/秒で す。 また、ホストは「セット・サンプルレート」コマンドによりその値を変 更することができます。 ストリームモードはリセットに続くオペレーションのデフォルト・モードです 。 Stream Mode: 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 sample rate. 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. Stream mode is the default mode of operation following reset. 2.9.3. リモート・モード このモードでは、マウスは現在のサンプルレートで入力を読みカウンター/フ ラグを更新します。 しかし、移動が生じた場合でも自動的にデータ・パケッ トを出すことはありません。 代わりに、ホストは「データ読込み」コマンド でマウスからデータを取得します。 このコマンドを受け取ったマウスは、 一組の移動データ・パケットを送り、その後移動カウンターをリセットします 。 Remote Mode: 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. Instead, the host must poll the mouse using the "Read Data" command. Upon receiving this command the mouse will send a single movement data packet and reset its movement counters. 2.9.4. ラップ・モード これは、マウスが受信した各バイトをホストに送り返す、「エコー」モードで す。 バイトが有効なコマンドであっても、マウスはそのコマンドに応答せず、単に ホストにそのバイトをエコーバックします。 但し、2つの例外があります。 「セット・リセット」コマンドおよび「リセット・ラップ・モード」コマンド です。 マウスはこの2つを有効なコマンドとして取り扱い、ホストに対し てエコーは行いません。 Wrap Mode: 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. 2.10. インテリマウスの拡張 標準のPS/2マウスに対してポピュラーな拡張はマイクロソフトIntellimouseで す。 これには、5つのマウスボタンと3軸の移動機構(左右、上下、スクロー ルホイール)があります。 特徴は、標準3バイトのパケットではなく4バイト 移動データ・パケットを使用することです。 ドライバが拡張パケット・フォーマットをサポートしていない場合や、 このパケット・フォーマットを認識することができない標準のPS/2マウス・ドライ バの場合には、マイクロソフトインテリマウスを標準のPS/2マウスと同じに取り扱 うことが要求されます。 マイクロソフトインテリマウスが、標準のPS/2マウスのみをサポートするコン ピューターで使用された場合、ホイールおよび第4と第5ボタンは機能しないこ とになります。 電源投入またはリセットの後に、マイクロソフトインテリマウスは、ちょうど 標準のPS/2マウスであるかのように作動します。(つまり、3バイトの移動デー タ・パケットを使用し、標準のPS/2マウスと同じ方法で全てのコマンドに応答 し、00hの装置IDを報告します。) 「スクロールホイール」モードを入力するた めに、ホストは下記コマンド・シーケンスを送ります: サンプルレート 200 設定 サンプルレート 100 設定 サンプルレート 80 設定 その後、ホストは「装置ID取得」コマンドを出し、レスポンスを待ちます。 標準のPS/2マウス(つまり非Intellimouse)が接続さた場合、装置ID 00hで応答 します。 この場合、ホストはマウスがスクロールホイールを持たない標準のPS/2マウス として取り扱うことになります。 しかし、マイクロソフトインテリマウスが接続されている場合、装置ID 03hを ホストに送信します。 接続したポインティング・デバイスにはスクロールホ イールがあります。 また、ホストはマウスが下記の4バイトの移動データ・ パケットを使用することを想定します。 Byte 1 Bit 7 Y overflow Bit 6 X overflow Bit 5 Y sign bit Bit 4 X sign bit Bit 3 Always 1 Bit 2 Middle Button Bit 1 Right Button Bit 0 Left Button Byte 2 X Movement Byte 3 Y Movement Byte 4 Z Movement Z移動量は、最後のデータ・レポート以後スクロールしたホイールの移動量を 表わした2の補数値です。 有効な値は、-8〜+7の範囲です。 これは、LSB側 からの4ビットで表わされます。 上位の4ビットは、符号拡張ビットです。 「スクロールホイール+5ボタン」モードを入力するために、ホストは下記コマ ンド・シーケンスを送ります: サンプルレート 200 設定 サンプルレート 100 設定 サンプルレート 80 設定 その後、ホストは「装置ID取得」コマンドを出し、レスポンスを待ちます。 マイクロソフトインテリマウスは04hの装置IDで応答後、下記の4バイトの移動 データ・パケットを使用します。 Byte 1 Bit 7 Y overflow Bit 6 X overflow Bit 5 Y sign bit Bit 4 X sign bit Bit 3 Always 1 Bit 2 Middle Button Bit 1 Right Button Bit 0 Left Button Byte 2 Bit 7-0 X Movement Byte 3 Bit 7-0 Y Movement Byte 4 Bit 7 Always 0 Bit 6 Always 0 Bit 5 5th Button Bit 4 4th Button Bit 3 Z3 Bit 2 Z2 Bit 1 Z1 Bit 0 Z0 Z0-Z3は、最後のデータ・レポート以後に生じた移動量を表わす2の補数です。 有効な範囲は -8〜+7 です。 4番目の釦: 1 = 押されている。 0 = 押されていない。 5番目の釦: 1 = 押されている。 0 = 押されていない。 2つのスクロールホイールを備えたマウスの場合、1つは垂直用でもう1つは水 平用です。 このマウスでは上に記述そたマイクロソフトインテリマウスデータ・パケット ・フォーマットを使用します。 上向きに垂直用ホールがスクロールされた場合、Zカウンターは1だけインクリ メントされます、また、ホイールが下向きにスクロールされた場合、Zカウン ターは1だけディクリメントされます。 これはスクロールホイールの通常動作 です。 しかし、水平ホイールがスクロールされた場合、Zカウンターは2だけ インクリメントされます、また、左にスクロールされた場合、Zカウンターは2 だけディクリメントされます。 これは、第2のスクロールホイールを設けたよ うに思えますが、2軸の位置関係によって作動する為、両方とも同時に使用す ることはありません。 (両方を同時に使用した場合、水平ホイール側は無視されます。) Intellimouse Extensions: A popular extension to the standard PS/2 mouse is the Microsoft Intellimouse. This includes support for a total of five mouse buttons and three axises of movement (right-left, up-down, and a scrolling wheel). These additional atures require the use of a 4-byte movement data packet rather than the standard 3-byte packet. 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. 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. 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.) To enter "scrolling wheel" mode, the host sends the following command sequence: Set sample rate 200 Set sample rate 100 Set sample rate 80 The host then issues the "Get device ID" command and waits for a response. If a standard PS/2 mouse (ie, non-Intellimouse) is attached, it will respond with a device ID of 00h. 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. However, if a Microsoft Intellimouse is attached, it will respond with an ID of 03h. 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: Byte 1 Bit 7 Y overflow Bit 6 X overflow Bit 5 Y sign bit Bit 4 X sign bit Bit 3 Always 1 Bit 2 Middle Button Bit 1 Right Button Bit 0 Left Button Byte 2 X Movement Byte 3 Y Movement Byte 4 Z Movement Z Movement is a 2's complement number that represents the scrolling wheel's movement since the last data report. 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. To enter "scrolling wheel + 5 button" mode, the host sends the following command sequence: Set sample rate 200 Set sample rate 200 Set sample rate 80 The host then issues the "Get device ID" command and waits for a response. A Microsoft Intellimouse will respond with a device ID of 04h, then use the following 4-byte movement data packet: Byte 1 Bit 7 Y overflow Bit 6 X overflow Bit 5 Y sign bit Bit 4 X sign bit Bit 3 Always 1 Bit 2 Middle Button Bit 1 Right Button Bit 0 Left Button Byte 2 Bit 7-0 X Movement Byte 3 Bit 7-0 Y Movement Byte 4 Bit 7 Always 0 Bit 6 Always 0 Bit 5 5th Button Bit 4 4th Button Bit 3 Z3 Bit 2 Z2 Bit 1 Z1 Bit 0 Z0 Z0-Z3 is a 2's complement number which represents the amount of movement that has occurred since the last data report. Valid values range from -8 to +7. 4th Btn: 1 = 4th mouse button is pressed; 0 = 4th mouse button is not pressed. 5th Btn: 1 = 5th mouse button is pressed; 0 = 5th mouse button is not pressed. You may have seen mice with two scrolling wheels--one vertical and the other horizontal. These mice use the Microsoft Intellimouse data packet format as described above. If the vertical wheel is scrolled upward, the Z-counter is incremented by one and if that wheel is scrolled down, the Z-counter is decremented by one. This is normal operation for a scrolling wheel. However, if the horizontal wheel is scrolled right, the Z-counter is incremented by two and if it is scrolled left, the Z-counter is decremented by two. 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.) 2.11. コマンドセット 下記は標準のPS/2マウスに採用されたコマンドセットです。 マウスがストリ ームモードの場合、ホストは任意に他のコマンドを送る前に、コマンドF5hでデ ータレポートを禁止するべきです。 ・FFh (リセット) マウスはこのコマンドに「肯定」(FAh)で応答します。 その後、リセット・モードになります。 ・FEh (再送信) マウスから無効なデータを受信した場合に、ホストは常このコマンドを送り ます。 マウスはホストへ送った最後(脚注2)のパケット(脚注3)を再び送り ます。 マウスが異なる無効なパケットで「再送信」コマンドに応答した場 合にホストは、「再送信要求」コマンド 、「エラー」コマンド、マウスを リセットする為にマウス電源の供給と停止の繰り返や、通信の禁止(クロッ クラインをLowに設定)などの方法で対応する事があり、手段はホストに依存 します。 ・F6h (セット・デフォルト) マウスは「肯定」(FAh)で応答した後、次の値を設定します。 サンプリングレート = 100、 解像度 = 4カウント/mm、 スケーリング = 1:1、 データレポート禁止、 その後、マウスは移動量をリセットしストリームモードになります。 ・F5h (データレポート禁止) マウスは「肯定」(FAh)で応答した後に、データレポートを禁止にし、移動量 カウンターをリセットします。 ストリームモードにおけるデータレポート のみに影響を及ぼしますが、サンプリングに影響することはありません。 禁止中のストリームモードはリモートモードと同じです。 ・F4h (データレポート許可) マウスは「肯定」(FAh)で応答した後、データレポートを可能にし、移動量 カウンターをリセットします。 マウスがリモートモード(あるいはストリー ムモード)である間に、このコマンドは出されるかもしれません。 しかし それは、ストリームモードのデータレポートにのみ影響します。 ・F3h (サンプルレート) マウスは「肯定」(FAh)で応答しその後、ホストからもう1バイトを読みます 。 マウスは新しいサンプルレートとしてこのバイトを保存します。 サンプルレートを受け取った後に、マウスは再び「肯定」(0xFA)で応答し、 移動量カウンターをリセットします。 有効なサンプルレートは、10、20、 40、60、80、100および200サンプル/秒です。 ・F2h (装置ID取得) マウスは「肯定」(FAh)の後に装置IDを続けて送信します。(標準のPS/2マウ スの場合は00h。)。 マウスはさらに移動カウンターをリセットします。 ・F0h (リモートモード設定) マウスは「肯定」(FAh)で応答後、移動量カウンターをリセットし、リモー トモードになります。 ・EEh (ラップモード設定) マウスは「肯定」(FAh)で応答後、移動カウンターをリセットし。 ラップ・ モードになります。 ・ECh (リセット・ラップ・モード) マウスは「肯定」(FAh)で応答後、移動量カウンターをリセットし、ラップ ・モードになる以前のモードになります。(ストリーム・モードあるいはリ モート・モード。) ・EBh (データ読み出し) マウスは「肯定」(FAh)で応答後、移動量データ・パケットを送ります。 これはリモート・モードにおけるデータ読み出しの唯一の方法です。 データ・パケット送信後に移動量カウンターをリセットします。 ・EAh (ストリームモード設定) マウスは「肯定」で応答後、移動量カウンターをリセットし、ストリームモ ードになります。 ・E9h (ステータス・リクエスト) マウスは「肯定」で応答後、次の3バイトのステータス・パケットを送信しま す。(その後、移動量カウンターをリセットします。) Byte 1 Bit 7 常に 0 Bit 6 モード ( 0=ストリーム、1=リモート ) Bit 5 レポート許可 ( 0=禁止、1=許可 ) Bit 4 比率 ( 0= 1:1、1=2:1 ) Bit 3 常に 0 Bit 2 左ボタン ( 1=オン ) Bit 1 中央釦 ( 1=オン ) Bit 0 右ボタン ( 1=オン ) Byte 2 Bit 7-0 解像度 ( 10,20,40,60,80,100,200 ) Byte 3 Bit 7-0 レポートレート 右釦、中央釦、左ボタン = 1= 釦が押された状態。 0= 釦が押されない状態。 比率 = 1 はスケーリングが2:1である場合。 0 はスケーリングが1:1である場合。 (コマンドE7hおよびE6hを参照。) レポート許可 = 1 はデータレポート許可。 0 はデータレポート禁止。(コマンドF5hおよびF4hを参照。) モード = 1 はリモートモードが可能。 0 はりストリームモードが可能。 (コマンドF0hおよびEAhを参照。) ・E8h (解像度設定) マウスは「肯定」(FAh)で応答後、ホストから1バイトを受信し、再び肯定」 (FAh)で応答します。 その後、移動量カウンターをリセットします 。 ホストから受信したバイトは以下のように解像度を決定します: 受信データ 解像度 ------------+---------------------- 0x00 1 カウント/mm 0x01 2 カウント/mm 0x02 4 カウント/mm 0x03 8 カウント/mm ・E7h (比率 2:1 設定) マウスは「肯定」(FAh)で応答後、比率を2:1にします。 (既に記述があります。) ・E6h(比率 1:1 設定) マウスは「肯定」(FAh)で応答後、比率を1:1にします。 (既に記述があります。) 標準のPS/2マウスがホストへ送ることが出来るコマンドは、「再送」(FEh)と、 「エラー」(FCh)です。 両方とも、ホストから装置へのコマンドと同様の働き をします。 Command Set: The following is the set of command accepted by the standard PS/2 mouse . If the mouse is in Stream mode, the host should disable data reporting (command F5h) before sending any other commands. ・FFh (Reset) - The mouse responds to this command with "acknowledge" (FAh) then enters Reset Mode. ・FEh (Resend) - The host sends this command whenever it receives invalid data from the mouse. The mouse responds by resending the last(2) packet(3) it sent to the host. 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). The action taken depends on the host. ・F6h (Set Defaults) - The mouse responds with "acknowledge" (FAh) then loads the following values: Sampling rate = 100, Resolution = 4 counts/mm, Scaling = 1:1, Disable Data Reporting. The mouse then resets its movement counters and enters stream mode. ・F5h (Disable Data Reporting) - The mouse responds with "acknowledge" (FAh) then disables data reporting and resets its movement counters. This only effects data reporting in Stream mode and does not disable sampling. Disabled stream mode funcions the same as remote mode. ・F4h (Enable Data Reporting) - The mouse responds with "acknowledge" (FAh) then enables data reporting and resets its movement counters. 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. ・F3h (Set Sample Rate) - The mouse responds with "acknowledge" (FAh) then reads one more byte from the host. 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. Valid sample rates are 10, 20, 40, 60, 80, 100, and 200 samples/sec. ・F2h (Get Device ID) - The mouse responds with "acknowledge" (FAh) followed by its device ID (00h for the standard PS/2 mouse.) The mouse should also reset its movement counters. ・F0h (Set Remote Mode) - The mouse responds with "acknowledge" (FAh) then resets its movement counters and enters remote mode. ・EEh (Set Wrap Mode) - The mouse responds with "acknowledge" (FAh) then resets its movement counters and enters wrap mode. ・ECh (Reset Wrap Mode) - The mouse responds with "acknowledge" (FAh) then resets its movement counters and enters the mode it was in prior to wrap mode (Stream Mode or Remote Mode.) ・EBh (Read Data) - The mouse responds with acknowledge (FAh) then sends a movement data packet. This is the only way to read data in Remote Mode. After the data packets has been successfully sent, it resets its movement counters. ・EAh (Set Stream Mode) - The mouse responds with "acknowledge" then resets its movement counters and enters steram mode. ・E9h (Status Request) - The mouse responds with "acknowledge" then sends the following 3-byte status packet (then resets its movement counters.): Byte 1 Bit 7 Always 0 Bit 6 Mode Bit 5 Enable Bit 4 Scaling Bit 3 Always 0 Bit 2 Left Button Bit 1 Middle Button Bit 0 Right Button Byte 2 Bit 7-0 Resolution Byte 3 Bit 7-0 Sample Rate Right, Middle, Left Btn = 1 if button pressed; 0 if button is not pressed. Scaling = 1 if scaling is 2:1; 0 if scaling is 1:1. (See commands E7h and E6h) Enable = 1 if data reporting is enabled; 0 if data reporting is disabled. (See commands F5h and F4h) Mode = 1 if Remote Mode is enabled; 0 if Stream mode is enabled. (See commands F0h and EAh) ・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: Byte Read from Host Resolution 0x00 1 count/mm 0x01 2 count/mm 0x02 4 count/mm 0x03 8 count/mm ・E7h (Set Scaling 2:1) - The mouse responds with acknowledge (FAh) then enables 2:1 scaling (discussed earlier in this document.) ・E6h (Set Scaling 1:1) - The mouse responds with acknowledge (FAh) then enables 1:1 scaling (discussed earlier in this document.) 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. 2.12. 初期化 通常PS/2マウスが検知/初期化されるのは、コンピューターがブートしている ときに限られます。 すなわち、マウスはホットプラグ接続可能ではありませ ん。 また、PS/2マウスを追加/削除する場合は、常にコンピューターをリス タートしなければなりません。 コンピューターの稼働中に、PS/2マウスを追加/削除することでマザーボード が破損するおそれがあります。 稼動中のPS/2マウスの初期検出。 マウスの検出が出来れば、BIOSはオペレ ーティング・システムによるマウスの組込や使用を認めるでしょう。 あるいはマウスのバス上の通信を禁止することも出来るでしょう。 コンピューターを立上げた時のマウス接続、ウインドウズ稼働中のマウスの分 離や接続、OSによるマウス再接続の検出などができるかもしれません。 マイクロソフトがサポートを検討した結果、稼働効率が50%になりました。 下記は標準のPS/2マウスとWin98を使用したコンピュータ間のブート時の通信 内容です。 典型的なPS/2マウスの標準的な初期化の下記コマンドシーケンスを、PS/2マウ スをエミュレートする場合の参考にしてください。 Initialization: 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.) 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 may be able to detect the mouse was reattached. Microsoft tried to support this, but it only works about 50% of the time. 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... Power-on Reset: Mouse: AA Self-test passed Mouse: 00 Mouse ID Host: FF Reset command Mouse: FA Acknowledge Mouse: AA Self-test passed Mouse: 00 Mouse ID Host: FF Reset command Mouse: FA Acknowledge Mouse: AA Self-test passed Mouse: 00 Mouse ID Host: FF Reset command Mouse: FA Acknowledge Mouse: AA Self-test passed Mouse: 00 Mouse ID Host: F3 Set Sample Rate : Attempt to Enter Microsoft Mouse: FA Acknowledge : Scrolling Mouse mode Host: C8 decimal 200 : Mouse: FA Acknowledge : Host: F3 Set Sample Rate : Mouse: FA Acknowledge : Host: 64 decimal 100 : Mouse: FA Acknowledge : Host: F3 Set Sample Rate : Mouse: FA Acknowledge : Host: 50 decimal 80 : Mouse: FA Acknowledge : Host: F2 Read Device Type : Mouse: FA Acknowledge : Mouse: 00 Mouse ID : Response 03 if microsoft scrolling mouse Host: F3 Set Sample Rate Mouse: FA Acknowledge Host: 0A decimal 10 Mouse: FA Acknowledge Host: F2 Read Device Type Mouse: FA Acknowledge Mouse: 00 Mouse ID Host: E8 Set resolution Mouse: FA Acknowledge Host: 03 8 Counts/mm Mouse: FA Acknowledge Host: E6 Set Scaling 1:1 Mouse: FA Acknowledge Host: F3 Set Sample Rate Mouse: FA Acknowledge Host: 28 decimal 40 Mouse: FA Acknowledge Host: F4 Enable Mouse: FA Acknowledge Initialization complete... If I then press the Left Button... Mouse: 09 1 1 00001001; bit0 = Left button state; bit3 = always 1 Mouse: 00 1 1 No X-movement Mouse: 00 1 1 No Y-movement ... and release the Left Button: Mouse: 08 0 1 00001000 bit0 = Left button state; bit3 = always 1 Mouse: 00 1 1 No X-movement Mouse: 00 1 1 No Y-movement The following is the communication between my computer (running Win98SE) and mouse when it boots up with an (emulated) Intellimouse... Power-on Reset: Mouse: AA Self-test passed Mouse: 00 Mouse ID Host: FF Reset command Mouse: FA Acknowledge Mouse: AA Self-test passed Mouse: 00 Mouse ID Host: FF Reset command Mouse: FA Acknowledge Mouse: AA Self-test passed Mouse: 00 Mouse ID Host: FF Reset command Mouse: FA Acknowledge Mouse: AA Self-test passed Mouse: 00 Mouse ID Host: F3 Set Sample Rate : Attempt to Enter Microsoft Mouse: FA Acknowledge : Scrolling Mouse mode Host: C8 decimal 200 : Mouse: FA Acknowledge : Host: F3 Set Sample Rate : Mouse: FA Acknowledge : Host: 64 decimal 100 : Mouse: FA Acknowledge : Host: F3 Set Sample Rate : Mouse: FA Acknowledge : Host: 50 decimal 80 : Mouse: FA Acknowledge : Host: F2 Read Device Type : Mouse: FA Acknowledge : Mouse: 03 Mouse ID : Response 03 if microsoft scrolling mouse Host: E8 Set Resolution Mouse: FA Acknowledge Host: 03 8 counts/mm Mouse: FA Acknowledge Host: E6 Set scaling 1:1 Dev: FA Acknowledge Host: F3 Set Sample Rate Mouse: FA Acknowledge Host: 28 decimal 40 Mouse: FA Acknowledge Host: F4 Enable device Mouse: FA Acknowledge If I then press the left mouse button: Mouse: 09 00001001 bit0 = Left button state; bit3 = always 1 Mouse: 00 No X-movement Mouse: 00 No Y-movement Mouse: 00 No Z-movement ...and then release the left mouse button button: Mouse: 08 00001000 bit0 = Left button state; bit3 = always 1 Mouse: 00 No X-movement Mouse: 00 No Y-movement Mouse: 00 No Z-movement After I downloaded/installed the Microsoft's Intellimouse drivers with support for the 4th and 5th buttons, the following sequence was found: ... (starts same as before) ... Host: F3 Set Sample Rate : Attempt to Enter Microsoft Mouse: FA Acknowledge : Scrolling Mouse mode. Host: C8 decimal 200 : Mouse: FA Acknowledge : Host: F3 Set Sample Rate : Mouse: FA Acknowledge : Host: 64 decimal 100 : Mouse: FA Acknowledge : Host: F3 Set Sample Rate : Mouse: FA Acknowledge : Host: 50 decimal 80 : Mouse: FA Acknowledge : Host: F2 Read Device Type : Mouse: FA Acknowledge : Mouse: 03 Mouse ID :Response 03 if microsoft scrolling mouse. Host: F3 Set Sample Rate : Attempt to Enter Microsoft 5-button Mouse: FA Acknowledge : Scrolling Mouse mode. Host: C8 decimal 200 : Mouse: FA Acknowledge : Host: F3 Set Sample Rate : Mouse: FA Acknowledge : Host: C8 decimal 200 : Mouse: FA Acknowledge : Host: F3 Set Sample Rate : Mouse: FA Acknowledge : Host: 50 decimal 80 : Mouse: FA Acknowledge : Host: F2 Read Device Type : Mouse: FA Acknowledge : Mouse: 04 Mouse ID : Response 04 if 5-button scrolling mouse. ... rest of initialization same as before ... 2.13. 脚注 (1) 2:1スケーリングは、ストリームモードにおける自動のデータレポートの みに該当し、「リード・データ」コマンドに応じて送られるデータレポー トには影響がありません。 (2) マウスとホストは「再送信」コマンドの保存を行いません。 「再送信」コマンドに対する応答が「再送信」になることはありません。 (3) 1パケットとは、 3バイトの移動量データ・パケット、 4バイトの移動データ・パ ケット(インテリマウス用)、 3バイトのステータス・パケット(参照「ステータス要求」コマンド)、 2バイト完成コード-IDパケット(AAh、00hあるいはFCh、00h)、 あるいはコマンドに対する1バイトの応答。 などを示します。 Footnotes: 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. 2) The mouse and host do not buffer "Resend" commands. This means "Resend" will never be sent in response to the "Resend" command. 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. ー 以上 −
Topへ
inserted by FC2 system