USB鼠标HID设备示例
2021-12-19
2025
1
本示例的鼠标是一个最简单的USB鼠标,不包括任何其它附加设备。该设备在设备管理器中如下图所示:
该USB鼠标的枚举过程如示:
Device Length Phase Data Description
------ -------- ----- -------------------------------------------------- ----------------
9.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR
9.0 18 IN 12 01 00 02 00 00 00 08 6d 04 77 c0 00 72 01 02 ........m.w..r..
00 01 ..
9.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR
9.0 9 IN 09 02 22 00 01 01 00 a0 32 ..".....2
9.0 CTL 80 06 00 02 00 00 22 00 GET DESCRIPTOR
9.0 34 IN 09 02 22 00 01 01 00 a0 32 09 04 00 00 01 03 01 ..".....2.......
02 00 09 21 11 01 00 01 22 2e 00 07 05 81 03 04 ...!....".......
00 0a ..
9.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG
9.0 CTL 21 0a 00 00 00 00 00 00 SET IDLE
9.0 CTL 81 06 00 22 00 00 6e 00 GET DESCRIPTOR
9.0 46 IN 05 01 09 02 a1 01 09 01 a1 00 05 09 19 01 29 03 ..............).
15 00 25 01 95 08 75 01 81 02 05 01 09 30 09 31 ..%...u......0.1
09 38 15 81 25 7f 75 08 95 03 81 06 c0 c0 .8..%.u.......
9.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR
9.0 9 IN 09 02 22 00 01 01 00 a0 32 ..".....2
9.0 CTL 80 06 00 02 00 00 22 00 GET DESCRIPTOR
9.0 34 IN 09 02 22 00 01 01 00 a0 32 09 04 00 00 01 03 01 ..".....2.......
02 00 09 21 11 01 00 01 22 2e 00 07 05 81 03 04 ...!....".......
00 0a ..
9.1 4 IN 00 ff ff 00 ....
14 24 IN 01 00 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ................
ff ff ff ff 00 00 00 00 ........
9.1 4 IN 00 ff f7 00 ....
14 24 IN 01 00 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ................
f7 ff ff ff 00 00 00 00 ........
在BUSHOUND中通过的设备ID如下图所法:
通过USBTreeView的获取的设备描述符信息如下:
=========================== USB Port9 ===========================
Connection Status : 0x01 (Device is connected)
Port Chain : 2-9
Properties : 0x01
IsUserConnectable : yes
PortIsDebugCapable : no
PortHasMultiCompanions : no
PortConnectorIsTypeC : no
ConnectionIndex : 9
======================== USB Device ========================
+++++++++++++++++ Device Information ++++++++++++++++++
Device Description : USB 输入设备
Device Path : \\?\USB#VID_046D&PID_C077#5&1e7d8db7&0&9#{a5dcbf10-6530-11d2-901f-00c04fb951ed} (GUID_DEVINTERFACE_USB_DEVICE)
Kernel Name : \Device\USBPDO-3
Device ID : USB\VID_046D&PID_C077\5&1E7D8DB7&0&9
Hardware IDs : USB\VID_046D&PID_C077&REV_7200 USB\VID_046D&PID_C077
Driver KeyName : {745a17a0-74d3-11d0-b6fe-00a0c90f57da}\0006 (GUID_DEVCLASS_HIDCLASS)
Driver : \SystemRoot\System32\drivers\hidusb.sys (Version: 10.0.14393.82 Date: 2016-08-06)
Driver Inf : C:\Windows\inf\input.inf
Legacy BusType : PNPBus
Class : HIDClass
Class GUID : {745a17a0-74d3-11d0-b6fe-00a0c90f57da} (GUID_DEVCLASS_HIDCLASS)
Service : HidUsb
Enumerator : USB
Location Info : Port_#0009.Hub_#0001
Location IDs : PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(9), ACPI(_SB_)#ACPI(PCI0)#ACPI(XHC_)#ACPI(RHUB)#ACPI(HS09)
Container ID : {6ddf2e93-3fc3-11ec-a93f-0c9d92c27dc6}
Manufacturer Info : (标准系统设备)
Capabilities : 0x84 (Removable, SurpriseRemovalOK)
Status : 0x0180600A (DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_REMOVABLE, DN_NT_ENUMERATOR, DN_NT_DRIVER)
Problem Code : 0
HcDisableSelectiveSuspend: 0
EnableSelectiveSuspend : 0
SelectiveSuspendEnabled : 0
EnhancedPowerMgmtEnabled : 1
IdleInWorkingState : 0
WakeFromSleepState : 0
Power State : D0 (supported: D0, D1, D2, D3, wake from D0, wake from D1, wake from D2)
Child Device 1 : HID-compliant mouse
Device Path 1 : \\?\HID#VID_046D&PID_C077#6&2687a67d&1&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd} (GUID_DEVINTERFACE_MOUSE)
Device Path 2 : \\?\HID#VID_046D&PID_C077#6&2687a67d&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030} (GUID_DEVINTERFACE_HID)
Kernel Name : \Device\00000100
Device ID : HID\VID_046D&PID_C077\6&2687A67D&1&0000
Class : Mouse
Driver KeyName : {4d36e96f-e325-11ce-bfc1-08002be10318}\0000 (GUID_DEVCLASS_MOUSE)
Service : mouhid
+++++++++++++++++ Registry USB Flags +++++++++++++++++
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\046DC0777200
osvc : REG_BINARY 00 00
NewInterfaceUsage : REG_DWORD 00000000 (0)
---------------- Connection Information ---------------
Connection Index : 0x09 (9)
Connection Status : 0x01 (DeviceConnected)
Current Config Value : 0x01
Device Address : 0x0B (11)
Is Hub : 0x00 (no)
Device Bus Speed : 0x00 (Low-Speed)
Number Of Open Pipes : 0x01 (1 pipe to data endpoints)
Pipe[0] : EndpointID=1 Direction=IN ScheduleOffset=0 Type=Interrupt
Data (HexDump) : 09 00 00 00 12 01 00 02 00 00 00 08 6D 04 77 C0 ............m.w.
00 72 01 02 00 01 01 00 00 0B 00 01 00 00 00 01 .r..............
00 00 00 07 05 81 03 04 00 0A 00 00 00 00 ..............
--------------- Connection Information V2 -------------
Connection Index : 0x09 (9)
Length : 0x10 (16 bytes)
SupportedUsbProtocols : 0x03
Usb110 : 1 (yes)
Usb200 : 1 (yes)
Usb300 : 0 (no)
ReservedMBZ : 0x00
Flags : 0x00
DevIsOpAtSsOrHigher : 0 (Is not operating at SuperSpeed or higher)
DevIsSsCapOrHigher : 0 (Is not SuperSpeed capable or higher)
DevIsOpAtSsPlusOrHigher : 0 (Is not operating at SuperSpeedPlus or higher)
DevIsSsPlusCapOrHigher : 0 (Is not SuperSpeedPlus capable or higher)
ReservedMBZ : 0x00
Data (HexDump) : 09 00 00 00 10 00 00 00 03 00 00 00 00 00 00 00 ................
---------------------- Device Descriptor ----------------------
bLength : 0x12 (18 bytes)
bDescriptorType : 0x01 (Device Descriptor)
bcdUSB : 0x200 (USB Version 2.00) -> wrong, device is Low-Speed only
bDeviceClass : 0x00 (defined by the interface descriptors)
bDeviceSubClass : 0x00
bDeviceProtocol : 0x00
bMaxPacketSize0 : 0x08 (8 bytes)
idVendor : 0x046D (Logitech Inc.)
idProduct : 0xC077
bcdDevice : 0x7200
iManufacturer : 0x01 (String Descriptor 1)
Language 0x0409 : "Logitech"
iProduct : 0x02 (String Descriptor 2)
Language 0x0409 : "USB Optical Mouse"
iSerialNumber : 0x00 (No String Descriptor)
bNumConfigurations : 0x01 (1 Configuration)
Data (HexDump) : 12 01 00 02 00 00 00 08 6D 04 77 C0 00 72 01 02 ........m.w..r..
00 01 ..
------------------ Configuration Descriptor -------------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x02 (Configuration Descriptor)
wTotalLength : 0x0022 (34 bytes)
bNumInterfaces : 0x01 (1 Interface)
bConfigurationValue : 0x01 (Configuration 1)
iConfiguration : 0x00 (No String Descriptor)
bmAttributes : 0xA0
D7: Reserved, set 1 : 0x01
D6: Self Powered : 0x00 (no)
D5: Remote Wakeup : 0x01 (yes)
D4..0: Reserved, set 0 : 0x00
MaxPower : 0x32 (100 mA)
Data (HexDump) : 09 02 22 00 01 01 00 A0 32 09 04 00 00 01 03 01 ..".....2.......
02 00 09 21 11 01 00 01 22 2E 00 07 05 81 03 04 ...!....".......
00 0A ..
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x00
bAlternateSetting : 0x00
bNumEndpoints : 0x01 (1 Endpoint)
bInterfaceClass : 0x03 (HID - Human Interface Device)
bInterfaceSubClass : 0x01 (Boot Interface)
bInterfaceProtocol : 0x02 (Mouse)
iInterface : 0x00 (No String Descriptor)
Data (HexDump) : 09 04 00 00 01 03 01 02 00 .........
------------------- HID Descriptor --------------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x21 (HID Descriptor)
bcdHID : 0x0111 (HID Version 1.11)
bCountryCode : 0x00 (00 = not localized)
bNumDescriptors : 0x01
Data (HexDump) : 09 21 11 01 00 01 22 2E 00 .!...."..
Descriptor 1:
bDescriptorType : 0x22 (Class=Report)
wDescriptorLength : 0x002E (46 bytes)
Error reading descriptor : ERROR_INVALID_PARAMETER
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x81 (Direction=IN EndpointID=1)
bmAttributes : 0x03 (TransferType=Interrupt)
wMaxPacketSize : 0x0004
bInterval : 0x0A (10 ms)
Data (HexDump) : 07 05 81 03 04 00 0A .......
----------------- Device Qualifier Descriptor -----------------
Error : ERROR_GEN_FAILURE
-------------------- String Descriptors -------------------
------ String Descriptor 0 ------
bLength : 0x04 (4 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language ID[0] : 0x0409 (English - United States)
Data (HexDump) : 04 03 09 04 ....
------ String Descriptor 1 ------
bLength : 0x12 (18 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "Logitech"
Data (HexDump) : 12 03 4C 00 6F 00 67 00 69 00 74 00 65 00 63 00 ..L.o.g.i.t.e.c.
68 00 h.
------ String Descriptor 2 ------
bLength : 0x24 (36 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "USB Optical Mouse"
Data (HexDump) : 24 03 55 00 53 00 42 00 20 00 4F 00 70 00 74 00 $.U.S.B. .O.p.t.
69 00 63 00 61 00 6C 00 20 00 4D 00 6F 00 75 00 i.c.a.l. .M.o.u.
73 00 65 00 s.e.
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936