{"id":16318737,"url":"https://github.com/nzsmartie/pyhidparser","last_synced_at":"2026-03-07T09:33:00.532Z","repository":{"id":83096648,"uuid":"56852171","full_name":"NZSmartie/PyHIDParser","owner":"NZSmartie","description":"A HID descriptor parser written in Python 3","archived":false,"fork":false,"pushed_at":"2018-11-26T08:36:10.000Z","size":84,"stargazers_count":23,"open_issues_count":8,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T10:03:26.344Z","etag":null,"topics":["bluetooth","decode","encode","hid","parse","usb"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NZSmartie.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-22T11:59:09.000Z","updated_at":"2024-09-05T08:02:28.000Z","dependencies_parsed_at":"2023-03-12T17:28:36.314Z","dependency_job_id":null,"html_url":"https://github.com/NZSmartie/PyHIDParser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NZSmartie/PyHIDParser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NZSmartie%2FPyHIDParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NZSmartie%2FPyHIDParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NZSmartie%2FPyHIDParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NZSmartie%2FPyHIDParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NZSmartie","download_url":"https://codeload.github.com/NZSmartie/PyHIDParser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NZSmartie%2FPyHIDParser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30210849,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bluetooth","decode","encode","hid","parse","usb"],"created_at":"2024-10-10T22:24:28.262Z","updated_at":"2026-03-07T09:33:00.524Z","avatar_url":"https://github.com/NZSmartie.png","language":"Python","readme":"# PyHIDParser\n#### V0.0.7\n\nA python library for interpreting a HID descriptor to provide\nan application with byte structures for reading and writing to without the manual labour.\n\n#### Pre-Alpha\n\nAt this stage, this library is still in early development and adoption is not recommended.\n\n#### Progress\n\n  - [x] Parse HID Report descriptor from byte array\n    - [ ] Support for HID spec 1.11 items *(See Issue [#1](https://github.com/NZSmartie/PyHIDParser/issues/1))*\n    - [x] Main items (Collections, Inputs, Outputs and Features)\n    - [x] Global items\n    - [ ] Local items *(missing `delimiter`)*\n    - [ ] ~~Support vender defined long items~~ *(not going to happen any time soon)*\n  - [x] Parse HID Physical Descriptor\n  - [x] Create an application API for handing HID items - *Don't want the application developer to deal with states, nesting or closing collections, etc*\n    - [x] Access reports based on usages\n    - [x] Serialize/Deserialize reports to/from the HID device\n    - [x] Allow creating a HID descriptor from the API for configuring devices with\n\n## Goals\n\n  - Allow creating HID descriptors from byte arrays\n  - Allow creating byte arrays from a HID descriptor\n    - For those wanting an API approach to creating a descriptor\n    - Or for anyone willing to create a new GUI tool\n  - Provide a (de)serializer for reading and writing to devices\n  - Support adding vendor defined usage pages through API\n  - Provide meta data about reports, such as physical descriptor index, usage switches/modifiers\n\n## Examples\n\nMore examples int the [examples/](examples/) folder:\n - [mouse.py](examples/mouse.py) - Creating the example Mouse descriptor from the HID 1.11 spec\n - [dual-shock-3.py](examples/dual-shock-3.py)  - Parse Sony's DualShock3 HID descriptor\n\n*Note: This is a ***working*** example. But it is subject to change*\n```python\nimport hidparser\nfrom hidparser.UsagePages import GenericDesktop, Button\n\n# ...\n\nmouse_desc = array('B', [\n    0x05, 0x01,  # USAGE_PAGE (Generic Desktop)\n    0x09, 0x02,  # USAGE (Mouse)\n    0xa1, 0x01,  # COLLECTION (Application)\n    # ...\n    0xc0         # END_COLLECTION\n    ])\n\n# This returns a Device object from a descriptor\nmouse_from_desc = hidparser.parse(mouse)\n\n# Alternatively, create a mouse device through API instead of parsing bytes\nmouse_from_api = hidparser.Device(\n    hidparser.Collection(\n        usage=GenericDesktop.MOUSE,\n        items=hidparser.Collection(\n            usage=GenericDesktop.POINTER,\n            items=[\n                hidparser.Report(\n                    report_type=hidparser.ReportType.INPUT,\n                    usages=hidparser.UsageRange(\n                        minimum=Button(1),\n                        maximum=Button(3)\n                    ).get_range(),\n                    size=1,\n                    count=3,\n                    logical_range=(0, 1),\n                    flags=hidparser.ReportFlags.VARIABLE\n                ),\n                hidparser.Report(\n                    report_type=hidparser.ReportType.INPUT,\n                    usages=[],\n                    size=5,\n                    count=1,\n                    flags=hidparser.ReportFlags.CONSTANT | hidparser.ReportFlags.VARIABLE\n                ),\n                hidparser.Report(\n                    report_type=hidparser.ReportType.INPUT,\n                    usages=[\n                        GenericDesktop.X,\n                        GenericDesktop.Y\n                    ],\n                    size=8,\n                    count=2,\n                    logical_range=(-127, 127),\n                    flags=hidparser.ReportFlags.VARIABLE | hidparser.ReportFlags.RELATIVE\n                )\n            ]\n        )\n    )\n)\n\n# Read from the physical device\ndata = bytes([0x00, 0x12, 0x34])\n# Deserialize the data and populate the object members\nmouse_from_api.deserialize(data)\n\n# Read the x,y members from mouse after deserializing\npointer = mouse_from_api.reports[0].inputs.mouse.pointer\nprint(\"pointer: {}, {}\".format(pointer.x, pointer.y))\n# Example Output:\n# pointer: 18, 52\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnzsmartie%2Fpyhidparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnzsmartie%2Fpyhidparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnzsmartie%2Fpyhidparser/lists"}