1 /*
2 usb.h - USB support
3 
4 Copyright (c) 2003             Ulrich Hecht <uli@emulinks.de>
5 Copyright (c) 2004             NoisyB
6 Copyright (c) 2015, 2018, 2020 dbjh
7 
8 
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23 #ifndef MISC_USB_H
24 #define MISC_USB_H
25 
26 #ifdef  HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29 #ifdef  USE_USB
30 #ifdef  __MINGW64__
31 #include <libusb-compat/usb.h>
32 #elif   defined _WIN32 || (defined __CYGWIN__ && !defined __x86_64__) // 64-bit Cygwin has usb.h
33 #ifdef  _MSC_VER
34 #pragma warning(push)
35 #pragma warning(disable: 4255) // 'function' : no function prototype given: converting '()' to '(void)'
36 #pragma warning(disable: 4668) // 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives'
37 #pragma warning(disable: 4820) // 'bytes' bytes padding added after construct 'member_name'
38 #endif
39 #include <lusb0_usb.h>
40 #ifdef  _MSC_VER
41 #pragma warning(pop)
42 #endif
43 #else
44 #include <usb.h>
45 #endif
46 
47 #define USBOPEN_SUCCESS      0          // no error
48 #define USBOPEN_ERR_ACCESS   1          // not enough permissions to open device
49 #define USBOPEN_ERR_NOTFOUND 2          // device not found
50 
51 extern int usbport_open (usb_dev_handle **result_handle, int vendor_id,
52                          char *vendor_name, int product_id, char *product_name);
53 extern struct usb_device *usbport_probe (int vendor_id, int product_id);
54 extern int usbport_read (usb_dev_handle *handle, int endpoint, char *buffer,
55                          int buffer_size, int timeout);
56 extern int usbport_write (usb_dev_handle *handle, int endpoint, char *buffer,
57                           int buffer_size, int timeout);
58 
59 #endif // USE_USB
60 
61 #endif // MISC_USB_H
62