What is the data transmit format for PS2 mouse in different systems?
According to different Host systems, PS2 Mouse support different function mode, namely 3Key Mode and 5Key Mode. Host send download command 0XF3 and then send Sample Rate information, it can be judged by Sample Rate information to know the device is 3Key Mode or 5Key Mode.
1.5Key Mode. Product that be developed using SONIX PS2 Lib Platform support 3D5Key under Win2000/XP/Vista system, namely 5Key Mode, the specific data format is as follows:
Byte1:
Bit [2:0] middle right left bits and support multiple keys pressed at the same time, "1" means the corresponding button pressed, "0" shows the button is released;
Bit [3] always "1", when "0", PS2 port upload data abortion;
Bit [5:4] X sign bit and Y sign bit, two bits represent PS2 actual upload the highest bit (sign bit) of X, Y data;
Bit [7:6] X, Y overflow flag bit, generally do not take into account, the default is "0."
Byte2:
Displacement of X direction, make necessary reverse action according to the actual direction of Sensor, the action affect Byte1 [4];
Byte3:
Displacement of Y direction, make necessary reverse action according to the actual direction of Sensor, the action affect Byte1 [5];
Byte4:
Bit [3:0] wheel upload data, the range is -8 ~ +7, forward is 0x0F, backward is 0x01;
Bit [5:4] 4Key、5Key bits,"1" means the corresponding button pressed, "0" shows the button is released;
Bit [7:6] reserved bits, the default is "0."
2.3Key Mode. Using SONIX PS2 Lib platform developed products support 3D3Key under Win98, namely 3Key Mode, the specific data format is as follows:
Byte1 ~ Byte3 information format of above picture is the same with 5Key Mode, Byte4 is different.
Byte4: Wheel significant bit is still the low nibble, the range is -8 to +7, the high nibble data is only for extension sign bit. However, when the wheel forward upload data is 0xFF, when wheel backward data should be 0x01.
So for user, how to distinguish between 3Key Mode and 5Key Mode? We can use mouse_id to determine from U + P Lib, when mouse_id = 3 (or ID_3KEY), it is 3Key Mode; when mouse_id = 4 (or ID_5KEY), it is 5Key Mode, User can use mouse_id to determine the specific transmission data of Byte4.