Instrument Neutral Distributed Interface INDI  1.9.5
hidapi.h
Go to the documentation of this file.
1 /*
2  HIDAPI - Multi-Platform library for communication with HID devices.
3 
4  Copyright (c) 2009 by Alan Ott, Signal 11 Software (8/22/2009)
5  All Rights Reserved.
6 
7  Changes for use with SX Filter Wheel INDI Driver by CloudMakers - 11/6/2012
8 
9  This program is free software; you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by the Free
11  Software Foundation; either version 2 of the License, or (at your option)
12  any later version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17  more details.
18 
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59
21  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  The full GNU General Public License is included in this distribution in the
24  file called LICENSE.
25 
26  These files may also be found in the public source code repository located:
27  http://github.com/signal11/hidapi
28 */
29 
34 #pragma once
35 
36 #include <wchar.h>
37 
38 #ifdef _WIN32
39 #define HID_API_EXPORT __declspec(dllexport)
40 #define HID_API_CALL
41 #else
42 #define HID_API_EXPORT
43 #define HID_API_CALL
44 #endif
45 
46 #define HID_API_EXPORT_CALL HID_API_EXPORT HID_API_CALL
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 struct hid_device_;
52 typedef struct hid_device_ hid_device;
56 {
58  char *path;
60  unsigned short vendor_id;
62  unsigned short product_id;
64  wchar_t *serial_number;
67  unsigned short release_number;
71  wchar_t *product_string;
74  unsigned short usage_page;
77  unsigned short usage;
83 
86 };
87 
103 
116 
136 struct hid_device_info HID_API_EXPORT *HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id);
137 
147 
164 HID_API_EXPORT hid_device *HID_API_CALL hid_open(unsigned short vendor_id, unsigned short product_id,
165  const wchar_t *serial_number);
166 
181 
208 int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length);
209 
228 int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds);
229 
247 int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length);
248 
268 
295 int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length);
296 
316 int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length);
317 
324 
335 int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen);
336 
347 int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen);
348 
359 int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen);
360 
372 int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen);
373 
384 
385 #ifdef __cplusplus
386 }
387 #endif
hid_error
const HID_API_EXPORT wchar_t *HID_API_CALL hid_error(hid_device *device)
Get a string describing the last error which occurred.
Definition: hid_libusb.c:1227
hid_device_info::interface_number
int interface_number
Definition: hidapi.h:82
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_libusb.c:929
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_libusb.c:1107
hid_close
void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device)
Close a HID device.
Definition: hid_libusb.c:1163
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_libusb.c:1095
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_libusb.c:597
HID_API_EXPORT_CALL
#define HID_API_EXPORT_CALL
Definition: hidapi.h:46
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_libusb.c:1211
hid_device_info::manufacturer_string
wchar_t * manufacturer_string
Definition: hidapi.h:69
hid_device_info::next
struct hid_device_info * next
Definition: hidapi.h:85
hid_device_info
Definition: hidapi.h:55
hid_device_
Definition: hid_libusb.c:93
device
hid_device * device
Definition: activefocuser_utils.cpp:92
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_libusb.c:418
hid_device_info::product_id
unsigned short product_id
Definition: hidapi.h:62
hid_device_info::serial_number
wchar_t * serial_number
Definition: hidapi.h:64
hid_device_info::release_number
unsigned short release_number
Definition: hidapi.h:67
hid_device_info::usage
unsigned short usage
Definition: hidapi.h:77
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_libusb.c:1206
HID_API_CALL
#define HID_API_CALL
Definition: hidapi.h:43
hid_device_info::usage_page
unsigned short usage_page
Definition: hidapi.h:74
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_libusb.c:1135
hid_init
int HID_API_EXPORT HID_API_CALL hid_init()
Initialize the HIDAPI library.
Definition: hid_libusb.c:388
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_libusb.c:1100
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_libusb.c:1201
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_libusb.c:612
hid_exit
int HID_API_EXPORT HID_API_CALL hid_exit()
Finalize the HIDAPI library.
Definition: hid_libusb.c:407
hid_device_info::path
char * path
Definition: hidapi.h:58
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_libusb.c:1196
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_libusb.c:997
hid_device_info::vendor_id
unsigned short vendor_id
Definition: hidapi.h:60
hid_device_info::product_string
wchar_t * product_string
Definition: hidapi.h:71
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_libusb.c:790
HID_API_EXPORT
#define HID_API_EXPORT
Definition: hidapi.h:42