USB Human Interface Devices: Difference between revisions

m
→‎USB mouse: Del duplicate
[unchecked revision][unchecked revision]
m (→‎USB Report Protocol: Del section misplaced)
m (→‎USB mouse: Del duplicate)
Line 173:
|Reserved, must be zero.
|}
 
== USB mouse ==
USB mice, just like any other HID device, communicate with the software using reports, which are sent via interrupt endpoints or can be manually requested with the "GetReport" request. USB mice have a protocol value of 2 in the interface descriptor.
 
=== Report format ===
This report must be requested by the host using interrupt transfers once every interval milliseconds. Interval is defined in the interrupt IN descriptor of the USB mouse device. Only the first three bytes of the USB mouse report are defined. The remaining bytes, if existed, may be used for device-specific features. Software may request only three bytes in an interrupt transfer, and this will not cause an error even if the actual packet is larger. The table below defines the report format for USB mice operating using the boot protocol.
{| width="70%" border="1"
|-
|'''Offset'''
|'''Size'''
|'''Description'''
|-
|0
|Byte
|Button status.
|-
|1
|Byte
|X movement.
|-
|2
|Byte
|Y movement.
|}
 
 
'''Button status:''' This byte is a bitfield, in which the lowest three bits are standard format. The remaining 5 bits may be used for device-specific purposes.
 
{| width="70%" border="1"
|-
|'''Bit'''
|'''Bit Length'''
|'''Description'''
|-
|0
|1
|When set to 1, indicates the left mouse button is being clicked.
|-
|1
|1
|When set to 1, indicates the right mouse button is being clicked.
|-
|2
|1
|When set to 1, indicates the middle mouse button is being clicked.
|-
|3
|5
|These bits are reserved for device-specific features.
|}
 
 
'''X movement:''' This is a signed 8-bit integer that represents the X movement. Bit 7 (value 0x80) determines the sign of the value. When this value is negative, the mouse is being moved to the left. When this value is positive, the mouse is being moved to the right. Notice that unlike PS/2 mice, the movement values for USB mice are 8-bit signed integers and not 9-bit integers.
 
'''Y movement:''' This is also a signed 8-bit integer that represents the Y movement. When this value is negative, the mouse is being moved up. When the value is positive, the mouse is being moved down (towards the user.)
 
== USB mouse ==
Anonymous user