Seth Woolley's Man Viewer

usb(3) - hid_dispose_report_desc, hid_end_parse, hid_get_data, hid_get_item, hid_get_report_desc, hid_init, hid_locate, hid_report_size, hid_set_data, hid_start_parse, hid_usage_in_page, hid_usage_page, usb - USB HID access routines - man 3 usb

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

USB(3)                   BSD Library Functions Manual                   USB(3)

NAME
     usb, hid_get_report_desc, hid_dispose_report_desc, hid_start_parse,
     hid_end_parse, hid_get_item, hid_report_size, hid_locate, hid_usage_page,
     hid_usage_in_page, hid_init, hid_get_data, hid_set_data -- USB HID access(2,5)
     routines

LIBRARY
     library ``libusb''

SYNOPSIS
     #include <usb.h>

     report_desc_t
     hid_get_report_desc(int file(1,n));

     void
     hid_dispose_report_desc(report_desc_t d);

     hid_data_t
     hid_start_parse(report_desc_t d, int kindset);

     void
     hid_end_parse(hid_data_t s);

     int
     hid_get_item(hid_data_t s, hid_item_t *h);

     int
     hid_report_size(report_desc_t d, hid_kind_t k, int *idp);

     int
     hid_locate(report_desc_t d, u_int usage, hid_kind_t k, hid_item_t *h);

     char *
     hid_usage_page(int i);

     char *
     hid_usage_in_page(u_int u);

     void
     hid_init(char *file(1,n));

     int
     hid_get_data(void *data, hid_item_t *h);

     void
     hid_set_data(void *data, hid_item_t *h, u_int data);

DESCRIPTION
     The usb library provides routines to extract data from USB Human Inter-
     face Devices.

   INTRODUCTION
     USB HID devices send(2,n) and receive data layed out a device dependent way.
     The usb library contains routines to extract the report descriptor which
     contains the data layout information and then use this information.

     The routines can be divided into four parts: extraction of the descrip-
     tor, parsing of the descriptor, translating to/from symbolic names, and
     data manipulation.

   DESCRIPTOR FUNCTIONS
     A report descriptor can be obtained by calling hid_get_report_desc() with
     a file(1,n) descriptor obtained by opening a uhid(4) device.  When the report
     descriptor is no longer needed it should be freed by calling
     hid_dispose_report_desc().  The type report_desc_t is opaque and should
     be used when calling the parsing functions.

   DESCRIPTOR PARSING FUNCTIONS
     To parse the report descriptor the hid_start_parse() function should be
     called with a report descriptor and a set(7,n,1 builtins) that describes which items that
     are interesting.  The set(7,n,1 builtins) is obtained by oring together values (1 << k)
     where k is an item of type hid_kind_t.  The function returns NULL if(3,n) the
     initialization fails, otherwise an opaque value to be used in(1,8) subsequent
     calls.  After parsing the hid_end_parse() function should be called to
     free internal data structures.

     To iterate through all the items in(1,8) the report descriptor hid_get_item()
     should be called while it returns a value greater than 0.  When the
     report descriptor ends it will returns 0; a syntax error(8,n) within the
     report descriptor will cause a return value less(1,3) than 0.  The struct
     pointed to by h will be filled with the relevant data for the item.  The
     definition of hid_item_t can be found in(1,8) <usb.h> and the meaning of the
     components in(1,8) the USB HID documentation.

     Data should be read(2,n,1 builtins)/written to the device in(1,8) the size of the report.  The
     size of a report (of a certain kind) can be computed by the
     hid_report_size() function.  If the report is prefixed by an ID byte it
     is stored at idp, otherwise it will contain 0.

     To locate a single item the hid_locate() function can be used.  It should
     be given the usage code of the item and its kind and it will fill the
     item and return non-zero if(3,n) the item was found.

   NAME TRANSLATION FUNCTIONS
     The function hid_usage_page() will return the symbolic name of a usage
     page, and the function hid_usage_in_page() will return the symbolic name
     of the usage within the page.  Both these functions may return a pointer
     to static data.  Before either of these functions can be called the usage
     table must be parsed, this is done by calling hid_init() with the name of
     the table.  Passing NULL to this function will cause it to use the
     default table.

   DATA EXTRACTION FUNCTIONS
     Given the data obtained from a HID device and an item in(1,8) the report
     descriptor the hid_get_data() function extracts the value of the item.
     Conversely hid_set_data() can be used to put data into a report (which
     must be zeroed first).

EXAMPLE
     Not yet.

FILES
     /usr/share/misc/usb_hid_usages The default HID usage table.

BUGS
     This man(1,5,7) page is woefully incomplete.

SEE ALSO
     The USB specifications can be found at
     http://www.usb.org/developers/docs.htm.

     hid(4), usb(4).

HISTORY
     The usb library first appeared in(1,8) NetBSD 1.5.

BSD                              May 11, 1999                              BSD

References for this manual (incoming links)