惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - Mojies

Prompt 相关 T-Lite 简介 CRC 计算 C 语言例子 一个 python 拆解文本文件的工具 UNIX 环境编程 Note ( UPDATING ) 航模.fs.ia6b 接收机记录 线程同步 STM32 Note Linux FrameBuffer note VIM Note Android 开发笔记(更新中....) Effective C++ (暂停更新) Linux 命令行对比二进制文件脚本 Linux Note (Updateing) 自制树莓派 3D 模型,附 STL 文件 《重构改善既有代码的设计》Tips 翻译: buildroot 用户手册 (更新中...) Some view of engineers 地球地址
关于 HID 你可能需要知道的几件事 (更新中...)
Mojies · 2022-01-11 · via 博客园 - Mojies

  1. 《HID 1.11》 主要描述 report desc 的一些规则,以及如何进行通讯
  2. 《HUT 1.22》 则主要说明一些通用的 HID 设备类型具备的 Usage page, Usage
  3. 关于 HID 的文档请从该网页获取:https://www.usb.org/hid

  1. 关于 HID 的库可以使用 libusb 直接操作 USB HID 节点,也可通过 libhidapi 来操作,libhidapi 集成度更高,而且最近也开始重新维护了。都由 libusb 维护:
  2. libusb 仓库地址:https://github.com/libusb/libusb
  3. libhidapi 仓库地址:https://github.com/libusb/hidapi
  4. 如果你比较纠结到底是选择 libusb 好还是 libhidapi 好,则可以看一下这个帖子:https://stackoverflow.com/questions/55272593/hidapi-vs-libusb-for-linux

  1. HID 规范文档中设备描述的 input 和 output 都是站在 Host 端角度描述的
  2. HID 中的 report desc 主要是为了向 Host 描述设备具备何种功能,以及如何使用设备的。而 HID 从协议上并没有严格的绑定传输过程中的数据与 report desc 的对应关系。这需要设备和 PC 端的驱动和应用程序来保证。因此,这也造成了是市面很多不规范的产品 dump 出来一个设备描述自己支持很多的功能,但可能其中只有一小部分的功能是支持的原因。

  1. HID report descriptor 描述了HID 设备的没一笔数据的数据标签(Tag)类型,大小,比如:

    1. 定义了 HID 的 input 事件应该被当作 mouse 事件还是 Keyboard 事件
    2. 定义了一个 output 事件或者 input 事件应该被如何传输(数据结构,类型)

  1. HID 的 ClassCode 恒定为 0x03

  2. HID 的 SubClass 有两个值

    1. 0 代表无 SubClass
    2. 1 代表 Boot Interface Subclass
  3. HID 的 Protocol Codes 定义了三个值:(只有当 SubClass 为 1 的时候才会有 Interface Desc,并且 ProtocolCode 才有 非零值)

    1. 0 - None
    2. 1 - Keyboard
    3. 2 - Mouse

六: 关于 HID 的 Endpoint 说明如下:

  1. Control pipe de Endpoint0 是作为一个 USB 设备一定存在的,其也传输了包含以下内容:USB Control, Class request code, polled data(Message Data)
  2. Interrupt In, 用于承载 HID Input 类型数据(device to host)
  3. Interrupt Out,用于承载 HID output 类型数据(Host to devices),该 Endpoint 可不实现,此时 Output 数据通过 Endpoint0 传输

七 Report Descript

  1. HID Report Desc 中包含许多格式相近的 item,而分析这些 item 的上下文可以得知,一个 HID 的设备包含哪些能力。

  2. Report Desc 上下文的格式大致如下图所示:

  3. 其中 item 的格式:

    短 item 主要包含以下几个部分:bTag,bType,bSize,bData,如下所示
    ShortItems

    1. bTag 和 bType 一起标识该 Item 的属性,其中 bType 主要指定属性范围,占用两个位:
      00 - Main Items
      01 - Global Items
      10 - Local Items
      11 - 保留(实际上可看成和特殊的 bTag(1111), bSize(10) 搭配标识该 Item 为长 Items)

    2. 而对于短 Item 来说, bSize 标识该 item 的 bData 长度,短 Item 大致有 0,1,2,4 这几种长度,分别用 00, 01, 10, 11 表示

    长 item 主要包含 特殊头,bDataSize,bLongItemTag, Data,如下所示:
    LongItems

posted @ 2022-01-11 22:57  Mojies  阅读(2225)  评论()    收藏  举报