USB HID Report Descriptor 報告描述符詳解

來源:互聯網
上載者:User

標籤:des   style   http   color   os   檔案   

Report descriptors are composed of pieces of information. Each piece of information is called an Item.
報告描述符由一些資料片組成。這些資料片被叫做Item。
All items have a one-byte prefix that contains the item tag, item type, and item size. 
每一個Item都包含一個位元組的首碼,這個首碼中包含了三個資訊--item tag,、item type、item size。
An item may include optional item data。
Item可以包含一個可選的資料區段。
The size of the data portion of an item is determined by its fundamental type.
Item的資料部分的長度取決於Item的基本類型。
There are two basic types of items: short items and long items.
Item有兩種基本類型:short items and long item。

long item格式 (原檔案名稱:long item.jpg) 


short item格式 (原檔案名稱:short item.jpg) 

There are three categories of short item tags: Main, Global, and Local. 
short item 的 item tags 有三種類型:Main, Global, and Local.

Main items: </center>
Main items are used to either define or group certain types of data fields within a Report descriptor. There are two types of Main items: data and non-data. Data-type Main items are used to create a field within a report and include Input, Output, and Feature. Other items do not create fields and are subsequently referred to as non-data Main items. 


(原檔案名稱:MAIN Item.jpg) 

(原檔案名稱:MAIN Item1.jpg) 
好了,到此我們應該可以對照實際應用的報告描述符,尋找其中的 Main items了。 

至此我們已經可以明白報告描述符中的幾個MAIN Item的意義,接下來繼續看Global Item 和 Local Item.

Global Item: </center>
Global items describe rather than define data from a control. A new Main item assumes the characteristics of the item state table. Global items can change the state table. As a result Global item tags apply to all subsequently defined items unless overridden by another Global item.  

(原檔案名稱:Global Item.jpg) 

(原檔案名稱:Global Item1.jpg) 

至此我們已經可以明白報告描述符中的幾個Global Item的意義

Local Item: </center> 
Local item tags define characteristics of controls. These items do not carry over to the next Main item. If a Main item defines more than one control, it may be preceded by several similar Local item tags. For example, an Input item may have several Usage tags associated with it, one for each control.  

(原檔案名稱:Local Item.jpg) 
至此我們已經可以明白報告描述符中的幾個Local Item的意義

//該報告描述符號由HID Descriptor tool產生   
以下是一個USB滑鼠的報告描述符 
code char MouseReportDescriptor[63] = {    
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)    
    0x09, 0x06,                  // USAGE (Keyboard)    
    0xa1, 0x01,                    // COLLECTION (Application)   這就是一個MAIN Item,可以對應查看   
    0x05, 0x07,                    //   USAGE_PAGE (Keyboard)    
    0x19, 0xe0,                    //   USAGE_MINIMUM (Keyboard LeftControl)    
    0x29, 0xe7,                    //   USAGE_MAXIMUM (Keyboard Right GUI)    
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)    
    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)    
    0x75, 0x01,                    //   REPORT_SIZE (1)    
    0x95, 0x08,                    //   REPORT_COUNT (8)    
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)     這就是一個MAIN Item,可以對應查看  
    0x95, 0x01,                    //   REPORT_COUNT (1)    
    0x75, 0x08,                    //   REPORT_SIZE (8)    
    0x81, 0x03,                    //   INPUT (Cnst,Var,Abs)     這就是一個MAIN Item,可以對應查看  
    0x95, 0x05,                    //   REPORT_COUNT (5)    
    0x75, 0x01,                    //   REPORT_SIZE (1)    
    0x05, 0x08,                    //   USAGE_PAGE (LEDs)    
    0x19, 0x01,                    //   USAGE_MINIMUM (Num Lock)    
    0x29, 0x05,                    //   USAGE_MAXIMUM (Kana)    
    0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)     這就是一個MAIN Item,可以對應查看   
    0x95, 0x01,                    //   REPORT_COUNT (1)    
    0x75, 0x03,                    //   REPORT_SIZE (3)    
    0x91, 0x03,                    //   OUTPUT (Cnst,Var,Abs)     這就是一個MAIN Item,可以對應查看  
    0x95, 0x06,                    //   REPORT_COUNT (6)    
    0x75, 0x08,                    //   REPORT_SIZE (8)    
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)    
    0x25, 0xFF,                    //   LOGICAL_MAXIMUM (255)    
    0x05, 0x07,                    //   USAGE_PAGE (Keyboard)    
    0x19, 0x00,                    //   USAGE_MINIMUM (Reserved (no event indicated))    
    0x29, 0x65,                    //   USAGE_MAXIMUM (Keyboard Application)    
    0x81, 0x00,                    //   INPUT (Data,Ary,Abs)     這就是一個MAIN Item,可以對應查看   
    0xc0                           // END_COLLECTION             這就是一個MAIN Item,可以對應查看          
}; 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.