Mouse Input: Difference between revisions

Jump to navigation Jump to search
4,849 bytes added ,  15 years ago
add a lot of text ( tables, whole command list..) and add some definations, however non clean up on structure ..
[unchecked revision][unchecked revision]
m (→‎PS2 Mouse -- Basic Operation (M$ compliant): changed to a more neutral title)
(add a lot of text ( tables, whole command list..) and add some definations, however non clean up on structure ..)
Line 26:
generated by the auxiliary PS2 input port.
 
==== PS2 Mouse Subtypes====
There are several types of mice, but they can be separated into two groups, depending on whether they have a scroll wheel.
Mice with scroll wheels can send an additional byte in each mouse packet,
Line 49:
for deltaX and deltaY are one or two for slow movement, and perhaps 20 for very fast movement. Maximum possible
values are +255 to -256 (they are 9-bit quantities, two's complement).
The meaning of the packets is like this:
<br>
<br>
byte 1:
{| border="1" cellspacing="0" cellpadding="5" align="center"
! Y overflow
! X overflow
! Y sign bit
! X sign bit
! Always 1
! Middle Btn
! Left Btn
! Right Btn
|}
<br>
byte 2:
{| border="1" cellspacing="0" cellpadding="5" align="center"
! X movement
|}
<br>
byte 3:
{| border="1" cellspacing="0" cellpadding="5" align="center"
! Y movement
|}
 
The top two bits of the first byte (values 0x80 and 0x40) supposedly show Y and X overflows, respectively. They
Line 80 ⟶ 104:
* 2 -- horizontal scroll right one click
* 0xE -- horizontal scroll left one click
 
It will look something like this, when only 1 scroll has been activatet:
<br>
byte 4:
{| border="1" cellspacing="0" cellpadding="5" align="center"
! Z movement
|}
However if you mangede to have a 2 scroll wheel ( or 5 btn) and init, then it will look like this :
<br>
byte 4:
{| border="1" cellspacing="0" cellpadding="5" align="center"
! Always 0
! Always 0
! 5th btn
! 4th btn
! Z3
! Z2
! Z1
! Z0
|}
Here is Z3 though Z0 is a signed value, of the Z movement (scroll) if it is increased/ decreased with 2, then it is the vertical scroll wheel, else it is just the horizontal scroll wheel.<br>
If a button is pressed, then the value for the button will be “1”, and when not pressed “0”.
 
====Non-Linear Movement====
Line 116 ⟶ 162:
===PS2 Mouse Commands===
 
After the PS2 Aux port has been enabled, you can send commands to the mouse. It is Recommended to disable packets while "re"programming the mouse.
 
====Waiting to Send Bytes to Port 60 and 64====
Line 130 ⟶ 176:
It is required to wait until the mouse sends back a 0xFA acknowledgement byte, after each command byte,
before sending the next 0xD4. (Note: reset commands might not be ACK'ed -- wait for the 0xAA after a reset.)
Some commands generate 2 ACK, 1 for the command, and 1 for reciving data.
====Mouse Command Set====
 
 
{| border="1" cellspacing="0" cellpadding="5" align="center"
! Hex value
! Meaning
! Describing
|-
! 0xFF
! reset
! The mouse sends ACK (0xFA) and resets.
|-
! 0xFE
! resend
! this command makes the mouse sends its second last packet to the host again.
|-
! 0xF6
! Set Defaults
! The mouse sends ACK (0xFA) and applies default values
|-
! 0xF5
! Disable Data Reporting
! The mouse sends ACK (0xFA) and disable data reporting.
|-
! 0xF4
! enable Data Reporting
! The mouse sends ACK (0xFA) and enables data reporting
|-
! 0xF3
! Set Sample Rate
! The mouse sends ACK (0xFA) and waits for the next data, written to the mouse, to be the sample rate
|-
! 0xF2
! Get Device ID
! The mouse sends ACK (0xFA) and sends its ID, though the DATA port
|-
! 0xF0
! Set Remote Mode
! The mouse sends ACK (0xFA) and then reset its movement counters, and enters remote mode
|-
! 0xEE
! Set Wrap Mode
! The mouse sends ACK (0xFA) and then reset its movement counters, and enters warp mode
|-
! 0xEC
! Reset Wrap Mode
! The mouse sends ACK, and then enters the last mode, before entering wrap mode, it also resets its movement counters
|-
! 0xEB
! Read Data
! The mouse sends ACK, followed by the first packet, and so on, until It have sent all.
|-
! 0xEA
! Set Stream Mode
! The mouse sends ACK (0xFA) and then reset its movement counters, and enters reporting mode
|-
! 0xE9
! Status Request
! The mouse sends ACK, and sends afterwards the status bytes ( 3 bytes in a row, remember to wait each time for new data)
|-
! 0xE8
! Set Resolution
! The mouse sends ACK and waits for the next data, written to the mouse, to be the resolution
|-
! 0xE7
! Set Scaling 2:1
! The mouse sends ACK and set scaling 2:1
|-
! 0xE6
! Set Scaling 1:1
! The mouse sends ACK and set scaling 1:1
 
|}
<br>
The status byte looks like this:
<br>
Byte 1:
{| border="1" cellspacing="0" cellpadding="5" align="center"
! Always 0
! mode
! enable
! scaling
! Always 0
! left btn
! middle
! right btn
|}
Byte 2:
{| border="1" cellspacing="0" cellpadding="5" align="center"
!resoltion
|}
Byte 3:
{| border="1" cellspacing="0" cellpadding="5" align="center"
!sample rate
|}<br>
Mode: if it is 1, the current mode is remote mode; if 0 then it is stream mode <br>
Enable: if it is 1, then data reporting is enabled; if 0 then data reporting is disabled<br>
Scaling: if it is 1, scaling 2:1 is enabled; if 0 then scaling 1:1 is enabled.<br>
 
 
=====Resolution, Scaling and Sampling rate =====
Those is some options about the mouse, when you move it, and about how many packets it can make pr second.
Resolution: this is how many packets pr millimeter movement.
Scaling: is a change to the packet reported for each millimeter.
Sampling rate: this is how many packets the mouse can send pr second.
Those “options” can (of cause) have different value, so let’s sum them up:
Resolution:
 
{| border="1" cellspacing="0" cellpadding="5" align="center"
! value
! resolution
|-
!0x00
!1 count /mm
|-
!0x01
!2 count /mm
|-
!0x02
!4 count /mm
|-
!0x03
!8 count /mm
|}
<br>
For scaling, there is not many possibilities, since it can either be “1:1” or “2:1”, but looking at the scheme (below) we can see what happens if it is “2:1”
 
{| border="1" cellspacing="0" cellpadding="5" align="center"
! Movement Counter
! Reported Movement
|-
!0
!0
|-
!1
!1
|-
!2
!1
|-
!3
!3
|-
!4
!6
|-
!5
!9
|-
!more than 5
!2 * Movement Counter
|}
<br>
Sampling rate can have the following values: (all values is Decimal, NOT hex)<br>
{| border="1" cellspacing="0" cellpadding="5" align="center"
! value
! Samples pr second
|-
!10
!10
|-
!20
!20
|-
!40
!40
|-
!60
!60
|-
!80
!80
|-
!100
!100
|-
!200
!200
|}
 
====Partial Command Set====
* 0xFF -- reset (mouse responds with 0xAA, 0x00, and needs to be reinitialized)
* 0xEB -- request mouse packet
* 0xF4 -- enable automatic packets
* 0xF5 -- disable packets
* 0xF3 -- set packet "sample rate"<br>
{possible values are 80 (0x50), 100 (0x64), or 200 (0xC8) samples per second}
* 0xF2 -- get mouseID
* 0xE8 -- set resolution (pixels/mm)<br>
(possible values are 0, 1, 2, or 3 -- meaning 1, 2, 4, or 8 pixels/mm)
 
===Initializing a PS2 Mouse===
Line 197 ⟶ 413:
 
====Init/Detection Command Sequences====
If you would like more than just 3 buttons, you will have to use the following sequence(s).
If mouseID is 0, send: Set Samplerate 200, Set Samplerate 100, Set Samplerate 80, Get MouseID.
if a sequence is accepted, then the number of packets change ( see Format of First 3 Packet Bytes, and the Format of the optional 4 Packet Bytes), also notic the mouse ID changes if the sequence is accepted. So if the sequence is not accepted, the ID remains, if accpeted it change.
If mouseID changed to 3, mouse has a scroll wheel, and is now in 4 byte packet mode.
 
If mouseID is 3, send: Set Samplerate 200, Set Samplerate 200, Set Samplerate 80, Get MouseID.
The first sequence goes like this:
If mouseID changed to 4, mouse has 5 mouse buttons -- otherwise only 3.
* set sample to 200
* set sample to 100
* set sample to 80
* get the id
<br>
this will only activate the scroll wheel
 
 
* set sample to 200
* set sample to 200
* set sample to 80
* get the id
<br>
this will activate the scroll wheel, and the 4th and 5th button.
 
in order to try the second, you will need to do the first, you can not just skip the first.
 
====Enable Packets====
Line 228 ⟶ 460:
* [http://www.win.tue.nl/~aeb/linux/kbd/scancodes-13.html Linux PS2 mouse article with non-Microsoft mouse info]
* [http://houbysoft.xf.cz/download/ps2mouse.html Tutorial with sample C code]
* [http://www.webmasteren.eu/PS_mouse.pdf KMT dk's tutorial]
* [http://www.computer-engineering.org www.Computer-Engineering.org]
* [http://www.mcamafia.de/pdf/ibm_hitrc07.pdf IBM's Keyboard and Auxiliary Device (mouse) Controller documentation]
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu