HID报告描述符解析器:如何找到“单击”位位置

时间:2012-12-13 16:38:51

标签: usb mouse hid

我需要获取有关Wheell点击并从不同鼠标中释放的信息。我在嵌入式设备上工作,可以访问原始形式的所有数据 - 字节流。

AFAIK所有传输的字节在HID报告描述符鼠标中描述。我同时拥有2个不同鼠标的HID报告描述符和传输帧,但我不确定如何理解它们:

HID Logitech:

Interface 0 HID Report Descriptor Mouse
Item Tag (Value) Raw Data 
Usage Page (Generic Desktop) 05 01  
Usage (Mouse) 09 02  
Collection (Application) A1 01  
    Usage (Pointer) 09 01  
    Collection (Physical) A1 00  
        Usage Page (Button) 05 09  
        Usage Minimum (Button 1) 19 01  
        Usage Maximum (Button 3) 29 03  
        Logical Minimum (0) 15 00  
        Logical Maximum (1) 25 01  
        Report Size (1) 75 01  
        Report Count (3) 95 03  
        Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02  
        Report Size (5) 75 05  
        Report Count (1) 95 01  
        Input (Cnst,Ary,Abs) 81 01  
        Usage Page (Generic Desktop) 05 01  
        Usage (X) 09 30  
        Usage (Y) 09 31  
        Usage (Wheel) 09 38  
        Logical Minimum (-127) 15 81  
        Logical Maximum (127) 25 7F  
        Report Size (8) 75 08  
        Report Count (3) 95 03  
        Input (Data,Var,Rel,NWrp,Lin,Pref,NNul,Bit) 81 06  
    End Collection C0  
End Collection C0  

Logitech框架为4字节,首先是按钮:

00 00 00 00 : Button OFF (on release), X=0, Y=0, Whell=0
01 00 00 00 : Button 1 ON, X=0, Y=0, Whell=0
02 00 00 00 : Button 2 ON, X=0, Y=0, Whell=0

HID YACOSS:

Interface 0 HID Report Descriptor Mouse
Item Tag (Value) Raw Data 
Usage Page (Generic Desktop) 05 01  
Usage (Mouse) 09 02  
Collection (Application) A1 01  
    Report ID (1) 85 01  
    Usage (Pointer) 09 01  
    Collection (Physical) A1 00  
        Usage Page (Button) 05 09  
        Usage Minimum (Button 1) 19 01  
        Usage Maximum (Button 3) 29 03  
        Logical Minimum (0) 15 00  
        Logical Maximum (1) 25 01  
        Report Count (3) 95 03  
        Report Size (1) 75 01  
        Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02  
        Report Count (1) 95 01  
        Report Size (5) 75 05  
        Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 03  
        Usage Page (Generic Desktop) 05 01  
        Logical Minimum (-2047) 16 01 F8  
        Logical Maximum (2047) 26 FF 07  
        Report Size (12) 75 0C  
        Report Count (2) 95 02  
    Usage (X) 09 30  
    Usage (Y) 09 31  
    Input (Data,Var,Rel,NWrp,Lin,Pref,NNul,Bit) 81 06  
    Logical Minimum (-127) 15 81  
    Logical Maximum (127) 25 7F  
    Report Size (8) 75 08  
    Report Count (1) 95 01  
    Usage (Wheel) 09 38  
    Input (Data,Var,Rel,NWrp,Lin,Pref,NNul,Bit) 81 06  
    End Collection C0  
    Usage Page (Consumer Devices) 05 0C  
    Usage (AC Pan) 0A 38 02  
    Report Count (1) 95 01  
    Input (Data,Var,Rel,NWrp,Lin,Pref,NNul,Bit) 81 06  
End Collection C0  
Usage Page 06 F3 F1  
Usage 0A F3 F1  
Collection (Application) A1 01  
    Report ID (2) 85 02  
    Usage 09 00  
    Report Count (1) 95 01  
    Report Size (8) 75 08  
    Logical Minimum (0) 15 00  
    Logical Maximum (255) 26 FF 00  
    Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02  
End Collection C0  

YACOSS帧为7字节,第二帧为按钮:

01 00 00 00 00 00 00 Button 1 OFF (released), X=0, Y=0, Wheel=0, AC Pan=0 
01 01 00 00 00 00 00 Button 1 ON , X=0, Y=0, Wheel=0, AC Pan=0 
01 02 00 00 00 00 00 Button 2 ON , X=0, Y=0, Wheel=0, AC Pan=0 

1 个答案:

答案 0 :(得分:2)

报告描述符格式在设备类定义中针对HID进行了解释。小鼠也包含在HID使用表doc中。所有这些都可以在usb.org的HID页面上找到 - > http://www.usb.org/developers/docs/hidpage/

关于嵌入式HID的博客,包括报告描述符,这里 - > http://www.circuitsathome.com/category/mcu/arduino/usb-shield/hid

此外,如果您只需要鼠标的某些功能,例如X,Y,滚轮和3个按钮,则可以将其初始化为启动设备。任何鼠标都将具有相同的报告结构(请参阅启动鼠标),您可以将其硬编码到您的应用程序中。