HID - Keyboard键盘和Mouse鼠标实例

本文详细介绍了HID报告描述符的生成工具Dt.exe及其在键盘和鼠标设备上的应用实例,包括具体的报告描述符示例及HID规范的解读。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

hid报告描述符生成工具Dt.exe以及hid-keyboard键盘和mouse鼠标实例
报告描述符范例

    

     

 

  

Usage Page (Generic Desktop),

0x0105

Usage Page (Generic Desktop),

0x0105

Usage ( Keyboard ),

0x0609

Usage ( Mouse ),

0x0209

Collection (Application),

0x01A1

Collection (Application),

0x01A1

Usage Page (Keyboard),

0x0705

Usage ( Pointer ),

0x0109

Usage Minimum (224),

0xE019

Collection (Physical),

0x00A1

Usage Maximum (231),

0xE729

Usage Page (Buttons),

0x0905

Logical Minimum (0),

0x0015

Usage Minimum (1),

0x0119

Logical Maximum (1),

0x0125

Usage Maximum (3),

0x0329

Report Size (1),

0x0175

Logical Minimum (0),

0x0015

Report Count (8),

0x0895

Logical Maximum (1),

0x0125

Input (Data, Variable, Absolute),

0x0281

Report Size (1),

0x0175

Report Size (8),

0x0875

Report Count (3),

0x0395

Report Count (1),

0x0195

Input (Data, Variable, bsolute),

0x0281

Input (Constant),

0x0181

Report Size (5),

0x0575

Usage Minimum (0),

0x0019

Report Count (1),

0x0195

Usage Maximum (101),

0x6529

Input (Constant),

0x0181

Logical Minimum (0),

0x0015

Usage Page (Generic Desktop),

0x0105

Logical Maximum (101),

0x6525

Usage (X),

0x3009

Report Size (8),

0x0875

Usage (Y),

0x3109

Report Count (6),

0x0695

Logical Minimum (-127),

0x8115

Input (Data, Array),

0x0081

Logical Maximum (127),

0x7F25

Usage Page (LEDs),

0x0805

Report Size (8),

0x0875

Usage Minimum (1),

0x0119

Report Count (2),

0x0295

Usage Maximum (5),

0x0529

Input (Data, Variable, Relative),

0x0681

Logical Minimum (0),

0x0015

End Collection,

0xC0

Logical Maximum (1),

0x0125

End Collection

0xC0

Report Size (1),

0x0175

 

 

Report Count (5),

0x0595

 

 

Output (Data, Variable,Absolute),

0x0291

 

 

Report Size (3),

0x0375

 

 

Report Count (1),

0x0195

 

 

Output (Constant),

0x0191

 

 

End Collection

0xC0

 

 



http://www.usb.org/developers/hidpage/#Class_Definition


HID Information

HID Related Specifications

HID Resources

 

 

HID Related Specifications

Device Class Definition HID
The Device Class Definition for HID 1.11 is intended to supplement the USB Specification and provide HID manufacturers with the information necessary to build USB-compatible devices. It also specifies how the HID class driver should extract data from USB devices. The primary and underlying goals of the HID class definition are to:

  • be as compact as possible to save device data space
  • allow the software application to skip unknown information
  • be extensible and robust
  • support nesting and collections
  • be self-describing to allow generic software applications

HID Usage Tables
The HID Usage Tables 1.12 document defines constants that can be interpreted by an application to identify the purpose and meaning of a data field in a HID report.

Usages are also used to define the meaning of groups of related data items. This is accomplished by the hierarchical assignment of usage information to collections.

Usages identify the purpose of a collection and the items it contains. Each Input, Output, Feature, and/or Collection data item within a Collection item can be assigned a purpose with its own usage item. Usages assigned to a collection apply to the items within the collection.

The HID Usage Tables document contains extensions to the tables defined in the USB Device Class Definition for Human Interface Devices. All usages pages, except the Keyboard table, are replicated in the Usage Table document. The Usage Table document identifies the extensions to the Keyboard usage table.

Note: For keyboards, look at the usage table sections in both the HID Specification and the HID Usage Table document!

Approved Usage Table Review Requests

The following HID Usage Table Review Requests have been approved for implementation by the USB Device Working Group HID Committee. These Review requests assign enumeration values and recommended meaning to new Usages allocated after the publication of the HID Usage Tables v1.12. Please note that the creation of a new Usage does not imply support for that Usage by any USB HID Host vendor.

     Review Request 28:  Creation of a Usage Page for the Gaming Standards Association
     Review Request 29:  Repurposing the Alphanumberic Display Page (0x14) as a generic Auxiliary Display Page and adding bitmap and custom segment capabilities
     Review Request 30:  Touch digitizers
     Review Request 31:  Background Events application collection
     Review Request 32:  Dual-Mode Telephone devices
     Review Request 33:  Water cooling and computer chassis
     Review Request 34:  Multi-touch digitizers
     Review Request 35:  Consumer electronics devices (PiP Toggle, PiP-swap)
     Review Request 36:  Consumer electronics devices (Color buttons)

Usage Tables for Physical Interface Devices
The
Device Class Definition for PID 1.0 provides information for the development of Physical Interface Devices. These devices include force feedback joysticks, steering wheels, etc. It allows peripheral and driver developers to use a common set of HID report descriptors, device usages and reports to describe the characteristics of a PID class device.

Usage Tables for HID Power Devices
The
Usage Tables for HID Power Devices 1.0 specification provides information to guide implementers in using the USB logical structures for Power Devices, OS designers, BIOS designers, and peripheral and UPS designers can use the common descriptors, of USB Power Device Usages and Reports.

Monitor Control Class Specification
The
Monitor Control Class 1.0 specification defines how a monitor with a USB Monitor Control interface interacts with a USB-enabled host system.

HID Point Of Sale Usage Tables
The
HID Point Of Sale Usage Tables 1.02 document defines usages that apply to Point of Sale devices, in particular Barcode Scanners and Scales.

OAAD Arcade Usage Table
The
OAAD Arcade Usage Table document defines usages for coin changers, general purpose digital inputs and outputs, and other devices used in arcade products.

Gaming Standards Association Gaming Device Standards
The Gaming Standards Association defines HID Usages and HID Reports used in the implementation of GSA-compliant Gaming Devices such as currency handlers, gaming-specific printers, etc. Their standards relating to USB HID implementations can be found here .

Microsoft Related HID Documentation
The
Microsoft Related HID Documentation page contains links to documentation on Microsoft's site geared towards HID implementation, device class support, devices, etc.

HID Resources

HID Descriptor Tool
This tool allows you to create, edit and validate HID Report Descriptors. The tool also supports a variety of output formats (.txt, .inc, .h, etc.). DT uses ASCII based Usage Tables and supports vendor defined pages as well. Included are Usage Table files for the HID Usage Table document 1.0 Release Candidate 1, Monitor Class 1.0 Release Candidate 2, and Power Class Spec. Read the included README.TXT file for more information.

HIDView
This program, found in the USBCheck, is now obsolete. Its replacement is
USBCV .

HID White Papers

HID FAQ
A FAQ with questions and answers regarding hid and hid usage. 

Unicode
The Unicode web site (
www.unicode.org ) allows you to download the latest character tables for free. Check it before you finalize a design because new ones are always in process.
The Nadine Kano book, "Developing International Software" which was used as key reference for Unicode, is out of print. It can still be obtained in a CD-ROM version as part of the Microsoft Developers Network (MSDN) subscription. Subscription information can be obtained at the MSDN web site (msdn.microsoft.com ). Or it can be accessed for free online at the MSDN Library . The book can be found under "Books / Developing International Software".
To get the latest LANGID definitions go to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_8xo3.asp . This page will change as new LANGIDs are added.
Note that the HID Primary LANGID (0x0FF) is not on the above list, however it is permanently reserved and will never be reassigned.

Please send your URLs to hidcomments@usb.org


 

 原文地址 http://www.usb.org/developers/hidpage/#Class_Definition
### ESP32 蓝牙 HID 键盘鼠标同时连接运行实现方法 #### 1. 硬件准备 确保拥有一个带有蓝牙功能的ESP32开发板。此过程适用于多个版本的ESP32芯片,如ESP32-C3、ESP32-S3等[^2]。 #### 2. 安装必要的库文件 对于想要创建既作为键盘也作为鼠标的设备来说,安装合适的库至关重要。可以利用GitHub上的`T-vK/ESP32-BLE-Keyboard`库来简化这一流程。此外,还需要考虑集成或寻找类似的BLE Mouse库以便于后续组合使用。 #### 3. 编写代码逻辑 下面是一个简单的Arduino IDE脚本例子,它展示了如何设置ESP32作为一个能够发送按键事件(代表键盘)以及移动指针位置(代表鼠标)的复合型HID装置: ```cpp #include <BluetoothSerial.h> #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it. #endif #include "BLEDevice.h" #include "BLEUtils.h" #include "BLEServer.h" #include "BLECharacteristic.h" // Add BLE Keyboard & Mouse libraries here #include "BLEKeyboard.h" #include "BLEMouse.h" BLEKeyboard bleKeyboard; BLEMous bleMouse; void setup() { Serial.begin(115200); // Initialize the device as a peripheral BLEDevice::init("ESP32 BLE HID"); // Create server BLEServer *pServer = BLEDevice::createServer(); // Start services for keyboard and mouse bleKeyboard.start(); bleMouse.start(); } void loop() { delay(1000); // Simulate key press events every second bleKeyboard.print("123456"); delay(1000); // Move cursor by (-10, -10), no scroll or button click bleMouse.move(-10,-10,0); } ``` 上述代码片段中包含了启动服务并初始化两个独立的服务实例——一个是用于处理键盘输入(`bleKeyboard`);另一个则是用来管理鼠标动作(`bleMouse`). 在主循环里交替执行了模拟键入字符序列“123456”的命令向左上方轻微拖动光标的操作. 值得注意的是,在实际应用当中应当更加精细地设计触发条件与交互模式,而不仅仅局限于固定的间隔时间内的简单行为重复[^1]. #### 4. 测试与调试 完成编程之后,上传代码到ESP32,并通过手机或其他支持BLE HID协议接收端的应用程序来进行配对尝试。如果一切正常的话,则应该可以看到来自该微控制器所发出的数据流被成功解析成相应的外设指令被执行出来。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值