21#define LIBUSB_PATH_MAX 512
34#define USB_CLASS_PER_INTERFACE 0
35#define USB_CLASS_AUDIO 1
36#define USB_CLASS_COMM 2
37#define USB_CLASS_HID 3
38#define USB_CLASS_PRINTER 7
39#define USB_CLASS_MASS_STORAGE 8
40#define USB_CLASS_HUB 9
41#define USB_CLASS_DATA 10
42#define USB_CLASS_VENDOR_SPEC 0xff
47#define USB_DT_DEVICE 0x01
48#define USB_DT_CONFIG 0x02
49#define USB_DT_STRING 0x03
50#define USB_DT_INTERFACE 0x04
51#define USB_DT_ENDPOINT 0x05
53#define USB_DT_HID 0x21
54#define USB_DT_REPORT 0x22
55#define USB_DT_PHYSICAL 0x23
56#define USB_DT_HUB 0x29
61#define USB_DT_DEVICE_SIZE 18
62#define USB_DT_CONFIG_SIZE 9
63#define USB_DT_INTERFACE_SIZE 9
64#define USB_DT_ENDPOINT_SIZE 7
65#define USB_DT_ENDPOINT_AUDIO_SIZE 9
66#define USB_DT_HUB_NONVAR_SIZE 7
74 unsigned char bLength;
75 unsigned char bDescriptorType;
81 unsigned char bLength;
82 unsigned char bDescriptorType;
83 unsigned short wData[1];
89 unsigned char bLength;
90 unsigned char bDescriptorType;
91 unsigned short bcdHID;
92 unsigned char bCountryCode;
93 unsigned char bNumDescriptors;
97#define USB_MAXENDPOINTS 32
100 unsigned char bLength;
101 unsigned char bDescriptorType;
102 unsigned char bEndpointAddress;
103 unsigned char bmAttributes;
104 unsigned short wMaxPacketSize;
105 unsigned char bInterval;
106 unsigned char bRefresh;
107 unsigned char bSynchAddress;
109 unsigned char *extra;
113#define USB_ENDPOINT_ADDRESS_MASK 0x0f
114#define USB_ENDPOINT_DIR_MASK 0x80
116#define USB_ENDPOINT_TYPE_MASK 0x03
117#define USB_ENDPOINT_TYPE_CONTROL 0
118#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1
119#define USB_ENDPOINT_TYPE_BULK 2
120#define USB_ENDPOINT_TYPE_INTERRUPT 3
123#define USB_MAXINTERFACES 32
126 unsigned char bLength;
127 unsigned char bDescriptorType;
128 unsigned char bInterfaceNumber;
129 unsigned char bAlternateSetting;
130 unsigned char bNumEndpoints;
131 unsigned char bInterfaceClass;
132 unsigned char bInterfaceSubClass;
133 unsigned char bInterfaceProtocol;
134 unsigned char iInterface;
138 unsigned char *extra;
142#define USB_MAXALTSETTING 128
152#define USB_MAXCONFIG 8
155 unsigned char bLength;
156 unsigned char bDescriptorType;
157 unsigned short wTotalLength;
158 unsigned char bNumInterfaces;
159 unsigned char bConfigurationValue;
160 unsigned char iConfiguration;
161 unsigned char bmAttributes;
162 unsigned char MaxPower;
166 unsigned char *extra;
173 unsigned char bLength;
174 unsigned char bDescriptorType;
175 unsigned short bcdUSB;
176 unsigned char bDeviceClass;
177 unsigned char bDeviceSubClass;
178 unsigned char bDeviceProtocol;
179 unsigned char bMaxPacketSize0;
180 unsigned short idVendor;
181 unsigned short idProduct;
182 unsigned short bcdDevice;
183 unsigned char iManufacturer;
184 unsigned char iProduct;
185 unsigned char iSerialNumber;
186 unsigned char bNumConfigurations;
191 unsigned char bRequestType;
192 unsigned char bRequest;
193 unsigned short wValue;
194 unsigned short wIndex;
195 unsigned short wLength;
201#define USB_REQ_GET_STATUS 0x00
202#define USB_REQ_CLEAR_FEATURE 0x01
204#define USB_REQ_SET_FEATURE 0x03
206#define USB_REQ_SET_ADDRESS 0x05
207#define USB_REQ_GET_DESCRIPTOR 0x06
208#define USB_REQ_SET_DESCRIPTOR 0x07
209#define USB_REQ_GET_CONFIGURATION 0x08
210#define USB_REQ_SET_CONFIGURATION 0x09
211#define USB_REQ_GET_INTERFACE 0x0A
212#define USB_REQ_SET_INTERFACE 0x0B
213#define USB_REQ_SYNCH_FRAME 0x0C
215#define USB_TYPE_STANDARD (0x00 << 5)
216#define USB_TYPE_CLASS (0x01 << 5)
217#define USB_TYPE_VENDOR (0x02 << 5)
218#define USB_TYPE_RESERVED (0x03 << 5)
220#define USB_RECIP_DEVICE 0x00
221#define USB_RECIP_INTERFACE 0x01
222#define USB_RECIP_ENDPOINT 0x02
223#define USB_RECIP_OTHER 0x03
229#define USB_ENDPOINT_IN 0x80
230#define USB_ENDPOINT_OUT 0x00
233#define USB_ERROR_BEGIN 500000
239#define USB_LE16_TO_CPU(x)
246#define USB_RESET_TYPE_RESET_PORT (1 << 0)
247#define USB_RESET_TYPE_CYCLE_PORT (1 << 1)
248#define USB_RESET_TYPE_FULL_RESET (USB_RESET_TYPE_CYCLE_PORT | USB_RESET_TYPE_RESET_PORT)
259 char filename[LIBUSB_PATH_MAX];
268 unsigned char devnum;
270 unsigned char num_children;
278 char dirname[LIBUSB_PATH_MAX];
281 unsigned long location;
307struct usb_dev_handle;
308typedef struct usb_dev_handle usb_dev_handle;
312#define usb_busses usb_get_busses()
325 usb_dev_handle *usb_open(
struct usb_device *dev);
326 int usb_close(usb_dev_handle *dev);
327 int usb_get_string(usb_dev_handle *dev,
int index,
int langid,
char *buf,
329 int usb_get_string_simple(usb_dev_handle *dev,
int index,
char *buf,
333 int usb_get_descriptor_by_endpoint(usb_dev_handle *udev,
int ep,
334 unsigned char type,
unsigned char index,
335 void *buf,
int size);
336 int usb_get_descriptor(usb_dev_handle *udev,
unsigned char type,
337 unsigned char index,
void *buf,
int size);
340 int usb_bulk_write(usb_dev_handle *dev,
int ep,
char *bytes,
int size,
342 int usb_bulk_read(usb_dev_handle *dev,
int ep,
char *bytes,
int size,
344 int usb_interrupt_write(usb_dev_handle *dev,
int ep,
char *bytes,
int size,
346 int usb_interrupt_read(usb_dev_handle *dev,
int ep,
char *bytes,
int size,
348 int usb_control_msg(usb_dev_handle *dev,
int requesttype,
int request,
349 int value,
int index,
char *bytes,
int size,
351 int usb_set_configuration(usb_dev_handle *dev,
int configuration);
352 int usb_claim_interface(usb_dev_handle *dev,
int interface);
353 int usb_release_interface(usb_dev_handle *dev,
int interface);
354 int usb_set_altinterface(usb_dev_handle *dev,
int alternate);
355 int usb_resetep(usb_dev_handle *dev,
unsigned int ep);
356 int usb_clear_halt(usb_dev_handle *dev,
unsigned int ep);
357 int usb_reset(usb_dev_handle *dev);
358 int usb_reset_ex(usb_dev_handle *dev,
unsigned int reset_type);
360 char *usb_strerror(
void);
363 void usb_set_debug(
int level);
364 int usb_find_busses(
void);
365 int usb_find_devices(
void);
367 struct usb_bus *usb_get_busses(
void);
371#define LIBUSB_HAS_INSTALL_SERVICE_NP 1
372 int usb_install_service_np(
void);
373 void CALLBACK usb_install_service_np_rundll(HWND wnd, HINSTANCE instance,
374 LPSTR cmd_line,
int cmd_show);
376#define LIBUSB_HAS_UNINSTALL_SERVICE_NP 1
377 int usb_uninstall_service_np(
void);
378 void CALLBACK usb_uninstall_service_np_rundll(HWND wnd, HINSTANCE instance,
379 LPSTR cmd_line,
int cmd_show);
381#define LIBUSB_HAS_INSTALL_DRIVER_NP 1
382 int usb_install_driver_np(
const char *inf_file);
383 void CALLBACK usb_install_driver_np_rundll(HWND wnd, HINSTANCE instance,
384 LPSTR cmd_line,
int cmd_show);
386#define LIBUSB_HAS_TOUCH_INF_FILE_NP 1
387 int usb_touch_inf_file_np(
const char *inf_file);
388 void CALLBACK usb_touch_inf_file_np_rundll(HWND wnd, HINSTANCE instance,
389 LPSTR cmd_line,
int cmd_show);
391#define LIBUSB_HAS_INSTALL_NEEDS_RESTART_NP 1
392 int usb_install_needs_restart_np(
void);
394#define LIBUSB_HAS_INSTALL_NP 1
395 int usb_install_npW(HWND hwnd, HINSTANCE instance, LPCWSTR cmd_line,
int starg_arg);
396 int usb_install_npA(HWND hwnd, HINSTANCE instance, LPCSTR cmd_line,
int starg_arg);
397 #define usb_install_np usb_install_npA
398 void CALLBACK usb_install_np_rundll(HWND wnd, HINSTANCE instance,
399 LPSTR cmd_line,
int cmd_show);
403 int usb_isochronous_setup_async(usb_dev_handle *dev,
void **context,
404 unsigned char ep,
int pktsize);
405 int usb_bulk_setup_async(usb_dev_handle *dev,
void **context,
407 int usb_interrupt_setup_async(usb_dev_handle *dev,
void **context,
410 int usb_submit_async(
void *context,
char *bytes,
int size);
411 int usb_reap_async(
void *context,
int timeout);
412 int usb_reap_async_nocancel(
void *context,
int timeout);
413 int usb_cancel_async(
void *context);
414 int usb_free_async(
void **context);