py-hidreport


Namepy-hidreport JSON
Version 1.0.0a0 PyPI version JSON
download
home_pageNone
Summarya realization of report descriptor parser and codec context.
upload_time2025-08-16 14:07:03
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseCopyright © 2025 ThankVinci Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords hid report-desc usb
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python USB HID Report Descriptor

A realization of report descriptor parser and codec context.

## parser example

```python
from py_hidreport.items import *
from py_hidreport.usages import *
from py_hidreport.pages import *
from py_hidreport.parser import ReportDescParser
bin = b'\x05\x01\x09\x06\xA1\x01\x05\x07\x19\xE0\x29\xE7\x15\x00\x25\x01\x75\x01\x95\x08\x81\x02\x95\x01\x75\x08\x81\x03\x95\x05\x75\x01\x05\x08\x19\x01\x29\x05\x91\x02\x95\x01\x75\x03\x91\x03\x95\x06\x75\x08\x15\x00\x25\x65\x05\x07\x19\x00\x29\x65\x81\x00\xC0'
code:str = ReportDescParser.parse(bin)
prnt(code)
```

## codec example

```python
from py_hidreport.items import *
from py_hidreport.usages import *
from py_hidreport.pages import *
from py_hidreport.ctx import ReportDescStdContext

ReportDescContext.Set(ReportDescStdContext())

code = '''UsagePage(GenericDesktop)
    Usage(GenericDesktopPage.Mouse)
    Collection(Application)
    Usage(GenericDesktopPage.Pointer)
    Collection (Physical)
    UsagePage (Button) 
    UsageMinimum (1)
    UsageMaximum (3)
    LogicalMinimum (0)
    LogicalMaximum (1)
    ReportCount (3)
    ReportSize (1)
    Input (Data, Variable, Absolute)
    ReportCount (1)
    ReportSize (5)
    Input (Constant)
    UsagePage (GenericDesktop)
    Usage (GenericDesktopPage.X)
    Usage (GenericDesktopPage.Y)
    LogicalMinimum (-127)
    LogicalMaximum (127)
    ReportSize (8)
    ReportCount (2)
    Input(Data, Variable, Relative)
    EndCollection()
    EndCollection()
    '''
code = code.replace('\n','+')
code = code.replace(' ','')
code = code[:-1]
exec(code)
print(ReportDescContext.Data())

```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "py-hidreport",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "hid, report-desc, usb",
    "author": null,
    "author_email": "ThankVinci <thankvinci@163.com>",
    "download_url": null,
    "platform": null,
    "description": "# Python USB HID Report Descriptor\r\n\r\nA realization of report descriptor parser and codec context.\r\n\r\n## parser example\r\n\r\n```python\r\nfrom py_hidreport.items import *\r\nfrom py_hidreport.usages import *\r\nfrom py_hidreport.pages import *\r\nfrom py_hidreport.parser import ReportDescParser\r\nbin = b'\\x05\\x01\\x09\\x06\\xA1\\x01\\x05\\x07\\x19\\xE0\\x29\\xE7\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\\x05\\x08\\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03\\x95\\x06\\x75\\x08\\x15\\x00\\x25\\x65\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xC0'\r\ncode:str = ReportDescParser.parse(bin)\r\nprnt(code)\r\n```\r\n\r\n## codec example\r\n\r\n```python\r\nfrom py_hidreport.items import *\r\nfrom py_hidreport.usages import *\r\nfrom py_hidreport.pages import *\r\nfrom py_hidreport.ctx import ReportDescStdContext\r\n\r\nReportDescContext.Set(ReportDescStdContext())\r\n\r\ncode = '''UsagePage(GenericDesktop)\r\n    Usage(GenericDesktopPage.Mouse)\r\n    Collection(Application)\r\n    Usage(GenericDesktopPage.Pointer)\r\n    Collection (Physical)\r\n    UsagePage (Button) \r\n    UsageMinimum (1)\r\n    UsageMaximum (3)\r\n    LogicalMinimum (0)\r\n    LogicalMaximum (1)\r\n    ReportCount (3)\r\n    ReportSize (1)\r\n    Input (Data, Variable, Absolute)\r\n    ReportCount (1)\r\n    ReportSize (5)\r\n    Input (Constant)\r\n    UsagePage (GenericDesktop)\r\n    Usage (GenericDesktopPage.X)\r\n    Usage (GenericDesktopPage.Y)\r\n    LogicalMinimum (-127)\r\n    LogicalMaximum (127)\r\n    ReportSize (8)\r\n    ReportCount (2)\r\n    Input(Data, Variable, Relative)\r\n    EndCollection()\r\n    EndCollection()\r\n    '''\r\ncode = code.replace('\\n','+')\r\ncode = code.replace(' ','')\r\ncode = code[:-1]\r\nexec(code)\r\nprint(ReportDescContext.Data())\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "Copyright \u00a9 2025 ThankVinci\r\n        \r\n        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\r\n        \r\n        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n        \r\n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "a realization of report descriptor parser and codec context.",
    "version": "1.0.0a0",
    "project_urls": null,
    "split_keywords": [
        "hid",
        " report-desc",
        " usb"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6b139cc9cfb887d301dce2699ec32bf353a4f0a4512b2945d86f8f6107d700fc",
                "md5": "acf8b6d66a184a687909189f281bf5ab",
                "sha256": "d19c35fd641591b7579ae67c762b83b43ba7011ed57b687e340e59ddd4653a2e"
            },
            "downloads": -1,
            "filename": "py_hidreport-1.0.0a0-py38-none-any.whl",
            "has_sig": false,
            "md5_digest": "acf8b6d66a184a687909189f281bf5ab",
            "packagetype": "bdist_wheel",
            "python_version": "py38",
            "requires_python": ">=3.8",
            "size": 63099,
            "upload_time": "2025-08-16T14:07:03",
            "upload_time_iso_8601": "2025-08-16T14:07:03.578392Z",
            "url": "https://files.pythonhosted.org/packages/6b/13/9cc9cfb887d301dce2699ec32bf353a4f0a4512b2945d86f8f6107d700fc/py_hidreport-1.0.0a0-py38-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-16 14:07:03",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "py-hidreport"
}
        
Elapsed time: 1.37215s