aboutsummaryrefslogtreecommitdiff
path: root/lib/vusb/libs-host/hiddata.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vusb/libs-host/hiddata.h')
-rw-r--r--lib/vusb/libs-host/hiddata.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/vusb/libs-host/hiddata.h b/lib/vusb/libs-host/hiddata.h
new file mode 100644
index 000000000..245453d43
--- /dev/null
+++ b/lib/vusb/libs-host/hiddata.h
@@ -0,0 +1,70 @@
1/* Name: hiddata.h
2 * Author: Christian Starkjohann
3 * Creation Date: 2008-04-11
4 * Tabsize: 4
5 * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
6 * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
7 */
8
9#ifndef __HIDDATA_H_INCLUDED__
10#define __HIDDATA_H_INCLUDED__
11
12/*
13General Description:
14This module implements an abstraction layer for data transfer over HID feature
15requests. The implementation uses native Windows functions on Windows so that
16no driver installation is required and libusb on Unix. You must link the
17appropriate libraries in either case: "-lhid -lusb -lsetupapi" on Windows and
18`libusb-config --libs` on Unix.
19*/
20
21/* ------------------------------------------------------------------------ */
22
23#define USBOPEN_SUCCESS 0 /* no error */
24#define USBOPEN_ERR_ACCESS 1 /* not enough permissions to open device */
25#define USBOPEN_ERR_IO 2 /* I/O error */
26#define USBOPEN_ERR_NOTFOUND 3 /* device not found */
27
28/* ------------------------------------------------------------------------ */
29
30typedef struct usbDevice usbDevice_t;
31/* Opaque data type representing the USB device. This can be a Windows handle
32 * or a libusb handle, depending on the backend implementation.
33 */
34
35/* ------------------------------------------------------------------------ */
36
37int usbhidOpenDevice(usbDevice_t **device, int vendorID, char *vendorName, int productID, char *productName, int usesReportIDs);
38/* This function opens a USB device. 'vendorID' and 'productID' are the numeric
39 * Vendor-ID and Product-ID of the device we want to open. If 'vendorName' and
40 * 'productName' are both not NULL, only devices with matching manufacturer-
41 * and product name strings are accepted. If the device uses report IDs,
42 * 'usesReportIDs' must be set to a non-zero value.
43 * Returns: If a matching device has been found, USBOPEN_SUCCESS is returned
44 * and '*device' is set to an opaque pointer representing the device. The
45 * device must be closed with usbhidCloseDevice(). If the device has not been
46 * found or opening failed, an error code is returned.
47 */
48void usbhidCloseDevice(usbDevice_t *device);
49/* Every device opened with usbhidOpenDevice() must be closed with this function.
50 */
51int usbhidSetReport(usbDevice_t *device, char *buffer, int len);
52/* This function sends a feature report to the device. The report ID must be
53 * in the first byte of buffer and the length 'len' of the report is specified
54 * including this report ID. If no report IDs are used, buffer[0] must be set
55 * to 0 (dummy report ID).
56 * Returns: 0 on success, an error code otherwise.
57 */
58int usbhidGetReport(usbDevice_t *device, int reportID, char *buffer, int *len);
59/* This function obtains a feature report from the device. The requested
60 * report-ID is passed in 'reportID'. The caller must pass a buffer of the size
61 * of the expected report in 'buffer' and initialize the variable pointed to by
62 * 'len' to the total size of this buffer. Upon successful return, the report
63 * (prefixed with the report-ID) is in 'buffer' and the actual length of the
64 * report is returned in '*len'.
65 * Returns: 0 on success, an error code otherwise.
66 */
67
68/* ------------------------------------------------------------------------ */
69
70#endif /* __HIDDATA_H_INCLUDED__ */