HID class請求
HID裝置除了标準的USB請求之外,還有特殊的class請求,首先bRequestType字段定義如下:
bmRequestType:
7 資料傳輸方向
0 主機到裝置
1 裝置到主機
6~5 類型
1 Class
4~0 接收者
1 Interface
bRequest請求代碼定義如下:
0x01 GET_REPORT
0x02 GET_IDLE
0x03
0x04~0x08 Reserved
0x09 SET_REPORT
0x0a SET_IDLE
0x0b SET_PROTOCOL
1 GET_REPORT
bmRequestType 1010001
bRequest GET_REPORT
wValue 報告類型和報告ID
wIndex 接口
wLength 報告長度
該請求用于主機通過控制管道去擷取裝置報告,報告的類型有:
01 Input
02 Output
03 Feature
04~FF Reserved
2 GET_IDLE
bmRequestType 1010001
bRequest SET_REPORT
wValue 0和報告ID
wIndex 接口
wLength 1
3 GET_PROTOCOL
bmRequestType 1010001
bRequest GET_PROTOCOL
wValue 0
wIndex 接口
wLength 1
傳回裝置是處于boot protocol還是report protocol,如果裝置的SubClass為boot,那麼該請求必須支援。
4 SET_REPROT
bmRequestType 0010001
bRequest SET_REPORT
wValue 報告類型和報告ID
wIndex 接口
wLength 報告長度
該請求用于主機向裝置發送報告,該報告為輸出報告,例如:USB主機向USB鍵盤發送的LED顯示資訊報告。當USB裝置沒有輸出中斷端點時,可以通過端點0來發送報告。
5 SET_IDLE
bmRequestType 0010001
bRequest SET_IDLE
wValue Duration和報告ID
wIndex 接口
wLength 0
6 SET_PROTOCOL
bmRequestType 0010001
bRequest SET_PROTOCOL
wValue 0 Boot Protocol
1 Report Protocol
wIndex 接口
wLength 0
在boot protocol和report protocol之前切換,如果裝置的SubClass為boot,那麼該請求必須支援。