摘要 |
A computer system in accordance with the invention includes a USB transport layer and an HID class driver implemented on top of the transport layer. A client program calls the class driver (either directly or indirectly) to obtain HID reports and report descriptors. Before returning the reports to calling programs, however, the HID class driver normalizes the reports by making them a uniform length and by adding report IDs to any reports that do not already have report IDs. A provided parser includes a descriptor parsing function and an item retrieval function. After obtaining a report descriptor, a client calls the descriptor parsing function with the report descriptor as an argument. The descriptor parsing function returns a data structure containing a parsed report description. The client stores the parsed report description and submits it, along with HID reports, to the item retrieval function. A particular usage specification is also provided as an argument to the item retrieval function. The item retrieval function searches the designated HID report, based on the parsed report description, and returns one or more data items from the report whose usage specifications match the usage specification submitted as an argument to the item retrieval function. |