00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __LIBUSB_H__
00022 #define __LIBUSB_H__
00023
00024 #ifdef _MSC_VER
00025
00026 #define inline __inline
00027
00028 #ifndef _SSIZE_T_DEFINED
00029 #define _SSIZE_T_DEFINED
00030 #undef ssize_t
00031 #ifdef _WIN64
00032 typedef __int64 ssize_t;
00033 #else
00034 typedef int ssize_t;
00035 #endif
00036 #endif
00037 #endif
00038
00039
00040 #if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H))
00041 typedef unsigned __int8 uint8_t;
00042 typedef unsigned __int16 uint16_t;
00043 #else
00044 #include <stdint.h>
00045 #endif
00046
00047 #include <sys/types.h>
00048 #include <time.h>
00049 #include <limits.h>
00050
00051 #if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__)
00052 #include <sys/time.h>
00053 #endif
00054
00055
00056
00057
00058
00059
00060 #if defined(_WIN32) || defined(__CYGWIN__)
00061 #include <windows.h>
00062 #if defined(interface)
00063 #undef interface
00064 #endif
00065 #endif
00066
00092
00093
00094
00095
00096
00097
00098
00099 #if defined(_WIN32) || defined(__CYGWIN__)
00100 #define LIBUSB_CALL WINAPI
00101 #else
00102 #define LIBUSB_CALL
00103 #endif
00104
00105 #ifdef __cplusplus
00106 extern "C" {
00107 #endif
00108
00117 static inline uint16_t libusb_cpu_to_le16(const uint16_t x)
00118 {
00119 union {
00120 uint8_t b8[2];
00121 uint16_t b16;
00122 } _tmp;
00123 _tmp.b8[1] = x >> 8;
00124 _tmp.b8[0] = x & 0xff;
00125 return _tmp.b16;
00126 }
00127
00136 #define libusb_le16_to_cpu libusb_cpu_to_le16
00137
00138
00139
00142 enum libusb_class_code {
00147 LIBUSB_CLASS_PER_INTERFACE = 0,
00148
00150 LIBUSB_CLASS_AUDIO = 1,
00151
00153 LIBUSB_CLASS_COMM = 2,
00154
00156 LIBUSB_CLASS_HID = 3,
00157
00159 LIBUSB_CLASS_PHYSICAL = 5,
00160
00162 LIBUSB_CLASS_PRINTER = 7,
00163
00165 LIBUSB_CLASS_PTP = 6,
00166 LIBUSB_CLASS_IMAGE = 6,
00167
00169 LIBUSB_CLASS_MASS_STORAGE = 8,
00170
00172 LIBUSB_CLASS_HUB = 9,
00173
00175 LIBUSB_CLASS_DATA = 10,
00176
00178 LIBUSB_CLASS_SMART_CARD = 0x0b,
00179
00181 LIBUSB_CLASS_CONTENT_SECURITY = 0x0d,
00182
00184 LIBUSB_CLASS_VIDEO = 0x0e,
00185
00187 LIBUSB_CLASS_PERSONAL_HEALTHCARE = 0x0f,
00188
00190 LIBUSB_CLASS_DIAGNOSTIC_DEVICE = 0xdc,
00191
00193 LIBUSB_CLASS_WIRELESS = 0xe0,
00194
00196 LIBUSB_CLASS_APPLICATION = 0xfe,
00197
00199 LIBUSB_CLASS_VENDOR_SPEC = 0xff
00200 };
00201
00204 enum libusb_descriptor_type {
00206 LIBUSB_DT_DEVICE = 0x01,
00207
00209 LIBUSB_DT_CONFIG = 0x02,
00210
00212 LIBUSB_DT_STRING = 0x03,
00213
00215 LIBUSB_DT_INTERFACE = 0x04,
00216
00218 LIBUSB_DT_ENDPOINT = 0x05,
00219
00221 LIBUSB_DT_HID = 0x21,
00222
00224 LIBUSB_DT_REPORT = 0x22,
00225
00227 LIBUSB_DT_PHYSICAL = 0x23,
00228
00230 LIBUSB_DT_HUB = 0x29
00231 };
00232
00233
00234 #define LIBUSB_DT_DEVICE_SIZE 18
00235 #define LIBUSB_DT_CONFIG_SIZE 9
00236 #define LIBUSB_DT_INTERFACE_SIZE 9
00237 #define LIBUSB_DT_ENDPOINT_SIZE 7
00238 #define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9
00239 #define LIBUSB_DT_HUB_NONVAR_SIZE 7
00240
00241 #define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f
00242 #define LIBUSB_ENDPOINT_DIR_MASK 0x80
00243
00248 enum libusb_endpoint_direction {
00250 LIBUSB_ENDPOINT_IN = 0x80,
00251
00253 LIBUSB_ENDPOINT_OUT = 0x00
00254 };
00255
00256 #define LIBUSB_TRANSFER_TYPE_MASK 0x03
00257
00262 enum libusb_transfer_type {
00264 LIBUSB_TRANSFER_TYPE_CONTROL = 0,
00265
00267 LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1,
00268
00270 LIBUSB_TRANSFER_TYPE_BULK = 2,
00271
00273 LIBUSB_TRANSFER_TYPE_INTERRUPT = 3
00274 };
00275
00278 enum libusb_standard_request {
00280 LIBUSB_REQUEST_GET_STATUS = 0x00,
00281
00283 LIBUSB_REQUEST_CLEAR_FEATURE = 0x01,
00284
00285
00286
00288 LIBUSB_REQUEST_SET_FEATURE = 0x03,
00289
00290
00291
00293 LIBUSB_REQUEST_SET_ADDRESS = 0x05,
00294
00296 LIBUSB_REQUEST_GET_DESCRIPTOR = 0x06,
00297
00299 LIBUSB_REQUEST_SET_DESCRIPTOR = 0x07,
00300
00302 LIBUSB_REQUEST_GET_CONFIGURATION = 0x08,
00303
00305 LIBUSB_REQUEST_SET_CONFIGURATION = 0x09,
00306
00308 LIBUSB_REQUEST_GET_INTERFACE = 0x0A,
00309
00311 LIBUSB_REQUEST_SET_INTERFACE = 0x0B,
00312
00314 LIBUSB_REQUEST_SYNCH_FRAME = 0x0C
00315 };
00316
00321 enum libusb_request_type {
00323 LIBUSB_REQUEST_TYPE_STANDARD = (0x00 << 5),
00324
00326 LIBUSB_REQUEST_TYPE_CLASS = (0x01 << 5),
00327
00329 LIBUSB_REQUEST_TYPE_VENDOR = (0x02 << 5),
00330
00332 LIBUSB_REQUEST_TYPE_RESERVED = (0x03 << 5)
00333 };
00334
00339 enum libusb_request_recipient {
00341 LIBUSB_RECIPIENT_DEVICE = 0x00,
00342
00344 LIBUSB_RECIPIENT_INTERFACE = 0x01,
00345
00347 LIBUSB_RECIPIENT_ENDPOINT = 0x02,
00348
00350 LIBUSB_RECIPIENT_OTHER = 0x03
00351 };
00352
00353 #define LIBUSB_ISO_SYNC_TYPE_MASK 0x0C
00354
00360 enum libusb_iso_sync_type {
00362 LIBUSB_ISO_SYNC_TYPE_NONE = 0,
00363
00365 LIBUSB_ISO_SYNC_TYPE_ASYNC = 1,
00366
00368 LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 2,
00369
00371 LIBUSB_ISO_SYNC_TYPE_SYNC = 3
00372 };
00373
00374 #define LIBUSB_ISO_USAGE_TYPE_MASK 0x30
00375
00381 enum libusb_iso_usage_type {
00383 LIBUSB_ISO_USAGE_TYPE_DATA = 0,
00384
00386 LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1,
00387
00389 LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2
00390 };
00391
00397 struct libusb_device_descriptor {
00399 uint8_t bLength;
00400
00404 uint8_t bDescriptorType;
00405
00408 uint16_t bcdUSB;
00409
00411 uint8_t bDeviceClass;
00412
00415 uint8_t bDeviceSubClass;
00416
00419 uint8_t bDeviceProtocol;
00420
00422 uint8_t bMaxPacketSize0;
00423
00425 uint16_t idVendor;
00426
00428 uint16_t idProduct;
00429
00431 uint16_t bcdDevice;
00432
00434 uint8_t iManufacturer;
00435
00437 uint8_t iProduct;
00438
00440 uint8_t iSerialNumber;
00441
00443 uint8_t bNumConfigurations;
00444 };
00445
00451 struct libusb_endpoint_descriptor {
00453 uint8_t bLength;
00454
00458 uint8_t bDescriptorType;
00459
00464 uint8_t bEndpointAddress;
00465
00473 uint8_t bmAttributes;
00474
00476 uint16_t wMaxPacketSize;
00477
00479 uint8_t bInterval;
00480
00483 uint8_t bRefresh;
00484
00486 uint8_t bSynchAddress;
00487
00490 const unsigned char *extra;
00491
00493 int extra_length;
00494 };
00495
00501 struct libusb_interface_descriptor {
00503 uint8_t bLength;
00504
00508 uint8_t bDescriptorType;
00509
00511 uint8_t bInterfaceNumber;
00512
00514 uint8_t bAlternateSetting;
00515
00518 uint8_t bNumEndpoints;
00519
00521 uint8_t bInterfaceClass;
00522
00525 uint8_t bInterfaceSubClass;
00526
00529 uint8_t bInterfaceProtocol;
00530
00532 uint8_t iInterface;
00533
00536 const struct libusb_endpoint_descriptor *endpoint;
00537
00540 const unsigned char *extra;
00541
00543 int extra_length;
00544 };
00545
00549 struct libusb_interface {
00552 const struct libusb_interface_descriptor *altsetting;
00553
00555 int num_altsetting;
00556 };
00557
00563 struct libusb_config_descriptor {
00565 uint8_t bLength;
00566
00570 uint8_t bDescriptorType;
00571
00573 uint16_t wTotalLength;
00574
00576 uint8_t bNumInterfaces;
00577
00579 uint8_t bConfigurationValue;
00580
00582 uint8_t iConfiguration;
00583
00585 uint8_t bmAttributes;
00586
00590 uint8_t MaxPower;
00591
00594 const struct libusb_interface *interface;
00595
00598 const unsigned char *extra;
00599
00601 int extra_length;
00602 };
00603
00606 struct libusb_control_setup {
00612 uint8_t bmRequestType;
00613
00619 uint8_t bRequest;
00620
00622 uint16_t wValue;
00623
00626 uint16_t wIndex;
00627
00629 uint16_t wLength;
00630 };
00631
00632 #define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup))
00633
00634
00635
00636 struct libusb_context;
00637 struct libusb_device;
00638 struct libusb_device_handle;
00639
00657 typedef struct libusb_context libusb_context;
00658
00674 typedef struct libusb_device libusb_device;
00675
00676
00685 typedef struct libusb_device_handle libusb_device_handle;
00686
00690 enum libusb_speed {
00692 LIBUSB_SPEED_UNKNOWN = 0,
00693
00695 LIBUSB_SPEED_LOW = 1,
00696
00698 LIBUSB_SPEED_FULL = 2,
00699
00701 LIBUSB_SPEED_HIGH = 3,
00702
00704 LIBUSB_SPEED_SUPER = 4,
00705 };
00706
00713 enum libusb_error {
00715 LIBUSB_SUCCESS = 0,
00716
00718 LIBUSB_ERROR_IO = -1,
00719
00721 LIBUSB_ERROR_INVALID_PARAM = -2,
00722
00724 LIBUSB_ERROR_ACCESS = -3,
00725
00727 LIBUSB_ERROR_NO_DEVICE = -4,
00728
00730 LIBUSB_ERROR_NOT_FOUND = -5,
00731
00733 LIBUSB_ERROR_BUSY = -6,
00734
00736 LIBUSB_ERROR_TIMEOUT = -7,
00737
00739 LIBUSB_ERROR_OVERFLOW = -8,
00740
00742 LIBUSB_ERROR_PIPE = -9,
00743
00745 LIBUSB_ERROR_INTERRUPTED = -10,
00746
00748 LIBUSB_ERROR_NO_MEM = -11,
00749
00751 LIBUSB_ERROR_NOT_SUPPORTED = -12,
00752
00753
00754
00755
00757 LIBUSB_ERROR_OTHER = -99
00758 };
00759
00762 enum libusb_transfer_status {
00765 LIBUSB_TRANSFER_COMPLETED,
00766
00768 LIBUSB_TRANSFER_ERROR,
00769
00771 LIBUSB_TRANSFER_TIMED_OUT,
00772
00774 LIBUSB_TRANSFER_CANCELLED,
00775
00778 LIBUSB_TRANSFER_STALL,
00779
00781 LIBUSB_TRANSFER_NO_DEVICE,
00782
00784 LIBUSB_TRANSFER_OVERFLOW
00785 };
00786
00789 enum libusb_transfer_flags {
00791 LIBUSB_TRANSFER_SHORT_NOT_OK = 1<<0,
00792
00794 LIBUSB_TRANSFER_FREE_BUFFER = 1<<1,
00795
00800 LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2
00801 };
00802
00805 struct libusb_iso_packet_descriptor {
00807 unsigned int length;
00808
00810 unsigned int actual_length;
00811
00813 enum libusb_transfer_status status;
00814 };
00815
00816 struct libusb_transfer;
00817
00827 typedef void (LIBUSB_CALL *libusb_transfer_cb_fn)(struct libusb_transfer *transfer);
00828
00835 struct libusb_transfer {
00837 libusb_device_handle *dev_handle;
00838
00840 uint8_t flags;
00841
00843 unsigned char endpoint;
00844
00846 unsigned char type;
00847
00850 unsigned int timeout;
00851
00859 enum libusb_transfer_status status;
00860
00862 int length;
00863
00867 int actual_length;
00868
00871 libusb_transfer_cb_fn callback;
00872
00874 void *user_data;
00875
00877 unsigned char *buffer;
00878
00881 int num_iso_packets;
00882
00884 struct libusb_iso_packet_descriptor iso_packet_desc
00885 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
00886 []
00887 #else
00888 [0]
00889 #endif
00890 ;
00891 };
00892
00898 enum libusb_capability {
00900 LIBUSB_CAN_GET_DEVICE_SPEED = 0,
00901 };
00902
00903 int LIBUSB_CALL libusb_init(libusb_context **ctx);
00904 void LIBUSB_CALL libusb_exit(libusb_context *ctx);
00905 void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
00906 int LIBUSB_CALL libusb_has_capability(uint32_t capability);
00907 const char * LIBUSB_CALL libusb_error_name(int errcode);
00908
00909 ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,
00910 libusb_device ***list);
00911 void LIBUSB_CALL libusb_free_device_list(libusb_device **list,
00912 int unref_devices);
00913 libusb_device * LIBUSB_CALL libusb_ref_device(libusb_device *dev);
00914 void LIBUSB_CALL libusb_unref_device(libusb_device *dev);
00915
00916 int LIBUSB_CALL libusb_get_configuration(libusb_device_handle *dev,
00917 int *config);
00918 int LIBUSB_CALL libusb_get_device_descriptor(libusb_device *dev,
00919 struct libusb_device_descriptor *desc);
00920 int LIBUSB_CALL libusb_get_active_config_descriptor(libusb_device *dev,
00921 struct libusb_config_descriptor **config);
00922 int LIBUSB_CALL libusb_get_config_descriptor(libusb_device *dev,
00923 uint8_t config_index, struct libusb_config_descriptor **config);
00924 int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev,
00925 uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
00926 void LIBUSB_CALL libusb_free_config_descriptor(
00927 struct libusb_config_descriptor *config);
00928 uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev);
00929 uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev);
00930 int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev);
00931 int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev,
00932 unsigned char endpoint);
00933 int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev,
00934 unsigned char endpoint);
00935
00936 int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **handle);
00937 void LIBUSB_CALL libusb_close(libusb_device_handle *dev_handle);
00938 libusb_device * LIBUSB_CALL libusb_get_device(libusb_device_handle *dev_handle);
00939
00940 int LIBUSB_CALL libusb_set_configuration(libusb_device_handle *dev,
00941 int configuration);
00942 int LIBUSB_CALL libusb_claim_interface(libusb_device_handle *dev,
00943 int interface_number);
00944 int LIBUSB_CALL libusb_release_interface(libusb_device_handle *dev,
00945 int interface_number);
00946
00947 libusb_device_handle * LIBUSB_CALL libusb_open_device_with_vid_pid(
00948 libusb_context *ctx, uint16_t vendor_id, uint16_t product_id);
00949
00950 int LIBUSB_CALL libusb_set_interface_alt_setting(libusb_device_handle *dev,
00951 int interface_number, int alternate_setting);
00952 int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev,
00953 unsigned char endpoint);
00954 int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev);
00955
00956 int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev,
00957 int interface_number);
00958 int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev,
00959 int interface_number);
00960 int LIBUSB_CALL libusb_attach_kernel_driver(libusb_device_handle *dev,
00961 int interface_number);
00962
00963
00964
00977 static inline unsigned char *libusb_control_transfer_get_data(
00978 struct libusb_transfer *transfer)
00979 {
00980 return transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
00981 }
00982
00995 static inline struct libusb_control_setup *libusb_control_transfer_get_setup(
00996 struct libusb_transfer *transfer)
00997 {
00998 return (struct libusb_control_setup *) transfer->buffer;
00999 }
01000
01023 static inline void libusb_fill_control_setup(unsigned char *buffer,
01024 uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
01025 uint16_t wLength)
01026 {
01027 struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer;
01028 setup->bmRequestType = bmRequestType;
01029 setup->bRequest = bRequest;
01030 setup->wValue = libusb_cpu_to_le16(wValue);
01031 setup->wIndex = libusb_cpu_to_le16(wIndex);
01032 setup->wLength = libusb_cpu_to_le16(wLength);
01033 }
01034
01035 struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets);
01036 int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer);
01037 int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer);
01038 void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
01039
01067 static inline void libusb_fill_control_transfer(
01068 struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
01069 unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data,
01070 unsigned int timeout)
01071 {
01072 struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer;
01073 transfer->dev_handle = dev_handle;
01074 transfer->endpoint = 0;
01075 transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL;
01076 transfer->timeout = timeout;
01077 transfer->buffer = buffer;
01078 if (setup)
01079 transfer->length = LIBUSB_CONTROL_SETUP_SIZE
01080 + libusb_le16_to_cpu(setup->wLength);
01081 transfer->user_data = user_data;
01082 transfer->callback = callback;
01083 }
01084
01098 static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
01099 libusb_device_handle *dev_handle, unsigned char endpoint,
01100 unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
01101 void *user_data, unsigned int timeout)
01102 {
01103 transfer->dev_handle = dev_handle;
01104 transfer->endpoint = endpoint;
01105 transfer->type = LIBUSB_TRANSFER_TYPE_BULK;
01106 transfer->timeout = timeout;
01107 transfer->buffer = buffer;
01108 transfer->length = length;
01109 transfer->user_data = user_data;
01110 transfer->callback = callback;
01111 }
01112
01126 static inline void libusb_fill_interrupt_transfer(
01127 struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
01128 unsigned char endpoint, unsigned char *buffer, int length,
01129 libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
01130 {
01131 transfer->dev_handle = dev_handle;
01132 transfer->endpoint = endpoint;
01133 transfer->type = LIBUSB_TRANSFER_TYPE_INTERRUPT;
01134 transfer->timeout = timeout;
01135 transfer->buffer = buffer;
01136 transfer->length = length;
01137 transfer->user_data = user_data;
01138 transfer->callback = callback;
01139 }
01140
01155 static inline void libusb_fill_iso_transfer(struct libusb_transfer *transfer,
01156 libusb_device_handle *dev_handle, unsigned char endpoint,
01157 unsigned char *buffer, int length, int num_iso_packets,
01158 libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
01159 {
01160 transfer->dev_handle = dev_handle;
01161 transfer->endpoint = endpoint;
01162 transfer->type = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS;
01163 transfer->timeout = timeout;
01164 transfer->buffer = buffer;
01165 transfer->length = length;
01166 transfer->num_iso_packets = num_iso_packets;
01167 transfer->user_data = user_data;
01168 transfer->callback = callback;
01169 }
01170
01179 static inline void libusb_set_iso_packet_lengths(
01180 struct libusb_transfer *transfer, unsigned int length)
01181 {
01182 int i;
01183 for (i = 0; i < transfer->num_iso_packets; i++)
01184 transfer->iso_packet_desc[i].length = length;
01185 }
01186
01203 static inline unsigned char *libusb_get_iso_packet_buffer(
01204 struct libusb_transfer *transfer, unsigned int packet)
01205 {
01206 int i;
01207 size_t offset = 0;
01208 int _packet;
01209
01210
01211
01212
01213 if (packet > INT_MAX)
01214 return NULL;
01215 _packet = packet;
01216
01217 if (_packet >= transfer->num_iso_packets)
01218 return NULL;
01219
01220 for (i = 0; i < _packet; i++)
01221 offset += transfer->iso_packet_desc[i].length;
01222
01223 return transfer->buffer + offset;
01224 }
01225
01245 static inline unsigned char *libusb_get_iso_packet_buffer_simple(
01246 struct libusb_transfer *transfer, unsigned int packet)
01247 {
01248 int _packet;
01249
01250
01251
01252
01253 if (packet > INT_MAX)
01254 return NULL;
01255 _packet = packet;
01256
01257 if (_packet >= transfer->num_iso_packets)
01258 return NULL;
01259
01260 return transfer->buffer + (transfer->iso_packet_desc[0].length * _packet);
01261 }
01262
01263
01264
01265 int LIBUSB_CALL libusb_control_transfer(libusb_device_handle *dev_handle,
01266 uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
01267 unsigned char *data, uint16_t wLength, unsigned int timeout);
01268
01269 int LIBUSB_CALL libusb_bulk_transfer(libusb_device_handle *dev_handle,
01270 unsigned char endpoint, unsigned char *data, int length,
01271 int *actual_length, unsigned int timeout);
01272
01273 int LIBUSB_CALL libusb_interrupt_transfer(libusb_device_handle *dev_handle,
01274 unsigned char endpoint, unsigned char *data, int length,
01275 int *actual_length, unsigned int timeout);
01276
01289 static inline int libusb_get_descriptor(libusb_device_handle *dev,
01290 uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length)
01291 {
01292 return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN,
01293 LIBUSB_REQUEST_GET_DESCRIPTOR, (desc_type << 8) | desc_index, 0, data,
01294 (uint16_t) length, 1000);
01295 }
01296
01311 static inline int libusb_get_string_descriptor(libusb_device_handle *dev,
01312 uint8_t desc_index, uint16_t langid, unsigned char *data, int length)
01313 {
01314 return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN,
01315 LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | desc_index,
01316 langid, data, (uint16_t) length, 1000);
01317 }
01318
01319 int LIBUSB_CALL libusb_get_string_descriptor_ascii(libusb_device_handle *dev,
01320 uint8_t desc_index, unsigned char *data, int length);
01321
01322
01323
01324 int LIBUSB_CALL libusb_try_lock_events(libusb_context *ctx);
01325 void LIBUSB_CALL libusb_lock_events(libusb_context *ctx);
01326 void LIBUSB_CALL libusb_unlock_events(libusb_context *ctx);
01327 int LIBUSB_CALL libusb_event_handling_ok(libusb_context *ctx);
01328 int LIBUSB_CALL libusb_event_handler_active(libusb_context *ctx);
01329 void LIBUSB_CALL libusb_lock_event_waiters(libusb_context *ctx);
01330 void LIBUSB_CALL libusb_unlock_event_waiters(libusb_context *ctx);
01331 int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *tv);
01332
01333 int LIBUSB_CALL libusb_handle_events_timeout(libusb_context *ctx,
01334 struct timeval *tv);
01335 int LIBUSB_CALL libusb_handle_events_timeout_completed(libusb_context *ctx,
01336 struct timeval *tv, int *completed);
01337 int LIBUSB_CALL libusb_handle_events(libusb_context *ctx);
01338 int LIBUSB_CALL libusb_handle_events_completed(libusb_context *ctx, int *completed);
01339 int LIBUSB_CALL libusb_handle_events_locked(libusb_context *ctx,
01340 struct timeval *tv);
01341 int LIBUSB_CALL libusb_pollfds_handle_timeouts(libusb_context *ctx);
01342 int LIBUSB_CALL libusb_get_next_timeout(libusb_context *ctx,
01343 struct timeval *tv);
01344
01348 struct libusb_pollfd {
01350 int fd;
01351
01356 short events;
01357 };
01358
01369 typedef void (LIBUSB_CALL *libusb_pollfd_added_cb)(int fd, short events,
01370 void *user_data);
01371
01381 typedef void (LIBUSB_CALL *libusb_pollfd_removed_cb)(int fd, void *user_data);
01382
01383 const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds(
01384 libusb_context *ctx);
01385 void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx,
01386 libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,
01387 void *user_data);
01388
01389 #ifdef __cplusplus
01390 }
01391 #endif
01392
01393 #endif