#include <libsimpleio/libhidraw.h> void HIDRAW_open1(const char *name, int32_t *fd, int32_t *error); void HIDRAW_open2(int32_t VID, int32_t PID, int32_t *fd, int32_t *error); void HIDRAW_open3(int32_t VID, int32_t PID, const char *serial, int32_t *fd, int32_t *error); void HIDRAW_close(int32_t fd, int32_t *error); void HIDRAW_get_name(int32_t fd, char *name, int32_t namesize, int32_t *error); void HIDRAW_get_info(int32_t fd, int32_t *bustype, int32_t *vendor, int32_t *product, int32_t *error); void HIDRAW_send(int32_t fd, void *buf, int32_t bufsize, int32_t *count, int32_t *error); void HIDRAW_receive(int32_t fd, void *buf, int32_t bufsize, int32_t *count, int32_t *error);Link with -lsimpleio.
HIDRAW_open1() opens a raw HID device by name. The device node name (/dev/hidrawN) must be passed in name. Upon success, a file descriptor for the raw HID device is returned in *fd.
HIDRAW_open2() opens the first raw HID device that matches the vendor ID and product ID passed in VID and PID. Upon success, a file descriptor for the raw hid device is returned in *fd.
HIDRAW_open3() opens the raw HID device that matches the vendor ID, product ID, and serial number passed in VID, PID, and serial. Upon success, a file descriptor for the raw hid device is returned in *fd.
HIDRAW_close() closes a previously opened raw HID device. The HID device file descriptor must be passed in fd.
HIDRAW_get_name() fetches an information string from the raw HID device. The HID device file descriptor must be passed in fd. The destination buffer address must be passed in *name and the destination buffer size must be passed in namesize. The minimum size for the destination buffer is 16 bytes.
HIDRAW_get_info() fetches the bus type, vendor ID and product ID from the raw HID device. The HID device file descriptor must be passed in fd. The bus type is returned in *bustype, and may be BUS_USB, BUS_HIL, BUS_BLUETOOTH or BUS_VIRTUAL. These values are defined in /usr/include/linux/input.h. The vendor and product ID's are returned in *vendor and *product respectively.
HIDRAW_send() sends a message (also known as a HID report) to the raw HID device. The HID device file descriptor must be passed in fd. The address of the message buffer must be passed in buf and the size of the message buffer must be passed in bufsize. The message size will typically be either 64 or 65 bytes, depending on whether the particular raw HID device uses the first byte for the report number. Upon success, the number of bytes actually sent will be returned in *count.
HIDRAW_receive() receives a message (i.e. a HID report) from the raw HID device. The HID device file descriptor must be passed in fd. The address of the message buffer must be passed in buf and the size of the message buffer must be passed in bufsize. The message size will typically be either 64 or 65 bytes, depending on whether the particular raw HID device uses the first byte for the report number. Upon success, the number of bytes actually received will be returned in *count.