(sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget)/translations/zh_CN/hid/hidreport-parsingmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget)/translations/zh_TW/hid/hidreport-parsingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget)/translations/it_IT/hid/hidreport-parsingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget)/translations/ja_JP/hid/hidreport-parsingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget)/translations/ko_KR/hid/hidreport-parsingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget)/translations/sp_SP/hid/hidreport-parsingmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhC/var/lib/git/docbuild/linux/Documentation/hid/hidreport-parsing.rsthKubhsection)}(hhh](htitle)}(h(Manual parsing of HID report descriptorsh]h(Manual parsing of HID report descriptors}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(h]Consider again the mouse HID report descriptor introduced in Documentation/hid/hidintro.rst::h]h\Consider again the mouse HID report descriptor introduced in Documentation/hid/hidintro.rst:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh literal_block)}(hX$ hexdump -C /sys/bus/hid/devices/0003\:093A\:2510.0002/report_descriptor 00000000 05 01 09 02 a1 01 09 01 a1 00 05 09 19 01 29 03 |..............).| 00000010 15 00 25 01 75 01 95 03 81 02 75 05 95 01 81 01 |..%.u.....u.....| 00000020 05 01 09 30 09 31 09 38 15 81 25 7f 75 08 95 03 |...0.1.8..%.u...| 00000030 81 06 c0 c0 |....| 00000034h]hX$ hexdump -C /sys/bus/hid/devices/0003\:093A\:2510.0002/report_descriptor 00000000 05 01 09 02 a1 01 09 01 a1 00 05 09 19 01 29 03 |..............).| 00000010 15 00 25 01 75 01 95 03 81 02 75 05 95 01 81 01 |..%.u.....u.....| 00000020 05 01 09 30 09 31 09 38 15 81 25 7f 75 08 95 03 |...0.1.8..%.u...| 00000030 81 06 c0 c0 |....| 00000034}hhsbah}(h]h ]h"]h$]h&]hhuh1hhhhK hhhhubh)}(hand try to parse it by hand.h]hand try to parse it by hand.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hStart with the first number, 0x05: it carries 2 bits for the length of the item, 2 bits for the type of the item and 4 bits for the function::h]hStart with the first number, 0x05: it carries 2 bits for the length of the item, 2 bits for the type of the item and 4 bits for the function:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hX+----------+ | 00000101 | +----------+ ^^ ---- Length of data (see HID spec 6.2.2.2) ^^ ------ Type of the item (see HID spec 6.2.2.2, then jump to 6.2.2.7) ^^^^ --------- Function of the item (see HID spec 6.2.2.7, then HUT Sec 3)h]hX+----------+ | 00000101 | +----------+ ^^ ---- Length of data (see HID spec 6.2.2.2) ^^ ------ Type of the item (see HID spec 6.2.2.2, then jump to 6.2.2.7) ^^^^ --------- Function of the item (see HID spec 6.2.2.7, then HUT Sec 3)}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhhhhubh)}(hIn our case, the length is 1 byte, the type is ``Global`` and the function is ``Usage Page``, thus for parsing the value 0x01 in the second byte we need to refer to HUT Sec 3.h](h/In our case, the length is 1 byte, the type is }(hjhhhNhNubhliteral)}(h ``Global``h]hGlobal}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh and the function is }(hjhhhNhNubj)}(h``Usage Page``h]h Usage Page}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhS, thus for parsing the value 0x01 in the second byte we need to refer to HUT Sec 3.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK!hhhhubh)}(hThe second number is the actual data, and its meaning can be found in the HUT. We have a ``Usage Page``, thus we need to refer to HUT Sec. 3, "Usage Pages"; from there, one sees that ``0x01`` stands for ``Generic Desktop Page``.h](hYThe second number is the actual data, and its meaning can be found in the HUT. We have a }(hjGhhhNhNubj)}(h``Usage Page``h]h Usage Page}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjGubhT, thus we need to refer to HUT Sec. 3, “Usage Pages”; from there, one sees that }(hjGhhhNhNubj)}(h``0x01``h]h0x01}(hjahhhNhNubah}(h]h ]h"]h$]h&]uh1jhjGubh stands for }(hjGhhhNhNubj)}(h``Generic Desktop Page``h]hGeneric Desktop Page}(hjshhhNhNubah}(h]h ]h"]h$]h&]uh1jhjGubh.}(hjGhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK%hhhhubh)}(hXMoving now to the second two bytes, and following the same scheme, ``0x09`` (i.e. ``00001001``) will be followed by one byte (``01``) and is a ``Local`` item (``10``). Thus, the meaning of the remaining four bits (``0000``) is given in the HID spec Sec. 6.2.2.8 "Local Items", so that we have a ``Usage``. From HUT, Sec. 4, "Generic Desktop Page", we see that 0x02 stands for ``Mouse``.h](hCMoving now to the second two bytes, and following the same scheme, }(hjhhhNhNubj)}(h``0x09``h]h0x09}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh (i.e. }(hjhhhNhNubj)}(h ``00001001``h]h00001001}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh ) will be followed by one byte (}(hjhhhNhNubj)}(h``01``h]h01}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh ) and is a }(hjhhhNhNubj)}(h ``Local``h]hLocal}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh item (}(hjhhhNhNubj)}(h``10``h]h10}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh1). Thus, the meaning of the remaining four bits (}(hjhhhNhNubj)}(h``0000``h]h0000}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhM) is given in the HID spec Sec. 6.2.2.8 “Local Items”, so that we have a }(hjhhhNhNubj)}(h ``Usage``h]hUsage}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhM. From HUT, Sec. 4, “Generic Desktop Page”, we see that 0x02 stands for }(hjhhhNhNubj)}(h ``Mouse``h]hMouse}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK*hhhhubh)}(h4The following numbers can be parsed in the same way.h]h4The following numbers can be parsed in the same way.}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK1hhhhubeh}(h](manual-parsing-of-hid-report-descriptorsah ]h"](manual parsing of hid report descriptorsah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjberror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}j<j9s nametypes}j<sh}j9hs footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.