hidapi.h
/*******************************************************
HIDAPI - Multi-Platform library for
communication with HID devices.
Alan Ott
Signal 11 Software
8/22/2009
Copyright 2009, All Rights Reserved.
At the discretion of the user of this library,
this software may be licensed under the terms of the
GNU General Public License v3, a BSD-Style license, or the
original HIDAPI license as outlined in the LICENSE.txt,
LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt
files located at the root of the source distribution.
These files may also be found in the public source
code repository located at:
http://github.com/signal11/hidapi .
********************************************************/
#ifndef HIDAPI_H__
#define HIDAPI_H__
#include <wchar.h>
#ifdef _WIN32
#define HID_API_EXPORT __declspec(dllexport)
#define HID_API_CALL
#else
#define HID_API_EXPORT
#define HID_API_CALL
#endif
#define HID_API_EXPORT_CALL HID_API_EXPORT HID_API_CALL
#ifdef __cplusplus
extern "C" {
#endif
struct hid_device_;
typedef struct hid_device_ hid_device;
struct hid_device_info
{
char *path;
unsigned short vendor_id;
unsigned short product_id;
wchar_t *serial_number;
unsigned short release_number;
wchar_t *manufacturer_string;
wchar_t *product_string;
unsigned short usage_page;
unsigned short usage;
int interface_number;
struct hid_device_info *next;
};
int HID_API_EXPORT HID_API_CALL hid_init(void);
int HID_API_EXPORT HID_API_CALL hid_exit(void);
struct hid_device_info HID_API_EXPORT *HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id);
void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *devs);
HID_API_EXPORT hid_device *HID_API_CALL hid_open(unsigned short vendor_id,
unsigned short product_id,
const wchar_t *serial_number);
HID_API_EXPORT hid_device *HID_API_CALL hid_open_path(const char *path);
#ifdef LINUX
int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length);
#else
int HID_API_EXPORT HID_API_CALL hid_write_timeout(hid_device *device,
const unsigned char *data,
size_t length,
int milliseconds);
#endif
int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds);
int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length);
int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *device, int nonblock);
int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length);
int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length);
void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device);
int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen);
int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen);
int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen);
int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen);
HID_API_EXPORT const wchar_t *HID_API_CALL hid_error(hid_device *device);
#ifdef __cplusplus
}
#endif
#endif
hid_error
HID_API_EXPORT const wchar_t *HID_API_CALL hid_error(hid_device *device)
Get a string describing the last error which occurred.
Definition: hid-linux.c:808
hid_device_info::interface_number
int interface_number
Definition: hidapi.h:76
hid_device_info
Definition: hidapi.h:49
hid_free_enumeration
void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *devs)
Free an enumeration Linked List.
Definition: hid-linux.c:583
hid_device_info::manufacturer_string
wchar_t * manufacturer_string
Definition: hidapi.h:63
hid_device_info::path
char * path
Definition: hidapi.h:52
hid_write
int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length)
Write an Output report to a HID device.
Definition: hid-linux.c:686
hid_get_indexed_string
int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen)
Get a string from a HID device, based on its string index.
Definition: hid-linux.c:803
hid_device_info::next
struct hid_device_info * next
Definition: hidapi.h:79
hid_set_nonblocking
int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *device, int nonblock)
Set the device handle to be non-blocking.
Definition: hid-linux.c:748
hid_close
void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device)
Close a HID device.
Definition: hid-linux.c:780
hid_get_product_string
int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen)
Get The Product String from a HID device.
Definition: hid-linux.c:793
hid_device_
Definition: hid-linux.c:72
hid_device_info::product_id
unsigned short product_id
Definition: hidapi.h:56
hid_device_info::serial_number
wchar_t * serial_number
Definition: hidapi.h:58
hid_exit
int HID_API_EXPORT HID_API_CALL hid_exit(void)
Finalize the HIDAPI library.
Definition: hid-linux.c:390
hid_read_timeout
int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds)
Read an Input report from a HID device with timeout.
Definition: hid-linux.c:695
hid_device_info::vendor_id
unsigned short vendor_id
Definition: hidapi.h:54
hid_open
HID_API_EXPORT hid_device *HID_API_CALL hid_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...
Definition: hid-linux.c:598
hid_get_feature_report
int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length)
Get a feature report from a HID device.
Definition: hid-linux.c:769
hid_device_info::product_string
wchar_t * product_string
Definition: hidapi.h:65
hid_device_info::usage
unsigned short usage
Definition: hidapi.h:71
hid_get_serial_number_string
int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen)
Get The Serial Number String from a HID device.
Definition: hid-linux.c:798
hid_init
int HID_API_EXPORT HID_API_CALL hid_init(void)
Initialize the HIDAPI library.
Definition: hid-linux.c:376
hid_device_info::usage_page
unsigned short usage_page
Definition: hidapi.h:68
hid_send_feature_report
int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length)
Send a Feature report to the device.
Definition: hid-linux.c:758
hid_get_manufacturer_string
int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen)
Get The Manufacturer String from a HID device.
Definition: hid-linux.c:788
hid_open_path
HID_API_EXPORT hid_device *HID_API_CALL hid_open_path(const char *path)
Open a HID device by its path name.
Definition: hid-linux.c:638
hid_enumerate
struct hid_device_info HID_API_EXPORT *HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id)
Enumerate the HID Devices.
Definition: hid-linux.c:396
hid_device_info::release_number
unsigned short release_number
Definition: hidapi.h:61
hid_read
int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length)
Read an Input report from a HID device.
Definition: hid-linux.c:743