|
NAMEusbhid , hid_get_report_desc ,
hid_get_report_id ,
hid_use_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 ,
hid_get_report , hid_set_report
—
USB HID access routines
LIBRARYUSB Human Interface Devices Library (libusbhid, -lusbhid)SYNOPSIS#include <usbhid.h>
report_desc_t
int
int
report_desc_t
void
hid_data_t
void
int
int
int
const char *
const char *
int
int
void
int
void
int
int
DESCRIPTIONTheusbhid library provides routines to extract data
from USB Human Interface Devices.
IntroductionUSB HID devices send and receive data layed out in a device dependent way. Theusbhid 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 descriptor, parsing of the descriptor, translating to/from symbolic names, and data manipulation. Synchronous HID operationSynchronous HID operation can be enabled or disabled by a call tohid_set_immed (). If the second argument is zero
synchronous HID operation is disabled. Else synchronous HID operation is
enabled. The function returns a negative value on failure.
Descriptor FunctionsThe report descriptor ID can be obtained by callinghid_get_report_id (). A report descriptor can be
obtained by calling hid_get_report_desc () with a file
descriptor obtained by opening a
uhid(4)
device. Alternatively a data buffer containing the report descriptor can be
passed into hid_use_report_desc (). The data is copied
into an internal structure. 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. If
hid_dispose_report_desc () fails it will return
NULL .
Descriptor Parsing FunctionsTo parse the report descriptor thehid_start_parse ()
function should be called with a report descriptor, a set that describes which
items that are interesting, and the desired report ID (or -1 to obtain items
of all report IDs). The set is obtained by OR-ing together values
(1 << k) where k is an item
of type hid_kind_t. The function returns
NULL if the initialization fails, otherwise an opaque
value to be used in subsequent calls. After parsing the
hid_end_parse () function should be called to free
internal data structures.
To iterate through all the items in the report descriptor
Data should be read/written to the device in the size of the
report. The size of a report (of a certain kind) can be computed by the
To locate a single item the Name Translation FunctionsThe functionhid_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.
The functions Before any of these functions can be called the usage table must
be parsed, this is done by calling Data Extraction FunctionsGiven the data obtained from a HID device and an item in the report descriptor thehid_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).
FILES
EXAMPLESNot yet.SEE ALSOThe USB specifications can be found at http://www.usb.org/developers/docs/.HISTORYTheusbhid library first appeared in
NetBSD 1.5.
BUGSThis man page is woefully incomplete.
Visit the GSP FreeBSD Man Page Interface. |