SlideShare a Scribd company logo
1 of 20
Download to read offline
USB HID Learning Record
版本:v0.6
Crifan Li
摘要
本文主要介绍了USB HID的基本知识,以及举例说明如何解析HID Report

本文提供多种格式供:
在线阅读

HTML

1

下载(7zip压缩包)

HTML

8

HTMLs

PDF

3

HTMLs

PDF

10

2

9

CHM

4

CHM

11

TXT

5

TXT

12

RTF

6

RTF

13

HTML版本的在线地址为:
http://www.crifan.com/files/doc/docbook/usb_hid/release/html/usb_hid.html
有任何意见,建议,提交bug等,都欢迎去讨论组发帖讨论:
http://www.crifan.com/bbs/categories/usb_hid/

修订历史
修订 0.4

2011-06-16

crl

2013-09-05

crl

1. 写好了USB HID基本内容
修订 0.6
1. 通过Docbook发布
2. 更新了所有xml:id

1

http://www.crifan.com/files/doc/docbook/usb_hid/release/html/usb_hid.html
http://www.crifan.com/files/doc/docbook/usb_hid/release/htmls/index.html
3
http://www.crifan.com/files/doc/docbook/usb_hid/release/pdf/usb_hid.pdf
4
http://www.crifan.com/files/doc/docbook/usb_hid/release/chm/usb_hid.chm
5
http://www.crifan.com/files/doc/docbook/usb_hid/release/txt/usb_hid.txt
6
http://www.crifan.com/files/doc/docbook/usb_hid/release/rtf/usb_hid.rtf
7
http://www.crifan.com/files/doc/docbook/usb_hid/release/webhelp/index.html
8
http://www.crifan.com/files/doc/docbook/usb_hid/release/html/usb_hid.html.7z
9
http://www.crifan.com/files/doc/docbook/usb_hid/release/htmls/index.html.7z
10
http://www.crifan.com/files/doc/docbook/usb_hid/release/pdf/usb_hid.pdf.7z
11
http://www.crifan.com/files/doc/docbook/usb_hid/release/chm/usb_hid.chm.7z
12
http://www.crifan.com/files/doc/docbook/usb_hid/release/txt/usb_hid.txt.7z
13
http://www.crifan.com/files/doc/docbook/usb_hid/release/rtf/usb_hid.rtf.7z
14
http://www.crifan.com/files/doc/docbook/usb_hid/release/webhelp/usb_hid.webhelp.7z
2

WEBHELP
7

WEBHELP
14
USB HID Learning Record:
Crifan Li

版本:v0.6
出版日期 2013-09-05
版权 © 2012 Crifan, http://crifan.com
15

本文章遵从:署名-非商业性使用 2.5 中国大陆(CC BY-NC 2.5)

15

http://www.crifan.com/files/doc/docbook/soft_dev_basic/release/html/soft_dev_basic.html#cc_by_nc
目录
1. USB HID基础知识 ................................................................................................................ 1
1.1. USB HID Structure ................................................................................................... 1
1.2. HID descriptor ......................................................................................................... 2
1.2.1. HID Class Structure ....................................................................................... 3
1.2.2. Short Items ................................................................................................... 4
1.2.3. Long Items .................................................................................................... 5
1.2.4. Main Items .................................................................................................... 6
1.2.5. Global Items .................................................................................................. 7
1.2.6. Local Items .................................................................................................... 8
1.3. Usage Page Summary .............................................................................................. 9
2. HID Report Example ......................................................................................................... 10
2.1. Normal examples ................................................................................................... 10
2.1.1. Generic mouse ............................................................................................ 10
2.1.2. Keyboard ..................................................................................................... 11
2.2. An HID Report Example analysis ........................................................................... 12

iii
插图清单
1.1.
1.2.
1.3.
1.4.
1.5.
1.6.
1.7.
1.8.
1.9.
2.1.
2.2.
2.3.
2.4.

USB HID Structure ........................................................................................................... 1
HID descriptor ................................................................................................................. 2
HID Class Structure .......................................................................................................... 3
HID Short Items ............................................................................................................... 4
HID Long Items ............................................................................................................... 5
HID Main Items ............................................................................................................... 6
HID Global Items ............................................................................................................. 7
HID Local Items ............................................................................................................... 8
HID Usage page summary ............................................................................................... 9
HID Report Example - 3 button mouse ......................................................................... 10
HID Report Example - keyboard - 1/2 ........................................................................... 11
HID Report Example - keyboard - 2/2 ........................................................................... 12
HID Data Format ........................................................................................................... 13

iv
第 1 章 USB HID基础知识
1.1. USB HID Structure
图 1.1. USB HID Structure

1
USB HID基础知识

1.2. HID descriptor
图 1.2. HID descriptor

2
USB HID基础知识

1.2.1. HID Class Structure
图 1.3. HID Class Structure

3
USB HID基础知识

1.2.2. Short Items
图 1.4. HID Short Items

4
USB HID基础知识

1.2.3. Long Items
图 1.5. HID Long Items

5
USB HID基础知识

1.2.4. Main Items
图 1.6. HID Main Items

6
USB HID基础知识

1.2.5. Global Items
图 1.7. HID Global Items

7
USB HID基础知识

1.2.6. Local Items
图 1.8. HID Local Items

8
USB HID基础知识

图 1.9. HID Usage page summary

1.3. Usage Page Summary

9
第 2 章 HID Report Example
2.1. Normal examples
2.1.1. Generic mouse
3-button mouse:

图 2.1. HID Report Example - 3 button mouse

Note: above data’s format is:
05 01 = 0x 01 05
09 02 = 0x 02 09

10
HID Report Example

2.1.2. Keyboard
图 2.2. HID Report Example - keyboard - 1/2

11
HID Report Example

图 2.3. HID Report Example - keyboard - 2/2

2.2. An HID Report Example analysis
Follow is the example.
According to the format, defined in specification:

12
HID Report Example

图 2.4. HID Data Format

Now to analysis the corresponding meaning for every group bytes:

Data send by LSB
The data is send by LSB, so when “0x45, 0xFF’ is sent, first send is “0x45”, second
send “0xFF”, the LSB is “0x45” located in low address, the MSB “0xFF” located
in high address, so the hex value is ”0xFF45“
0x06, 0x45, 0xFF,
0x0A, 0x00, 0xA0,
0xA1, 0x01,
0x75, 0x08,
0x96, 0x07, 0x01,
0x15, 0x00,
0x26, 0xFF, 0x00,
0x0A, 0x01, 0xA0,
0x91, 0x02,
0x75, 0x08,
0x95, 0x08,
0x0A, 0x02, 0xA0,
0x81, 0x02,
0xC0

[Data]

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0x06

0xFF

0x45

0000

01

10

0000 0110

Usage Page

Global item

2 bytes

0xFF45 -> 0xFF00 -0xFFFF
= Vendor defined
[Data]

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0x0A

0xA0

0x00

0000

10

10

0000 1010

Usage

Local item

2 bytes

Usage=0xA000

here Usage=0xA000 is just self defined, just need not confict with self's others, no other
special meaning
[Data]
bTag=7:4
bType=3:2
bSize=1:0
0xA1
0x01

1010

00

01

Application
(mouse,
keyboard)

Collection

Main item

1 bytes

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0x75

0x08

0111

01

01

0111 0101

Global item

1 bytes

Report Size = Report Size
0x08 bits

1010 0001

13
HID Report Example

[Data]

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0x96

0x01

0x07

1001

01

10

1001 0110

Report Count = 0x0107=263 Report Count Global item

2 bytes

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0x15

0x00

0001

01

01

0001 0101

Logical
= Minimum

Global item

1 bytes

Logical
Minimum
0x00
[Data]

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0x26

0x00

0xFF

0010

01

10

0010 0110

Logical
Maximum

Global item

2 bytes

Logical Maximum
=x00FF=255
[Data]

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0x0A

0xA0

0x01

0000

10

10

0000 1010

Usage

Local item

2 bytes

Usage = 0xA001

here Usage=0xA001 is just self defined, just need not confict with self's others, no other
special meaning
[Data]
bTag=7:4
bType=3:2
bSize=1:0
0x91
0x02

1001

00

01

1001 0001

0x02=0000
0010

Output

Main item

1 bytes

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0x75

0x08

0111

01

01

0111 0101

Report Size = Report Size
0x08 bits

Global item

1 bytes

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0x95

0x08

1001

01

01

1001 0101

Bit 1 { Variable
(1)}
All other bits
are Reserved
(0)

Report
Report Count Global item
Count= 0x08
=8

1 bytes

[Data]

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0x0A

0xA0

0x02

0000

10

10

0000 1010

Usage

Local item

2 bytes

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0x81

0x02

1000

00

01

1000 0001

0x02=0000
0010

Input

Main item

1 bytes

Usage = 0xA002

Bit 1 { Variable
(1)}
14
HID Report Example

[Data]
bTag=7:4
All other bits
are Reserved
(0)

bType=3:2

bSize=1:0

0x81

[Data]

bTag=7:4

bType=3:2

bSize=1:0

0xC0

1100

00

00

1100 0000

End
Collection

Main item

0 bytes

Closes an item collection

After analyze following data, the summary is:
Usage Page (0xFF45)

=Vendor-Specific

0xFF45 06 Global

Usage (0xA000)

0xA000 0A Local

Collection (Application)

0x01 A1 Main
Report Size (8)

0x08 75 Global

Report Count (263)

0x0107 96 Global

Logical Minimum (0)
Logical Maximum (255)
Usage (0xA001)

0x00 15 Global
0x00FF 26 Global
0xA0001 0A Local

Output (Variable)

0x02 91 Main

Report Size (8)

0x08 75 Global

Report Count (8)

0x08 95 Global

Usage (0xA002)

0xA002 0A Local

Input (Variable)

0x02 81 Main

End Collection

0xC0 Main

Report (Usage=0xA0000)
Output Report (Usage=0xA001)
263 bytes

Byte 0
Byte 1
...
...
Byte 261
Byte 262
Input Report (Usage=0xA002)

8 bytes

Byte 0
Byte 1
...
Byte 7

All of above means:
1. This is a vendor-specific HID device

15
HID Report Example
2. input or output is relative to Host side:

• Output = Host ⇒ Device = host send 263 bytes to device
• Input = Host ⇐ Device = device send 8 bytes to host

3. Every bytes value range is 0~255

16

More Related Content

Similar to Usb hid

Vvdi prog user manual v4.8.8
Vvdi prog user manual v4.8.8Vvdi prog user manual v4.8.8
Vvdi prog user manual v4.8.8OBD365
 
Xhorse Vvdi prog user manual 4.9.3
Xhorse Vvdi prog user manual 4.9.3Xhorse Vvdi prog user manual 4.9.3
Xhorse Vvdi prog user manual 4.9.3OBD365
 
Xhorse Vvdi prog user manual v4.7.7 -obdii365
Xhorse Vvdi prog user manual v4.7.7 -obdii365Xhorse Vvdi prog user manual v4.7.7 -obdii365
Xhorse Vvdi prog user manual v4.7.7 -obdii365OBD365
 
Bluetooth Module HC-06
Bluetooth Module HC-06Bluetooth Module HC-06
Bluetooth Module HC-06Raghav Shetty
 
[University] Capstone Design Project 2 (SAIOT)
[University] Capstone Design Project 2 (SAIOT)[University] Capstone Design Project 2 (SAIOT)
[University] Capstone Design Project 2 (SAIOT)창엽 양
 
Hardwear.io 2018 BLE Security Essentials workshop
Hardwear.io 2018 BLE Security Essentials workshopHardwear.io 2018 BLE Security Essentials workshop
Hardwear.io 2018 BLE Security Essentials workshopSlawomir Jasek
 
Loadnrun: UKIUA 2010 Presentation
Loadnrun: UKIUA 2010 PresentationLoadnrun: UKIUA 2010 Presentation
Loadnrun: UKIUA 2010 Presentationroydealsimon
 
Top Ten Siemens S7 Tips and Tricks
Top Ten Siemens S7 Tips and TricksTop Ten Siemens S7 Tips and Tricks
Top Ten Siemens S7 Tips and TricksDMC, Inc.
 
engage 2019 Workshop - Dirty Secrets of the Notes Client
engage 2019 Workshop - Dirty Secrets of the Notes Clientengage 2019 Workshop - Dirty Secrets of the Notes Client
engage 2019 Workshop - Dirty Secrets of the Notes ClientChristoph Adler
 
All You Need to Know About HCL Notes 64-Bit Clients
All You Need to Know About HCL Notes 64-Bit ClientsAll You Need to Know About HCL Notes 64-Bit Clients
All You Need to Know About HCL Notes 64-Bit Clientspanagenda
 
CollabSphere 2020 - INF105 - HCL Notes 11.0.1 FP1 - Performance Boost Re-Relo...
CollabSphere 2020 - INF105 - HCL Notes 11.0.1 FP1 - Performance Boost Re-Relo...CollabSphere 2020 - INF105 - HCL Notes 11.0.1 FP1 - Performance Boost Re-Relo...
CollabSphere 2020 - INF105 - HCL Notes 11.0.1 FP1 - Performance Boost Re-Relo...panagenda
 
CollabSphere 2020 Live - HCL Notes 11.0.1 FP1 - Performance Boost Re-Reloaded
CollabSphere 2020 Live - HCL Notes 11.0.1 FP1 - Performance Boost Re-ReloadedCollabSphere 2020 Live - HCL Notes 11.0.1 FP1 - Performance Boost Re-Reloaded
CollabSphere 2020 Live - HCL Notes 11.0.1 FP1 - Performance Boost Re-ReloadedChristoph Adler
 
Banana pi bpi-d1 user manual-en
Banana pi bpi-d1 user manual-enBanana pi bpi-d1 user manual-en
Banana pi bpi-d1 user manual-enwang lion
 
Smart City Lab 1 - Sensors and Actuators
Smart City Lab 1 - Sensors and ActuatorsSmart City Lab 1 - Sensors and Actuators
Smart City Lab 1 - Sensors and ActuatorsPeter Waher
 
Chapter 2_Architecture_edited_SDT
Chapter 2_Architecture_edited_SDTChapter 2_Architecture_edited_SDT
Chapter 2_Architecture_edited_SDTStephanie Stribling
 
06 - ELF format, knowing your friend
06 - ELF format, knowing your friend06 - ELF format, knowing your friend
06 - ELF format, knowing your friendAlexandre Moneger
 
neoFlash Introduction
neoFlash IntroductionneoFlash Introduction
neoFlash IntroductionYong Hee Nam
 
IBM Notes 10.0.1 FP2 Client Upgrades - made easy!
IBM Notes 10.0.1 FP2 Client Upgrades - made easy!IBM Notes 10.0.1 FP2 Client Upgrades - made easy!
IBM Notes 10.0.1 FP2 Client Upgrades - made easy!panagenda
 
V4.6.0 VVDI Prog Programmer User Manual
V4.6.0 VVDI Prog Programmer User ManualV4.6.0 VVDI Prog Programmer User Manual
V4.6.0 VVDI Prog Programmer User ManualBuyobdtoolShop
 

Similar to Usb hid (20)

Vvdi prog user manual v4.8.8
Vvdi prog user manual v4.8.8Vvdi prog user manual v4.8.8
Vvdi prog user manual v4.8.8
 
Xhorse Vvdi prog user manual 4.9.3
Xhorse Vvdi prog user manual 4.9.3Xhorse Vvdi prog user manual 4.9.3
Xhorse Vvdi prog user manual 4.9.3
 
Xhorse Vvdi prog user manual v4.7.7 -obdii365
Xhorse Vvdi prog user manual v4.7.7 -obdii365Xhorse Vvdi prog user manual v4.7.7 -obdii365
Xhorse Vvdi prog user manual v4.7.7 -obdii365
 
Bluetooth Module HC-06
Bluetooth Module HC-06Bluetooth Module HC-06
Bluetooth Module HC-06
 
[University] Capstone Design Project 2 (SAIOT)
[University] Capstone Design Project 2 (SAIOT)[University] Capstone Design Project 2 (SAIOT)
[University] Capstone Design Project 2 (SAIOT)
 
Hardwear.io 2018 BLE Security Essentials workshop
Hardwear.io 2018 BLE Security Essentials workshopHardwear.io 2018 BLE Security Essentials workshop
Hardwear.io 2018 BLE Security Essentials workshop
 
Loadnrun: UKIUA 2010 Presentation
Loadnrun: UKIUA 2010 PresentationLoadnrun: UKIUA 2010 Presentation
Loadnrun: UKIUA 2010 Presentation
 
IPmux ws 4.00.ppt
IPmux ws 4.00.pptIPmux ws 4.00.ppt
IPmux ws 4.00.ppt
 
Top Ten Siemens S7 Tips and Tricks
Top Ten Siemens S7 Tips and TricksTop Ten Siemens S7 Tips and Tricks
Top Ten Siemens S7 Tips and Tricks
 
engage 2019 Workshop - Dirty Secrets of the Notes Client
engage 2019 Workshop - Dirty Secrets of the Notes Clientengage 2019 Workshop - Dirty Secrets of the Notes Client
engage 2019 Workshop - Dirty Secrets of the Notes Client
 
All You Need to Know About HCL Notes 64-Bit Clients
All You Need to Know About HCL Notes 64-Bit ClientsAll You Need to Know About HCL Notes 64-Bit Clients
All You Need to Know About HCL Notes 64-Bit Clients
 
CollabSphere 2020 - INF105 - HCL Notes 11.0.1 FP1 - Performance Boost Re-Relo...
CollabSphere 2020 - INF105 - HCL Notes 11.0.1 FP1 - Performance Boost Re-Relo...CollabSphere 2020 - INF105 - HCL Notes 11.0.1 FP1 - Performance Boost Re-Relo...
CollabSphere 2020 - INF105 - HCL Notes 11.0.1 FP1 - Performance Boost Re-Relo...
 
CollabSphere 2020 Live - HCL Notes 11.0.1 FP1 - Performance Boost Re-Reloaded
CollabSphere 2020 Live - HCL Notes 11.0.1 FP1 - Performance Boost Re-ReloadedCollabSphere 2020 Live - HCL Notes 11.0.1 FP1 - Performance Boost Re-Reloaded
CollabSphere 2020 Live - HCL Notes 11.0.1 FP1 - Performance Boost Re-Reloaded
 
Banana pi bpi-d1 user manual-en
Banana pi bpi-d1 user manual-enBanana pi bpi-d1 user manual-en
Banana pi bpi-d1 user manual-en
 
Smart City Lab 1 - Sensors and Actuators
Smart City Lab 1 - Sensors and ActuatorsSmart City Lab 1 - Sensors and Actuators
Smart City Lab 1 - Sensors and Actuators
 
Chapter 2_Architecture_edited_SDT
Chapter 2_Architecture_edited_SDTChapter 2_Architecture_edited_SDT
Chapter 2_Architecture_edited_SDT
 
06 - ELF format, knowing your friend
06 - ELF format, knowing your friend06 - ELF format, knowing your friend
06 - ELF format, knowing your friend
 
neoFlash Introduction
neoFlash IntroductionneoFlash Introduction
neoFlash Introduction
 
IBM Notes 10.0.1 FP2 Client Upgrades - made easy!
IBM Notes 10.0.1 FP2 Client Upgrades - made easy!IBM Notes 10.0.1 FP2 Client Upgrades - made easy!
IBM Notes 10.0.1 FP2 Client Upgrades - made easy!
 
V4.6.0 VVDI Prog Programmer User Manual
V4.6.0 VVDI Prog Programmer User ManualV4.6.0 VVDI Prog Programmer User Manual
V4.6.0 VVDI Prog Programmer User Manual
 

More from cri fan

Scientific network summary
Scientific network summaryScientific network summary
Scientific network summarycri fan
 
Virutal machine tutorial
Virutal machine tutorialVirutal machine tutorial
Virutal machine tutorialcri fan
 
Virtualbox tutorial
Virtualbox tutorialVirtualbox tutorial
Virtualbox tutorialcri fan
 
Usb disk driver
Usb disk driverUsb disk driver
Usb disk drivercri fan
 
Usb basic
Usb basicUsb basic
Usb basiccri fan
 
Uboot starts analysis
Uboot starts analysisUboot starts analysis
Uboot starts analysiscri fan
 
Symbology upc
Symbology upcSymbology upc
Symbology upccri fan
 
Symbology plessey
Symbology plesseySymbology plessey
Symbology plesseycri fan
 
Symbology gs1128
Symbology gs1128Symbology gs1128
Symbology gs1128cri fan
 
Symbology code128
Symbology code128Symbology code128
Symbology code128cri fan
 
Soft dev basic
Soft dev basicSoft dev basic
Soft dev basiccri fan
 
Runtime upgrade linux
Runtime upgrade linuxRuntime upgrade linux
Runtime upgrade linuxcri fan
 
Regular expression
Regular expressionRegular expression
Regular expressioncri fan
 
Rec soft npp
Rec soft nppRec soft npp
Rec soft nppcri fan
 
Python topic str_encoding
Python topic str_encodingPython topic str_encoding
Python topic str_encodingcri fan
 
Python topic re
Python topic rePython topic re
Python topic recri fan
 
Python summary
Python summaryPython summary
Python summarycri fan
 
Python intermediate tutorial
Python intermediate tutorialPython intermediate tutorial
Python intermediate tutorialcri fan
 
Python beginner tutorial
Python beginner tutorialPython beginner tutorial
Python beginner tutorialcri fan
 
Programming language basic
Programming language basicProgramming language basic
Programming language basiccri fan
 

More from cri fan (20)

Scientific network summary
Scientific network summaryScientific network summary
Scientific network summary
 
Virutal machine tutorial
Virutal machine tutorialVirutal machine tutorial
Virutal machine tutorial
 
Virtualbox tutorial
Virtualbox tutorialVirtualbox tutorial
Virtualbox tutorial
 
Usb disk driver
Usb disk driverUsb disk driver
Usb disk driver
 
Usb basic
Usb basicUsb basic
Usb basic
 
Uboot starts analysis
Uboot starts analysisUboot starts analysis
Uboot starts analysis
 
Symbology upc
Symbology upcSymbology upc
Symbology upc
 
Symbology plessey
Symbology plesseySymbology plessey
Symbology plessey
 
Symbology gs1128
Symbology gs1128Symbology gs1128
Symbology gs1128
 
Symbology code128
Symbology code128Symbology code128
Symbology code128
 
Soft dev basic
Soft dev basicSoft dev basic
Soft dev basic
 
Runtime upgrade linux
Runtime upgrade linuxRuntime upgrade linux
Runtime upgrade linux
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Rec soft npp
Rec soft nppRec soft npp
Rec soft npp
 
Python topic str_encoding
Python topic str_encodingPython topic str_encoding
Python topic str_encoding
 
Python topic re
Python topic rePython topic re
Python topic re
 
Python summary
Python summaryPython summary
Python summary
 
Python intermediate tutorial
Python intermediate tutorialPython intermediate tutorial
Python intermediate tutorial
 
Python beginner tutorial
Python beginner tutorialPython beginner tutorial
Python beginner tutorial
 
Programming language basic
Programming language basicProgramming language basic
Programming language basic
 

Recently uploaded

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 

Recently uploaded (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 

Usb hid

  • 1. USB HID Learning Record 版本:v0.6 Crifan Li 摘要 本文主要介绍了USB HID的基本知识,以及举例说明如何解析HID Report 本文提供多种格式供: 在线阅读 HTML 1 下载(7zip压缩包) HTML 8 HTMLs PDF 3 HTMLs PDF 10 2 9 CHM 4 CHM 11 TXT 5 TXT 12 RTF 6 RTF 13 HTML版本的在线地址为: http://www.crifan.com/files/doc/docbook/usb_hid/release/html/usb_hid.html 有任何意见,建议,提交bug等,都欢迎去讨论组发帖讨论: http://www.crifan.com/bbs/categories/usb_hid/ 修订历史 修订 0.4 2011-06-16 crl 2013-09-05 crl 1. 写好了USB HID基本内容 修订 0.6 1. 通过Docbook发布 2. 更新了所有xml:id 1 http://www.crifan.com/files/doc/docbook/usb_hid/release/html/usb_hid.html http://www.crifan.com/files/doc/docbook/usb_hid/release/htmls/index.html 3 http://www.crifan.com/files/doc/docbook/usb_hid/release/pdf/usb_hid.pdf 4 http://www.crifan.com/files/doc/docbook/usb_hid/release/chm/usb_hid.chm 5 http://www.crifan.com/files/doc/docbook/usb_hid/release/txt/usb_hid.txt 6 http://www.crifan.com/files/doc/docbook/usb_hid/release/rtf/usb_hid.rtf 7 http://www.crifan.com/files/doc/docbook/usb_hid/release/webhelp/index.html 8 http://www.crifan.com/files/doc/docbook/usb_hid/release/html/usb_hid.html.7z 9 http://www.crifan.com/files/doc/docbook/usb_hid/release/htmls/index.html.7z 10 http://www.crifan.com/files/doc/docbook/usb_hid/release/pdf/usb_hid.pdf.7z 11 http://www.crifan.com/files/doc/docbook/usb_hid/release/chm/usb_hid.chm.7z 12 http://www.crifan.com/files/doc/docbook/usb_hid/release/txt/usb_hid.txt.7z 13 http://www.crifan.com/files/doc/docbook/usb_hid/release/rtf/usb_hid.rtf.7z 14 http://www.crifan.com/files/doc/docbook/usb_hid/release/webhelp/usb_hid.webhelp.7z 2 WEBHELP 7 WEBHELP 14
  • 2. USB HID Learning Record: Crifan Li 版本:v0.6 出版日期 2013-09-05 版权 © 2012 Crifan, http://crifan.com 15 本文章遵从:署名-非商业性使用 2.5 中国大陆(CC BY-NC 2.5) 15 http://www.crifan.com/files/doc/docbook/soft_dev_basic/release/html/soft_dev_basic.html#cc_by_nc
  • 3. 目录 1. USB HID基础知识 ................................................................................................................ 1 1.1. USB HID Structure ................................................................................................... 1 1.2. HID descriptor ......................................................................................................... 2 1.2.1. HID Class Structure ....................................................................................... 3 1.2.2. Short Items ................................................................................................... 4 1.2.3. Long Items .................................................................................................... 5 1.2.4. Main Items .................................................................................................... 6 1.2.5. Global Items .................................................................................................. 7 1.2.6. Local Items .................................................................................................... 8 1.3. Usage Page Summary .............................................................................................. 9 2. HID Report Example ......................................................................................................... 10 2.1. Normal examples ................................................................................................... 10 2.1.1. Generic mouse ............................................................................................ 10 2.1.2. Keyboard ..................................................................................................... 11 2.2. An HID Report Example analysis ........................................................................... 12 iii
  • 4. 插图清单 1.1. 1.2. 1.3. 1.4. 1.5. 1.6. 1.7. 1.8. 1.9. 2.1. 2.2. 2.3. 2.4. USB HID Structure ........................................................................................................... 1 HID descriptor ................................................................................................................. 2 HID Class Structure .......................................................................................................... 3 HID Short Items ............................................................................................................... 4 HID Long Items ............................................................................................................... 5 HID Main Items ............................................................................................................... 6 HID Global Items ............................................................................................................. 7 HID Local Items ............................................................................................................... 8 HID Usage page summary ............................................................................................... 9 HID Report Example - 3 button mouse ......................................................................... 10 HID Report Example - keyboard - 1/2 ........................................................................... 11 HID Report Example - keyboard - 2/2 ........................................................................... 12 HID Data Format ........................................................................................................... 13 iv
  • 5. 第 1 章 USB HID基础知识 1.1. USB HID Structure 图 1.1. USB HID Structure 1
  • 6. USB HID基础知识 1.2. HID descriptor 图 1.2. HID descriptor 2
  • 7. USB HID基础知识 1.2.1. HID Class Structure 图 1.3. HID Class Structure 3
  • 8. USB HID基础知识 1.2.2. Short Items 图 1.4. HID Short Items 4
  • 9. USB HID基础知识 1.2.3. Long Items 图 1.5. HID Long Items 5
  • 10. USB HID基础知识 1.2.4. Main Items 图 1.6. HID Main Items 6
  • 11. USB HID基础知识 1.2.5. Global Items 图 1.7. HID Global Items 7
  • 12. USB HID基础知识 1.2.6. Local Items 图 1.8. HID Local Items 8
  • 13. USB HID基础知识 图 1.9. HID Usage page summary 1.3. Usage Page Summary 9
  • 14. 第 2 章 HID Report Example 2.1. Normal examples 2.1.1. Generic mouse 3-button mouse: 图 2.1. HID Report Example - 3 button mouse Note: above data’s format is: 05 01 = 0x 01 05 09 02 = 0x 02 09 10
  • 15. HID Report Example 2.1.2. Keyboard 图 2.2. HID Report Example - keyboard - 1/2 11
  • 16. HID Report Example 图 2.3. HID Report Example - keyboard - 2/2 2.2. An HID Report Example analysis Follow is the example. According to the format, defined in specification: 12
  • 17. HID Report Example 图 2.4. HID Data Format Now to analysis the corresponding meaning for every group bytes: Data send by LSB The data is send by LSB, so when “0x45, 0xFF’ is sent, first send is “0x45”, second send “0xFF”, the LSB is “0x45” located in low address, the MSB “0xFF” located in high address, so the hex value is ”0xFF45“ 0x06, 0x45, 0xFF, 0x0A, 0x00, 0xA0, 0xA1, 0x01, 0x75, 0x08, 0x96, 0x07, 0x01, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x0A, 0x01, 0xA0, 0x91, 0x02, 0x75, 0x08, 0x95, 0x08, 0x0A, 0x02, 0xA0, 0x81, 0x02, 0xC0 [Data] [Data] bTag=7:4 bType=3:2 bSize=1:0 0x06 0xFF 0x45 0000 01 10 0000 0110 Usage Page Global item 2 bytes 0xFF45 -> 0xFF00 -0xFFFF = Vendor defined [Data] [Data] bTag=7:4 bType=3:2 bSize=1:0 0x0A 0xA0 0x00 0000 10 10 0000 1010 Usage Local item 2 bytes Usage=0xA000 here Usage=0xA000 is just self defined, just need not confict with self's others, no other special meaning [Data] bTag=7:4 bType=3:2 bSize=1:0 0xA1 0x01 1010 00 01 Application (mouse, keyboard) Collection Main item 1 bytes [Data] bTag=7:4 bType=3:2 bSize=1:0 0x75 0x08 0111 01 01 0111 0101 Global item 1 bytes Report Size = Report Size 0x08 bits 1010 0001 13
  • 18. HID Report Example [Data] [Data] bTag=7:4 bType=3:2 bSize=1:0 0x96 0x01 0x07 1001 01 10 1001 0110 Report Count = 0x0107=263 Report Count Global item 2 bytes [Data] bTag=7:4 bType=3:2 bSize=1:0 0x15 0x00 0001 01 01 0001 0101 Logical = Minimum Global item 1 bytes Logical Minimum 0x00 [Data] [Data] bTag=7:4 bType=3:2 bSize=1:0 0x26 0x00 0xFF 0010 01 10 0010 0110 Logical Maximum Global item 2 bytes Logical Maximum =x00FF=255 [Data] [Data] bTag=7:4 bType=3:2 bSize=1:0 0x0A 0xA0 0x01 0000 10 10 0000 1010 Usage Local item 2 bytes Usage = 0xA001 here Usage=0xA001 is just self defined, just need not confict with self's others, no other special meaning [Data] bTag=7:4 bType=3:2 bSize=1:0 0x91 0x02 1001 00 01 1001 0001 0x02=0000 0010 Output Main item 1 bytes [Data] bTag=7:4 bType=3:2 bSize=1:0 0x75 0x08 0111 01 01 0111 0101 Report Size = Report Size 0x08 bits Global item 1 bytes [Data] bTag=7:4 bType=3:2 bSize=1:0 0x95 0x08 1001 01 01 1001 0101 Bit 1 { Variable (1)} All other bits are Reserved (0) Report Report Count Global item Count= 0x08 =8 1 bytes [Data] [Data] bTag=7:4 bType=3:2 bSize=1:0 0x0A 0xA0 0x02 0000 10 10 0000 1010 Usage Local item 2 bytes [Data] bTag=7:4 bType=3:2 bSize=1:0 0x81 0x02 1000 00 01 1000 0001 0x02=0000 0010 Input Main item 1 bytes Usage = 0xA002 Bit 1 { Variable (1)} 14
  • 19. HID Report Example [Data] bTag=7:4 All other bits are Reserved (0) bType=3:2 bSize=1:0 0x81 [Data] bTag=7:4 bType=3:2 bSize=1:0 0xC0 1100 00 00 1100 0000 End Collection Main item 0 bytes Closes an item collection After analyze following data, the summary is: Usage Page (0xFF45) =Vendor-Specific 0xFF45 06 Global Usage (0xA000) 0xA000 0A Local Collection (Application) 0x01 A1 Main Report Size (8) 0x08 75 Global Report Count (263) 0x0107 96 Global Logical Minimum (0) Logical Maximum (255) Usage (0xA001) 0x00 15 Global 0x00FF 26 Global 0xA0001 0A Local Output (Variable) 0x02 91 Main Report Size (8) 0x08 75 Global Report Count (8) 0x08 95 Global Usage (0xA002) 0xA002 0A Local Input (Variable) 0x02 81 Main End Collection 0xC0 Main Report (Usage=0xA0000) Output Report (Usage=0xA001) 263 bytes Byte 0 Byte 1 ... ... Byte 261 Byte 262 Input Report (Usage=0xA002) 8 bytes Byte 0 Byte 1 ... Byte 7 All of above means: 1. This is a vendor-specific HID device 15
  • 20. HID Report Example 2. input or output is relative to Host side: • Output = Host ⇒ Device = host send 263 bytes to device • Input = Host ⇐ Device = device send 8 bytes to host 3. Every bytes value range is 0~255 16