{"id":1288,"date":"2014-01-17T09:21:52","date_gmt":"2014-01-17T09:21:52","guid":{"rendered":"https:\/\/ibex.tech\/resources\/?p=1288"},"modified":"2022-02-18T15:05:16","modified_gmt":"2022-02-18T15:05:16","slug":"usb-hid-report-descriptors","status":"publish","type":"post","link":"https:\/\/ibex.tech\/resources\/geek-area\/communications\/usb\/usb-hid-report-descriptors","title":{"rendered":"USB HID Report Descriptors"},"content":{"rendered":"<h4>\nUSB Org resources<br \/>\n<\/h4>\n<p>\nThe full spec and downloadable tables etc can be found <a href=\"http:\/\/www.usb.org\/developers\/hidpage#Class_Definitions\">here<\/a> (Device Class Definition for HID).\n<\/p>\n<p>\n<strong>Get the &#39;HID descriptor tool&#39; from the same page to help create descriptors &#8211; very handy!!!<\/strong>\n<\/p>\n<h4>\nOverview<br \/>\n<\/h4>\n<p>\nA USB HID Report Descriptor is requested by a USB host from a USB device.&nbsp; It tells the host how to interpret the report data packets the device sends to it.&nbsp; It includes:\n<\/p>\n<p style=\"margin-left: 40px;\">\nHow many packets the device supports\n<\/p>\n<p style=\"margin-left: 40px;\">\nPacket sizes\n<\/p>\n<p style=\"margin-left: 40px;\">\nThe purpose of each byte in each packet\n<\/p>\n<h4>\nThe HID Report<br \/>\n<\/h4>\n<p>\nAn example USB HID Report Descriptor\n<\/p>\n<pre>\r\n<code>\r\n0x05, 0x01,          \/\/ USAGE_PAGE = Generic Desktop (<\/code>USAGE_PAGE<code> is much like a namespace, see &quot;<\/code>HID Usage&quot; in the specs<code>)\r\n0x09, 0x02,          \/\/ USAGE = Mouse (one of the available usages from the selected <\/code>USAGE_PAGE)<code>\r\n0xa1, 0x01,          \/\/ COLLECTION = Application (<\/code>Allows you to define different groups of related attributes etc)<code>\r\n0x09, 0x01,          \/\/   USAGE = Pointer (an available sub USAGE of the parent USAGE)\r\n0xa1, 0x00,          \/\/   COLLECTION = Physical (<\/code>Allows you to define different groups of related attributes etc)<code>\r\n0x05, 0x09,          \/\/     USAGE_PAGE = Button (a change of USAGE_PAGE, like moving to a new namespace)\r\n0x19, 0x01,          \/\/     USAGE_MINIMUM = Button 1 (specifying the buttons)\r\n0x29, 0x03,          \/\/     USAGE_MAXIMUM = Button 3<\/code>&nbsp;(specifying the buttons)<code>\r\n0x15, 0x00,          \/\/     LOGICAL_MINIMUM = 0 (the min value that can be reported)\r\n0x25, 0x01,          \/\/     LOGICAL_MAXIMUM = 1 (the max value that can be reported)\r\n0x95, 0x03,          \/\/     REPORT_COUNT = 3 (total number of reported data fields, in this case the number of buttons)\r\n0x75, 0x01,          \/\/     REPORT_SIZE = 1 (bits used per report field, size will be 3 fields x 1 bit = 3 bits))\r\n0x81, 0x02,          \/\/     INPUT = Data,Var,Abs (add the above data variables to the report)\r\n0x95, 0x01,          \/\/     REPORT_COUNT = 1\r\n0x75, 0x05,          \/\/     REPORT_SIZE = 5\r\n0x81, 0x03,          \/\/     INPUT = Cnst,Var,Abs<\/code>&nbsp;(add the above constant data to the report, in this case padding bits)<code>\r\n0x05, 0x01,          \/\/     USAGE_PAGE = Generic Desktop (returning USAGE_PAGE back again)\r\n0x09, 0x30,          \/\/     USAGE = X (specifying the mouse X axis)\r\n0x09, 0x31,          \/\/     USAGE = Y<\/code>&nbsp;(specifying the mouse Y axis)<code>\r\n0x15, 0x81,          \/\/     LOGICAL_MINIMUM = -127\r\n0x25, 0x7f,          \/\/     LOGICAL_MAXIMUM = 127\r\n0x75, 0x08,          \/\/     REPORT_SIZE = 8\r\n0x95, 0x02,          \/\/     REPORT_COUNT = 2\r\n0x81, 0x06,          \/\/     INPUT = Data,Var,Rel\r\n0xc0,                \/\/   END_COLLECTION\r\n0xc0,                \/\/ END_COLLECTION\r\n<\/code><\/pre>\n<p>\n&nbsp;\n<\/p>\n<p>\nUSAGE_PAGE\n<\/p>\n<p style=\"margin-left: 40px;\">\nYou first set a usage page.&nbsp; Above it is using &#39;Generic Desktop&#39;\n<\/p>\n<p style=\"margin-left: 40px;\">\nUSAGE_PAGE page is much like a namespace.\n<\/p>\n<p style=\"margin-left: 40px;\">\nSee &quot;HID Usage&quot; in the specs.\n<\/p>\n<p>\nUSAGE\n<\/p>\n<p style=\"margin-left: 40px;\">\nA usage from the available usages in the usage page setting\n<\/p>\n<p>\nCOLLECTION\n<\/p>\n<p style=\"margin-left: 40px;\">\nAllows you to define different groups of related attributes etc\n<\/p>\n<p>\nINPUT\n<\/p>\n<p style=\"margin-left: 40px;\">\nData,Var,Abs\n<\/p>\n<p style=\"margin-left: 80px;\">\nAdd the above data variables to the report\n<\/p>\n<p style=\"margin-left: 40px;\">\nCnst,Var,Abs\n<\/p>\n<p style=\"margin-left: 80px;\">\nAdd the above constant variables to the report (e.g. padding bits to byte align for the next data section)\n<\/p>\n<p>\n&nbsp;\n<\/p>\n<h4>\nGood Resources<br \/>\n<\/h4>\n<p>\n<a href=\"http:\/\/eleccelerator.com\/tutorial-about-usb-hid-report-descriptors\/\">http:\/\/eleccelerator.com\/tutorial-about-usb-hid-report-descriptors\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>USB Org resources The full spec and downloadable tables etc can be found here (Device Class Definition for HID). Get the &#39;HID descriptor tool&#39; from the same page to help create descriptors &#8211; very handy!!! Overview A USB HID Report Descriptor is requested by a USB host from a USB device.&nbsp; It tells the host [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[],"class_list":["post-1288","post","type-post","status-publish","format-standard","hentry","category-usb"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/1288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/comments?post=1288"}],"version-history":[{"count":5,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/1288\/revisions"}],"predecessor-version":[{"id":1291,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/1288\/revisions\/1291"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/media?parent=1288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/categories?post=1288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/tags?post=1288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}