TwiceAsNice  2019-02-18
Classes | Macros | Functions | Variables
hid_libusb.c File Reference
#include "hidapi.h"
#include "locale_compat.h"
#include <libusb.h>
#include "iconv.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include <pthread.h>
Include dependency graph for hid_libusb.c:

Classes

struct  input_report
 
struct  hid_device_
 
struct  lang_map_entry
 

Macros

#define _GNU_SOURCE
 
#define DEBUG_PRINTF
 
#define LOG(...)   fprintf(stderr, __VA_ARGS__)
 
#define DETACH_KERNEL_DRIVER
 
#define LANG(name, code, usb_code)
 

Functions

uint16_t get_usb_code_for_current_locale (void)
 
static int return_data (hid_device *dev, unsigned char *data, size_t length)
 
static hid_devicenew_hid_device (void)
 
static void free_hid_device (hid_device *dev)
 
static uint16_t get_first_language (libusb_device_handle *dev)
 
static int is_language_supported (libusb_device_handle *dev, uint16_t lang)
 
static wchar_t * get_usb_string (libusb_device_handle *dev, uint8_t idx)
 
static char * make_path (libusb_device *dev, int interface_number)
 
int HID_API_EXPORT hid_init (void)
 Initialize the HIDAPI library. More...
 
int HID_API_EXPORT hid_exit (void)
 Finalize the HIDAPI library. More...
 
struct hid_device_info HID_API_EXPORThid_enumerate (unsigned short vendor_id, unsigned short product_id)
 Enumerate the HID Devices. More...
 
void HID_API_EXPORT hid_free_enumeration (struct hid_device_info *devs)
 Free an enumeration Linked List. More...
 
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. More...
 
static void read_callback (struct libusb_transfer *transfer)
 
static void * read_thread (void *param)
 
hid_device *HID_API_EXPORT hid_open_path (const char *path)
 Open a HID device by its path name. More...
 
int HID_API_EXPORT hid_write (hid_device *dev, const unsigned char *data, size_t length)
 Write an Output report to a HID device. More...
 
static void cleanup_mutex (void *param)
 
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. More...
 
int HID_API_EXPORT hid_read (hid_device *dev, unsigned char *data, size_t length)
 Read an Input report from a HID device. More...
 
int HID_API_EXPORT hid_set_nonblocking (hid_device *dev, int nonblock)
 Set the device handle to be non-blocking. More...
 
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. More...
 
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. More...
 
void HID_API_EXPORT hid_close (hid_device *dev)
 Close a HID device. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
HID_API_EXPORT const wchar_t *HID_API_CALL hid_error (hid_device *dev)
 Get a string describing the last error which occurred. More...
 

Variables

static libusb_context * usb_context = NULL
 
static struct lang_map_entry lang_map []
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

◆ DEBUG_PRINTF

#define DEBUG_PRINTF

◆ DETACH_KERNEL_DRIVER

#define DETACH_KERNEL_DRIVER

◆ LANG

#define LANG (   name,
  code,
  usb_code 
)
Value:
{ \
name, code, usb_code \
}
Definition: psf.h:47

◆ LOG

#define LOG (   ...)    fprintf(stderr, __VA_ARGS__)

Function Documentation

◆ cleanup_mutex()

static void cleanup_mutex ( void *  param)
static

◆ free_hid_device()

static void free_hid_device ( hid_device dev)
static

◆ get_first_language()

static uint16_t get_first_language ( libusb_device_handle dev)
static

◆ get_usb_code_for_current_locale()

uint16_t get_usb_code_for_current_locale ( void  )

◆ get_usb_string()

static wchar_t* get_usb_string ( libusb_device_handle dev,
uint8_t  idx 
)
static

◆ is_language_supported()

static int is_language_supported ( libusb_device_handle dev,
uint16_t  lang 
)
static

◆ make_path()

static char* make_path ( libusb_device *  dev,
int  interface_number 
)
static

◆ new_hid_device()

static hid_device* new_hid_device ( void  )
static

◆ read_callback()

static void read_callback ( struct libusb_transfer *  transfer)
static

◆ read_thread()

static void* read_thread ( void *  param)
static

◆ return_data()

static int return_data ( hid_device dev,
unsigned char *  data,
size_t  length 
)
static

Variable Documentation

◆ lang_map

struct lang_map_entry lang_map[]
static

◆ usb_context

libusb_context* usb_context = NULL
static