MCP2210 Library
An Open Source MCP2210 Library for Linux.
hid.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <fcntl.h>
#include <poll.h>
#include <linux/hidraw.h>
#include <linux/version.h>
#include <linux/input.h>
#include <libudev.h>
#include "hidapi.h"

Classes

struct  hid_device_

Defines

#define HIDIOCSFEATURE(len)   _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len)
#define HIDIOCGFEATURE(len)   _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len)

Enumerations

enum  device_string_id { DEVICE_STRING_MANUFACTURER, DEVICE_STRING_PRODUCT, DEVICE_STRING_SERIAL, DEVICE_STRING_COUNT }

Functions

hid_devicenew_hid_device ()
static void register_error (hid_device *device, const char *op)
static wchar_t * utf8_to_wchar_t (const char *utf8)
static wchar_t * copy_udev_string (struct udev_device *dev, const char *udev_name)
static int uses_numbered_reports (__u8 *report_descriptor, __u32 size)
int parse_uevent_info (const char *uevent, int *bus_type, unsigned short *vendor_id, unsigned short *product_id, char **serial_number_utf8, char **product_name_utf8)
static int get_device_string (hid_device *dev, enum device_string_id key, wchar_t *string, size_t maxlen)
int HID_API_EXPORT hid_init (void)
 Initialize the HIDAPI library.
int HID_API_EXPORT hid_exit (void)
 Finalize the HIDAPI library.
struct hid_device_info
HID_API_EXPORT
hid_enumerate (unsigned short vendor_id, unsigned short product_id)
 Enumerate the HID Devices.
void HID_API_EXPORT hid_free_enumeration (struct hid_device_info *devs)
 Free an enumeration Linked List.
hid_devicehid_open (unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)
 Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number.
hid_device *HID_API_EXPORT hid_open_path (const char *path)
 Open a HID device by its path name.
int HID_API_EXPORT hid_write (hid_device *dev, const unsigned char *data, size_t length)
 Write an Output report to a HID device.
int HID_API_EXPORT hid_read_timeout (hid_device *dev, unsigned char *data, size_t length, int milliseconds)
 Read an Input report from a HID device with timeout.
int HID_API_EXPORT hid_read (hid_device *dev, unsigned char *data, size_t length)
 Read an Input report from a HID device.
int HID_API_EXPORT hid_set_nonblocking (hid_device *dev, int nonblock)
 Set the device handle to be non-blocking.
int HID_API_EXPORT hid_send_feature_report (hid_device *dev, const unsigned char *data, size_t length)
 Send a Feature report to the device.
int HID_API_EXPORT hid_get_feature_report (hid_device *dev, unsigned char *data, size_t length)
 Get a feature report from a HID device.
void HID_API_EXPORT hid_close (hid_device *dev)
 Close a HID device.
int HID_API_EXPORT_CALL hid_get_manufacturer_string (hid_device *dev, wchar_t *string, size_t maxlen)
 Get The Manufacturer String from a HID device.
int HID_API_EXPORT_CALL hid_get_product_string (hid_device *dev, wchar_t *string, size_t maxlen)
 Get The Product String from a HID device.
int HID_API_EXPORT_CALL hid_get_serial_number_string (hid_device *dev, wchar_t *string, size_t maxlen)
 Get The Serial Number String from a HID device.
int HID_API_EXPORT_CALL hid_get_indexed_string (hid_device *dev, int string_index, wchar_t *string, size_t maxlen)
 Get a string from a HID device, based on its string index.
HID_API_EXPORT const wchar_t
*HID_API_CALL 
hid_error (hid_device *dev)
 Get a string describing the last error which occurred.

Variables

const char * device_string_names []
static __u32 kernel_version = 0

Define Documentation

#define HIDIOCGFEATURE (   len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len)
#define HIDIOCSFEATURE (   len)    _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len)

Enumeration Type Documentation

Enumerator:
DEVICE_STRING_MANUFACTURER 
DEVICE_STRING_PRODUCT 
DEVICE_STRING_SERIAL 
DEVICE_STRING_COUNT 

Function Documentation

static wchar_t* copy_udev_string ( struct udev_device *  dev,
const char *  udev_name 
) [static]
static int get_device_string ( hid_device dev,
enum device_string_id  key,
wchar_t *  string,
size_t  maxlen 
) [static]
int parse_uevent_info ( const char *  uevent,
int *  bus_type,
unsigned short *  vendor_id,
unsigned short *  product_id,
char **  serial_number_utf8,
char **  product_name_utf8 
)

type vendor product HID_ID=0003:000005AC:00008242

static void register_error ( hid_device device,
const char *  op 
) [static]
static int uses_numbered_reports ( __u8 *  report_descriptor,
__u32  size 
) [static]
static wchar_t* utf8_to_wchar_t ( const char *  utf8) [static]

Variable Documentation

const char* device_string_names[]
Initial value:
 {
     "manufacturer",
     "product",
     "serial",
}
__u32 kernel_version = 0 [static]
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines