libusb.h
Go to the documentation of this file.
1 /*
2 * This file is part of the OpenKinect Project. http://www.openkinect.org
3 *
4 * Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file
5 * for details.
6 *
7 * This code is licensed to you under the terms of the Apache License, version
8 * 2.0, or, at your option, the terms of the GNU General Public License,
9 * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
10 * or the following URLs:
11 * http://www.apache.org/licenses/LICENSE-2.0
12 * http://www.gnu.org/licenses/gpl-2.0.txt
13 *
14 * If you redistribute this file in source form, modified or unmodified, you
15 * may:
16 * 1) Leave this header intact and distribute it under the same terms,
17 * accompanying it with the APACHE20 and GPL20 files, or
18 * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
19 * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
20 * In all cases you must keep the copyright notice intact and include a copy
21 * of the CONTRIB file.
22 *
23 * Binary distributions must follow the binary distribution requirements of
24 * either License.
25 */
26 
27 #pragma once
28 
29 // This interface emulator requires the libusb-win32 v1.2.2.1 (snapshot)
30 // or later. Prior win32 versions of the library were not conformal to
31 // the official libusb-0.1 API naming convention
32 // (e.g.: usb_device_t instead of usb_device)
33 // One can either workaround prior releases to match the official naming
34 // or upgrade to the libusb-win32 1.2.2.1 snapshot.
35 
36 #include <unistd.h>
37 
38 #if defined(_MSC_VER)
39  typedef unsigned __int8 uint8_t;
40  typedef unsigned __int16 uint16_t;
41  // We need struct timeval.
42  #include <winsock.h>
43 #else
44  #include <stdint.h>
45  #include <sys/time.h>
46 #endif
47 
48 #define LIBUSBEMU 1
49 
50 // guard to enable mix of compiler semantics (C/C++ calling C++);
51 // this should allow builds under VC++ and gcc/g++ profiles
52 #ifdef __cplusplus
53  extern "C" {
54 #endif
55 
56 // gotta use "_t" suffix here...
57 struct libusb_context_t;
58 // ...otherwise C++ complains with such typedef declaration
60 int libusb_init(libusb_context** context);
62 void libusb_set_debug(libusb_context *ctx, int level);
63 
64 struct libusb_device_t;
67 void libusb_free_device_list(libusb_device** list, int unref_devices);
68 
70 
74 void libusb_close(libusb_device_handle* dev_handle);
75 
76 int libusb_get_string_descriptor(libusb_device_handle *dev_handle, uint8_t desc_index, uint16_t langid, unsigned char *data, int length);
77 int libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle, uint8_t desc_index, unsigned char *data, int length);
78 
79 int libusb_set_configuration(libusb_device_handle *dev, int configuration);
80 int libusb_set_interface_alt_setting(libusb_device_handle *dev,int interface_number,int alternate_setting);
81 int libusb_claim_interface(libusb_device_handle* dev, int interface_number);
82 int libusb_release_interface(libusb_device_handle* dev, int interface_number);
83 
85  uint16_t vendor_id, uint16_t product_id);
86 
87 int libusb_control_transfer(libusb_device_handle* dev_handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char* data, uint16_t wLength, unsigned int timeout);
88 int libusb_bulk_transfer(libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout);
89 
90 
91 struct libusb_transfer* libusb_alloc_transfer(int iso_packets);
92 void libusb_free_transfer(struct libusb_transfer* transfer);
93 
94 typedef void(*libusb_transfer_cb_fn)(struct libusb_transfer *transfer);
95 void libusb_fill_iso_transfer(struct libusb_transfer* transfer, libusb_device_handle* dev_handle, unsigned char endpoint, unsigned char* buffer, int length, int num_iso_packets, libusb_transfer_cb_fn callback, void* user_data, unsigned int timeout);
96 void libusb_set_iso_packet_lengths(struct libusb_transfer* transfer, unsigned int length);
97 
98 int libusb_submit_transfer(struct libusb_transfer* transfer);
99 int libusb_cancel_transfer(struct libusb_transfer* transfer);
100 
101 int libusb_handle_events(libusb_context* ctx); // WORK IN PROGRESS...
103 
104 // the signature of libusb_device_descriptor is identical to usb_device_descriptor
105 // which means that the below struct could be replaced by a typedef; however, that
106 // would require #including <usb.h> in this header, polluting the scope and possibly
107 // creating conflicts with existing <usb.h> declarations...
109 {
124 };
125 
129 };
130 
132 {
140 };
141 
143 {
148 };
149 
154 };
155 
157 {
160  unsigned char endpoint;
161  unsigned char type;
162  unsigned int timeout;
164  int length;
167  void *user_data;
168  unsigned char *buffer;
171 };
172 
174 {
175  unsigned int length;
176  unsigned int actual_length;
178 };
179 
181 {
196 };
197 
198 #ifdef __cplusplus
199  }
200 #endif
int libusb_handle_events_timeout(libusb_context *ctx, struct timeval *timeout)
Definition: libusbemu.cpp:638
uint8_t bNumConfigurations
Definition: libusb.h:123
int libusb_handle_events(libusb_context *ctx)
Definition: libusbemu.cpp:622
void libusb_set_iso_packet_lengths(struct libusb_transfer *transfer, unsigned int length)
Definition: libusbemu.cpp:516
int libusb_get_device_descriptor(libusb_device *dev, struct libusb_device_descriptor *desc)
Definition: libusbemu.cpp:206
int libusb_set_configuration(libusb_device_handle *dev, int configuration)
Definition: libusbemu.cpp:286
long ssize_t
Definition: unistd.h:36
uint8_t flags
Definition: libusb.h:159
unsigned short uint16_t
libusb_transfer_type
Definition: libusb.h:142
int libusb_init(libusb_context **context)
Definition: libusbemu.cpp:88
unsigned char * buffer
Definition: libusb.h:168
int libusb_get_string_descriptor(libusb_device_handle *dev_handle, uint8_t desc_index, uint16_t langid, unsigned char *data, int length)
Definition: libusbemu.cpp:267
libusb_error
Definition: libusb.h:180
void(* libusb_transfer_cb_fn)(struct libusb_transfer *transfer)
Definition: libusb.h:94
unsigned char uint8_t
void libusb_free_device_list(libusb_device **list, int unref_devices)
Definition: libusbemu.cpp:190
unsigned int timeout
Definition: libusb.h:162
libusb_transfer_flags
Definition: libusb.h:150
libusb_transfer_cb_fn callback
Definition: libusb.h:166
libusb_transfer_status
Definition: libusb.h:131
int libusb_open(libusb_device *dev, libusb_device_handle **handle)
Definition: libusbemu.cpp:217
unsigned int actual_length
Definition: libusb.h:176
struct libusb_transfer * libusb_alloc_transfer(int iso_packets)
Definition: libusbemu.cpp:439
void libusb_close(libusb_device_handle *dev_handle)
Definition: libusbemu.cpp:249
int libusb_release_interface(libusb_device_handle *dev, int interface_number)
Definition: libusbemu.cpp:347
int libusb_control_transfer(libusb_device_handle *dev_handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, unsigned int timeout)
Definition: libusbemu.cpp:394
void libusb_set_debug(libusb_context *ctx, int level)
Definition: libusbemu.cpp:142
void * user_data
Definition: libusb.h:167
void libusb_free_transfer(struct libusb_transfer *transfer)
Definition: libusbemu.cpp:451
struct libusb_iso_packet_descriptor * iso_packet_desc
Definition: libusb.h:170
void(* callback)(void)
libusb_device_handle * dev_handle
Definition: libusb.h:158
ssize_t libusb_get_device_list(libusb_context *ctx, libusb_device ***list)
Definition: libusbemu.cpp:151
void libusb_fill_iso_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, int num_iso_packets, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
Definition: libusbemu.cpp:489
libusb_device_handle * libusb_open_device_with_vid_pid(libusb_context *ctx, uint16_t vendor_id, uint16_t product_id)
Definition: libusbemu.cpp:362
typedef void(ONI_CALLBACK_TYPE *DeviceConnectedCallback)(const OniDeviceInfo *
int num_iso_packets
Definition: libusb.h:169
int libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle, uint8_t desc_index, unsigned char *data, int length)
Definition: libusbemu.cpp:276
static freenect_context * ctx
int libusb_submit_transfer(struct libusb_transfer *transfer)
Definition: libusbemu.cpp:529
int actual_length
Definition: libusb.h:165
int libusb_claim_interface(libusb_device_handle *dev, int interface_number)
Definition: libusbemu.cpp:316
int libusb_cancel_transfer(struct libusb_transfer *transfer)
Definition: libusbemu.cpp:578
libusb_endpoint_direction
Definition: libusb.h:126
int libusb_bulk_transfer(libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout)
Definition: libusbemu.cpp:412
unsigned char endpoint
Definition: libusb.h:160
int libusb_set_interface_alt_setting(libusb_device_handle *dev, int interface_number, int alternate_setting)
Definition: libusbemu.cpp:305
void libusb_exit(libusb_context *ctx)
Definition: libusbemu.cpp:110
unsigned char type
Definition: libusb.h:161


libfreenect
Author(s): Hector Martin, Josh Blake, Kyle Machulis, OpenKinect community
autogenerated on Thu Jun 6 2019 19:25:38