"""Dump + decode the HID report descriptor of the vendor interface (read-only).""" import hid VID, PID, USAGE_PAGE = 0x03F0, 0x08C2, 0xFF90 info = next(d for d in hid.enumerate(VID, PID) if d["usage_page"] == USAGE_PAGE) dev = hid.device() dev.open_path(info["path"]) desc = bytes(dev.get_report_descriptor()) dev.close() print(f"{len(desc)} bytes: {desc.hex(' ')}\n") TAGS = {0x04: "UsagePage", 0x08: "Usage", 0xA0: "Collection", 0xC0: "EndCollection", 0x14: "LogicalMin", 0x24: "LogicalMax", 0x74: "ReportSize", 0x94: "ReportCount", 0x84: "ReportID", 0x80: "Input", 0x90: "Output", 0xB0: "Feature", 0x18: "UsageMin", 0x28: "UsageMax"} i = 0 while i < len(desc): prefix = desc[i] size = {0: 0, 1: 1, 2: 2, 3: 4}[prefix & 3] val = int.from_bytes(desc[i + 1:i + 1 + size], "little") print(f" {TAGS.get(prefix & 0xFC, f'0x{prefix:02X}'):14} 0x{val:X}") i += 1 + size