2012-12-13 91 views
1

我需要獲取有關Wheell單擊並從不同鼠標釋放的信息。我在嵌入式設備上工作,可以訪問原始形式的所有數據 - 字節流。HID報告描述符解析器:如何找到「點擊」位位置

AFAIK所有傳輸的字節在HID報告描述符鼠標中描述。我有兩個HID報告描述符和2點不同的鼠標傳輸的幀,但我不知道怎麼去理解他們:

HID羅技:

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 

羅技幀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 

回答

2

報告描述符格式在Device Class definiton for 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個按鈕,可以將其初始化爲啓動設備。任何鼠標都將具有相同的報告結構(請參閱引導鼠標),並且可以將其硬編碼到您的應用程序中。