【发布时间】:2015-05-12 08:32:46
【问题描述】:
我正在通过在此处修改示例代码来处理我正在使用的 HID 报告描述符: https://code.msdn.microsoft.com/WudfVhidmini-Sample-b304f83a/sourcecode?fileId=42918&pathId=205101617(链接打开 queue.cpp 文件,这是我的驱动程序的大部分读/写代码和默认隐藏报告描述符所在的位置)。到目前为止,我在驱动程序中的更新报告描述符是(截至 2015 年 5 月 11 日):
HID_REPORT_DESCRIPTOR G_DefaultReportDescriptor[] = {
0x06, 0x00,0xFF, // (GLOBAL) USAGE_PAGE 0xFF00 Vendor-defined
0x09, 0x01, // (LOCAL) USAGE 0xFF000001
0xA1, 0x01, //(MAIN) COLLECTION 0x01 Application (Usage=0xFF000001: Page=Vendor-defined, Usage=, Type=)
0x85, 0x0F, // (GLOBAL) REPORT_ID 0x0F (15)
0x09, 0x01, // (LOCAL) USAGE 0xFF000001
0x15, 0x00, // (GLOBAL) LOGICAL_MINIMUM 0x00 (0) <-- Redundant: LOGICAL_MINIMUM is already 0
0x26, 0xFF,0x00, // (GLOBAL) LOGICAL_MAXIMUM 0x00FF (255)
0x75, 0x08, //(GLOBAL) REPORT_SIZE 0x08 (8) Number of bits per field
0x96, 0x09, 0x00, //(GLOBAL) REPORT_COUNT 0x0009 (9) Number of fields
0xB1, 0x00, // (MAIN) FEATURE 0x00000000 (9 fields x 8 bits) 0=Data 0=Array 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap
0x09, 0x01, // (LOCAL) USAGE 0xFF000001
0x96, 0x01, 0x00, // (GLOBAL) REPORT_COUNT 0x0001 (1) Number of fields
0x81, 0x00, // (MAIN) INPUT 0x00000000 (1 field x 8 bits) 0=Data 0=Array 0=Absolute 0=Ignored 0=Ignored 0=PrefState 0=NoNull
0x09, 0x01, //(LOCAL) USAGE 0xFF000001
0x96, 0x07, 0x00, // (GLOBAL) REPORT_COUNT 0x0007 (7) Number of fields
0x91, 0x00, // (MAIN) OUTPUT 0x00000000 (7 fields x 8 bits) 0=Data 0=Array 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap
0xC0, // (MAIN) END_COLLECTION Application
0x05, 0x01, // (GLOBAL) USAGE_PAGE 0x0001 Generic Desktop Page
0x09, 0x02, // (LOCAL) USAGE 0x00010002 Mouse (CA=Application Collection)
0xA1, 0x01, // (MAIN) COLLECTION 0x01 Application (Usage=0x00010002: Page=Generic Desktop Page, Usage=Mouse, Type=CA)
0x09, 0x01, // (LOCAL) USAGE 0x00010001 Pointer (CP=Physical Collection)
0xA1, 0x02, // (MAIN) COLLECTION 0x02 Logical (Usage=0x00010001: Page=Generic Desktop Page, Usage=Pointer, Type=CP) <-- Warning: USAGE type should be CL (Logical)
0x05, 0x0A, // (GLOBAL) USAGE_PAGE 0x000A Ordinal Page
0x09, 0x01, // (LOCAL) USAGE 0x000A0001 Instance 1 (UM=Usage Modifier)
0x85, 0x01, // (GLOBAL) REPORT_ID 0x01 (1)
0xA1, 0x00, // (MAIN) COLLECTION 0x00 Physical (Usage=0x000A0001: Page=Ordinal Page, Usage=Instance 1, Type=UM) <-- Warning: USAGE type should be CP (Physical)
0x05, 0x09, // (GLOBAL) USAGE_PAGE 0x0009 Button Page
0x19, 0x01, // (LOCAL) USAGE_MINIMUM 0x00090001 Button 1 Primary/trigger (MULTI=Selector, On/Off, Momentary, or One Shot)
0x29, 0x03, // (LOCAL) USAGE_MAXIMUM 0x00090003 Button 3 Tertiary (MULTI=Selector, On/Off, Momentary, or One Shot)
0x15, 0x00, // (GLOBAL) LOGICAL_MINIMUM 0x00 (0) <-- Redundant: LOGICAL_MINIMUM is already 0
0x25, 0x01, // (GLOBAL) LOGICAL_MAXIMUM 0x01 (1)
0x75, 0x01, // (GLOBAL) REPORT_SIZE 0x01 (1) Number of bits per field
0x95, 0x03, // (GLOBAL) REPORT_COUNT 0x03 (3) Number of fields
0x81, 0x02, // (MAIN) INPUT 0x00000002 (3 fields x 1 bit) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap
0x95, 0x05, // (GLOBAL)REPORT_COUNT 0x05 (5) Number of fields
0x81, 0x03, // (MAIN)INPUT 0x00000003 (5 fields x 1 bit) 1 = Constant 1 = Variable 0 = Absolute 0 = NoWrap 0 = Linear 0 = PrefState 0 = NoNull 0 = NonVolatile 0 = Bitmap
0x05, 0x01, // (GLOBAL)USAGE_PAGE 0x0001 Generic Desktop Page
0x09, 0x30, // (LOCAL)USAGE 0x00010030 X(DV = Dynamic Value)
0x09, 0x31, // (LOCAL)USAGE 0x00010031 Y(DV = Dynamic Value)
0x15, 0x81, // (GLOBAL)LOGICAL_MINIMUM 0x81 (-127)
0x25, 0x7F, // (GLOBAL)LOGICAL_MAXIMUM 0x7F (127)
0x75, 0x08, // (GLOBAL)REPORT_SIZE 0x08 (8) Number of bits per field
0x95, 0x02, // (GLOBAL)REPORT_COUNT 0x02 (2) Number of fields
0x81, 0x06, // (MAIN)INPUT 0x00000006 (2 fields x 8 bits) 0 = Data 1 = Variable 1 = Relative 0 = NoWrap 0 = Linear 0 = PrefState 0 = NoNull 0 = NonVolatile 0 = Bitmap
0xC0, // END_COLLECTION Physical
0x05, 0x0A, // (GLOBAL)USAGE_PAGE 0x000A Ordinal Page
0x09, 0x02, // (LOCAL)USAGE 0x000A0002 Instance 2 (UM = Usage Modifier)
0x85, 0x02, // (GLOBAL)REPORT_ID 0x02 (2)
0xA1, 0x00, // (MAIN)COLLECTION 0x00 Physical(Usage = 0x000A0002: Page = Ordinal Page, Usage = Instance 2, Type = UM) < --Warning: USAGE type should be CP(Physical)
0x05, 0x09, // (GLOBAL)USAGE_PAGE 0x0009 Button Page
0x19, 0x01, // (LOCAL)USAGE_MINIMUM 0x00090001 Button 1 Primary / trigger(MULTI = Selector, On / Off, Momentary, or One Shot)
0x29, 0x03, // (LOCAL)USAGE_MAXIMUM 0x00090003 Button 3 Tertiary(MULTI = Selector, On / Off, Momentary, or One Shot)
0x15, 0x00, // (GLOBAL)LOGICAL_MINIMUM 0x00 (0)
0x25, 0x01, // (GLOBAL)LOGICAL_MAXIMUM 0x01 (1)
0x75, 0x01, // (GLOBAL)REPORT_SIZE 0x01 (1) Number of bits per field
0x95, 0x03, // (GLOBAL)REPORT_COUNT 0x03 (3) Number of fields
0x81, 0x02, // (MAIN)INPUT 0x00000002 (3 fields x 1 bit) 0 = Data 1 = Variable 0 = Absolute 0 = NoWrap 0 = Linear 0 = PrefState 0 = NoNull 0 = NonVolatile 0 = Bitmap
0x95, 0x05, // (GLOBAL)REPORT_COUNT 0x05 (5) Number of fields
0x81, 0x03, // (MAIN)INPUT 0x00000003 (5 fields x 1 bit) 1 = Constant 1 = Variable 0 = Absolute 0 = NoWrap 0 = Linear 0 = PrefState 0 = NoNull 0 = NonVolatile 0 = Bitmap
0x05, 0x01, // (GLOBAL)USAGE_PAGE 0x0001 Generic Desktop Page
0x09, 0x30, // (LOCAL)USAGE 0x00010030 X(DV = Dynamic Value)
0x09, 0x31, // (LOCAL)USAGE 0x00010031 Y(DV = Dynamic Value)
0x15, 0x81, // (GLOBAL)LOGICAL_MINIMUM 0x81 (-127)
0x25, 0x7F, // (GLOBAL)LOGICAL_MAXIMUM 0x7F (127)
0x75, 0x08, // (GLOBAL)REPORT_SIZE 0x08 (8) Number of bits per field
0x95, 0x02, // (GLOBAL)REPORT_COUNT 0x02 (2) Number of fields
0x81, 0x06, // (MAIN)INPUT 0x00000006 (2 fields x 8 bits) 0 = Data 1 = Variable 1 = Relative 0 = NoWrap 0 = Linear 0 = PrefState 0 = NoNull 0 = NonVolatile 0 = Bitmap
0xC0, // END_COLLECTION Physical
0x05, 0x0A, // (GLOBAL)USAGE_PAGE 0x000A Ordinal Page
0x09, 0x03, // (LOCAL)USAGE 0x000A0003 Instance 3 (UM = Usage Modifier)
0x85, 0x03, // (GLOBAL)REPORT_ID 0x03 (3)
0xA1, 0x00, // (MAIN)COLLECTION 0x00 Physical(Usage = 0x000A0003: Page = Ordinal Page, Usage = Instance 3, Type = UM) < --Warning: USAGE type should be CP(Physical)
0x05, 0x09, // (GLOBAL)USAGE_PAGE 0x0009 Button Page
0x19, 0x01, // (LOCAL)USAGE_MINIMUM 0x00090001 Button 1 Primary / trigger(MULTI = Selector, On / Off, Momentary, or One Shot)
0x29, 0x03, // (LOCAL)USAGE_MAXIMUM 0x00090003 Button 3 Tertiary(MULTI = Selector, On / Off, Momentary, or One Shot)
0x15, 0x00, // (GLOBAL)LOGICAL_MINIMUM 0x00 (0)
0x25, 0x01, // (GLOBAL)LOGICAL_MAXIMUM 0x01 (1)
0x75, 0x01, // (GLOBAL)REPORT_SIZE 0x01 (1) Number of bits per field
0x95, 0x03, // (GLOBAL)REPORT_COUNT 0x03 (3) Number of fields
0x81, 0x02, // (MAIN)INPUT 0x00000002 (3 fields x 1 bit) 0 = Data 1 = Variable 0 = Absolute 0 = NoWrap 0 = Linear 0 = PrefState 0 = NoNull 0 = NonVolatile 0 = Bitmap
0x95, 0x05, // (GLOBAL)REPORT_COUNT 0x05 (5) Number of fields
0x81, 0x03, // (MAIN)INPUT 0x00000003 (5 fields x 1 bit) 1 = Constant 1 = Variable 0 = Absolute 0 = NoWrap 0 = Linear 0 = PrefState 0 = NoNull 0 = NonVolatile 0 = Bitmap
0x05, 0x01, // (GLOBAL)USAGE_PAGE 0x0001 Generic Desktop Page
0x09, 0x30, // (LOCAL)USAGE 0x00010030 X(DV = Dynamic Value)
0x09, 0x31, // (LOCAL)USAGE 0x00010031 Y(DV = Dynamic Value)
0x15, 0x81, // (GLOBAL)LOGICAL_MINIMUM 0x81 (-127)
0x25, 0x7F, // (GLOBAL)LOGICAL_MAXIMUM 0x7F (127)
0x75, 0x08, // (GLOBAL)REPORT_SIZE 0x08 (8) Number of bits per field
0x95, 0x02, // (GLOBAL)REPORT_COUNT 0x02 (2) Number of fields
0x81, 0x06, // (MAIN)INPUT 0x00000006 (2 fields x 8 bits) 0 = Data 1 = Variable 1 = Relative 0 = NoWrap 0 = Linear 0 = PrefState 0 = NoNull 0 = NonVolatile 0 = Bitmap
0xC0, // END_COLLECTION Physical
0x05, 0x0A, // (GLOBAL)USAGE_PAGE 0x000A Ordinal Page
0x09, 0x04, // (LOCAL)USAGE 0x000A0004 Instance 4 (UM = Usage Modifier)
0x85, 0x04, // (GLOBAL)REPORT_ID 0x04 (4)
0xA1, 0x00, // (MAIN)COLLECTION 0x00 Physical(Usage = 0x000A0004: Page = Ordinal Page, Usage = Instance 4, Type = UM) < --Warning: USAGE type should be CP(Physical)
0x05, 0x09, // (GLOBAL)USAGE_PAGE 0x0009 Button Page
0x19, 0x01, // (LOCAL)USAGE_MINIMUM 0x00090001 Button 1 Primary / trigger(MULTI = Selector, On / Off, Momentary, or One Shot)
0x29, 0x03, // (LOCAL)USAGE_MAXIMUM 0x00090003 Button 3 Tertiary(MULTI = Selector, On / Off, Momentary, or One Shot)
0x15, 0x00, // (GLOBAL)LOGICAL_MINIMUM 0x00 (0)
0x25, 0x01, // (GLOBAL)LOGICAL_MAXIMUM 0x01 (1)
0x75, 0x01, // (GLOBAL)REPORT_SIZE 0x01 (1) Number of bits per field
0x95, 0x03, // (GLOBAL)REPORT_COUNT 0x03 (3) Number of fields
0x81, 0x02, // (MAIN)INPUT 0x00000002 (3 fields x 1 bit) 0 = Data 1 = Variable 0 = Absolute 0 = NoWrap 0 = Linear 0 = PrefState 0 = NoNull 0 = NonVolatile 0 = Bitmap
0x95, 0x05, // (GLOBAL)REPORT_COUNT 0x05 (5) Number of fields
0x81, 0x03, // (MAIN)INPUT 0x00000003 (5 fields x 1 bit) 1 = Constant 1 = Variable 0 = Absolute 0 = NoWrap 0 = Linear 0 = PrefState 0 = NoNull 0 = NonVolatile 0 = Bitmap
0x05, 0x01, // (GLOBAL)USAGE_PAGE 0x0001 Generic Desktop Page
0x09, 0x30, // (LOCAL)USAGE 0x00010030 X(DV = Dynamic Value)
0x09, 0x31, // (LOCAL)USAGE 0x00010031 Y(DV = Dynamic Value)
0x15, 0x81, // (GLOBAL)LOGICAL_MINIMUM 0x81 (-127)
0x25, 0x7F, // (GLOBAL)LOGICAL_MAXIMUM 0x7F (127)
0x75, 0x08, // (GLOBAL)REPORT_SIZE 0x08 (8) Number of bits per field
0x95, 0x02, // (GLOBAL)REPORT_COUNT 0x02 (2) Number of fields
0x81, 0x06, // (MAIN)INPUT 0x00000006 (2 fields x 8 bits) 0 = Data 1 = Variable 1 = Relative 0 = NoWrap 0 = Linear 0 = PrefState 0 = NoNull 0 = NonVolatile 0 = Bitmap
0xC0, // END_COLLECTION Physical
0xC0, // END_COLLECTION Logical
0xC0, // END_COLLECTION Application
};
这是我当前使用的示例附带的默认报告结构(直到我弄清楚我可以在其中更改什么):
typedef struct _HIDMINI_INPUT_REPORT {
UCHAR ReportId;
UCHAR Data;
} HIDMINI_INPUT_REPORT, *PHIDMINI_INPUT_REPORT;
//
// output to device from system
//
typedef struct _HIDMINI_OUTPUT_REPORT {
UCHAR ReportId;
UCHAR Data;
USHORT Pad1;
ULONG Pad2;
} HIDMINI_OUTPUT_REPORT, *PHIDMINI_OUTPUT_REPORT;
我的问题是 4 折:
我需要将 4 个鼠标设备的数据从控件集合(到达鼠标设备注释开始之前的第一个集合)向下传递到鼠标集合中。我将如何编写报告描述符来执行此操作,或者我是否需要代码来执行此操作?
我的报表结构代码如何查找从 Windows.Devices.HumanInterfaceDevice 读取/写入控制结构的内容?
我是否应该像 vmulti 一样发送每个报告描述符,除了全部在一个循环中?
- 如果我想为多点鼠标 SDK 或其他多鼠标应用程序模拟/模拟鼠标设备,上述操作需要多少? (向多鼠标应用程序发送输入)
注意:我计划使用https://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.humaninterfacedevice.aspx 类函数从上面定义的 4 个鼠标设备中读取/写入,这就是为什么我要费尽心思弄清楚这些东西的原因。但是 msdn 上的课程明确指出我不能直接写入鼠标设备。如果是这样,我就不会在这里写了。 万一出现问题:是的,这是关于将输入注入鼠标集合,以便我可以让它们与多鼠标应用程序一起使用。 上面指向 WudfVhidmin-Sample 的链接不是我的代码但是我用来编写驱动程序的示例。
如果我在第一个结束集合评论之前取出部分,它会创建三个鼠标设备,但就是这样。
【问题讨论】:
-
这里是在线源代码的 vmulti 链接,看看我上面说的是什么:链接在这里:code.google.com/p/vmulti/source/browse/test/testvmulti.c
-
P.S.这是一些 Microsoft WDK 论坛工作人员推荐的我正在使用的描述符工具:usb.org/developers/hidpage#HID Descriptor Tool。
标签: c++ c windows device-driver hid