usb 1.7.2 → 1.8.0-libusb.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/.gitmodules +1 -1
  2. package/Readme.md +2 -2
  3. package/binding.gyp +2 -2
  4. package/libusb/.private/pre-commit.sh +7 -1
  5. package/libusb/.travis.yml +49 -0
  6. package/libusb/AUTHORS +44 -3
  7. package/libusb/Brewfile +4 -0
  8. package/libusb/ChangeLog +74 -2
  9. package/libusb/README.md +32 -0
  10. package/libusb/TODO +1 -1
  11. package/libusb/Xcode/common.xcconfig +12 -0
  12. package/libusb/Xcode/config.h +25 -0
  13. package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +959 -1
  14. package/libusb/android/README +4 -2
  15. package/libusb/android/config.h +75 -0
  16. package/libusb/appveyor.yml +41 -0
  17. package/libusb/appveyor_cygwin.bat +11 -0
  18. package/libusb/appveyor_minGW.bat +19 -0
  19. package/libusb/autogen.sh +1 -1
  20. package/libusb/bootstrap.sh +3 -16
  21. package/libusb/configure.ac +108 -80
  22. package/libusb/doc/doxygen.cfg.in +1785 -739
  23. package/libusb/examples/Makefile.am +1 -1
  24. package/libusb/examples/dpfp.c +3 -1
  25. package/libusb/examples/dpfp_threaded.c +23 -10
  26. package/libusb/examples/ezusb.c +3 -3
  27. package/libusb/examples/ezusb.h +2 -2
  28. package/libusb/examples/fxload.c +31 -9
  29. package/libusb/examples/hotplugtest.c +35 -7
  30. package/libusb/examples/listdevs.c +3 -1
  31. package/libusb/examples/sam3u_benchmark.c +3 -3
  32. package/libusb/examples/testlibusb.c +277 -0
  33. package/libusb/examples/xusb.c +40 -34
  34. package/libusb/libusb/Makefile.am +49 -23
  35. package/libusb/libusb/core.c +855 -457
  36. package/libusb/libusb/descriptor.c +72 -78
  37. package/libusb/libusb/hotplug.c +122 -76
  38. package/libusb/libusb/hotplug.h +42 -25
  39. package/libusb/libusb/io.c +625 -390
  40. package/libusb/libusb/libusb-1.0.def +12 -0
  41. package/libusb/libusb/libusb.h +218 -150
  42. package/libusb/libusb/libusbi.h +346 -176
  43. package/libusb/libusb/os/darwin_usb.c +604 -319
  44. package/libusb/libusb/os/darwin_usb.h +61 -20
  45. package/libusb/libusb/os/haiku_pollfs.cpp +367 -0
  46. package/libusb/libusb/os/haiku_usb.h +113 -0
  47. package/libusb/libusb/os/haiku_usb_backend.cpp +533 -0
  48. package/libusb/libusb/os/haiku_usb_raw.cpp +267 -0
  49. package/libusb/libusb/os/haiku_usb_raw.h +188 -0
  50. package/libusb/libusb/os/linux_netlink.c +186 -146
  51. package/libusb/libusb/os/linux_udev.c +36 -14
  52. package/libusb/libusb/os/linux_usbfs.c +426 -225
  53. package/libusb/libusb/os/linux_usbfs.h +5 -3
  54. package/libusb/libusb/os/netbsd_usb.c +21 -77
  55. package/libusb/libusb/os/openbsd_usb.c +32 -115
  56. package/libusb/libusb/os/poll_posix.c +38 -5
  57. package/libusb/libusb/os/poll_posix.h +3 -0
  58. package/libusb/libusb/os/poll_windows.c +277 -626
  59. package/libusb/libusb/os/poll_windows.h +11 -44
  60. package/libusb/libusb/os/sunos_usb.c +1695 -0
  61. package/libusb/libusb/os/sunos_usb.h +80 -0
  62. package/libusb/libusb/os/threads_posix.c +24 -26
  63. package/libusb/libusb/os/threads_posix.h +73 -21
  64. package/libusb/libusb/os/threads_windows.c +71 -157
  65. package/libusb/libusb/os/threads_windows.h +68 -44
  66. package/libusb/libusb/os/wince_usb.c +276 -420
  67. package/libusb/libusb/os/wince_usb.h +23 -28
  68. package/libusb/libusb/os/windows_common.h +78 -58
  69. package/libusb/libusb/os/windows_nt_common.c +1010 -0
  70. package/libusb/libusb/os/windows_nt_common.h +110 -0
  71. package/libusb/libusb/os/windows_nt_shared_types.h +147 -0
  72. package/libusb/libusb/os/windows_usbdk.c +830 -0
  73. package/libusb/libusb/os/windows_usbdk.h +103 -0
  74. package/libusb/libusb/os/windows_winusb.c +4391 -0
  75. package/libusb/libusb/os/windows_winusb.h +783 -0
  76. package/libusb/libusb/strerror.c +41 -7
  77. package/libusb/libusb/sync.c +41 -13
  78. package/libusb/libusb/version.h +1 -1
  79. package/libusb/libusb/version_nano.h +1 -1
  80. package/libusb/libusb-1.0.pc.in +1 -1
  81. package/libusb/msvc/appveyor.bat +27 -0
  82. package/libusb/msvc/config.h +5 -4
  83. package/libusb/msvc/ddk_build.cmd +87 -43
  84. package/libusb/msvc/fxload_2010.vcxproj +24 -104
  85. package/libusb/msvc/fxload_2012.vcxproj +24 -107
  86. package/libusb/msvc/fxload_2013.vcxproj +24 -107
  87. package/libusb/msvc/fxload_2015.vcxproj +91 -0
  88. package/libusb/msvc/fxload_2017.vcxproj +114 -0
  89. package/libusb/msvc/fxload_sources +1 -1
  90. package/libusb/msvc/getopt_2010.vcxproj +16 -75
  91. package/libusb/msvc/getopt_2012.vcxproj +16 -79
  92. package/libusb/msvc/getopt_2013.vcxproj +16 -79
  93. package/libusb/msvc/getopt_2015.vcxproj +73 -0
  94. package/libusb/msvc/getopt_2017.vcxproj +98 -0
  95. package/libusb/msvc/getopt_sources +6 -2
  96. package/libusb/msvc/hotplugtest_2010.vcxproj +18 -99
  97. package/libusb/msvc/hotplugtest_2012.vcxproj +18 -102
  98. package/libusb/msvc/hotplugtest_2013.vcxproj +18 -102
  99. package/libusb/msvc/hotplugtest_2015.vcxproj +83 -0
  100. package/libusb/msvc/hotplugtest_2017.vcxproj +106 -0
  101. package/libusb/msvc/hotplugtest_sources +1 -1
  102. package/libusb/msvc/libusb_2005.sln +20 -20
  103. package/libusb/msvc/libusb_2010.sln +57 -46
  104. package/libusb/msvc/libusb_2012.sln +57 -46
  105. package/libusb/msvc/libusb_2013.sln +57 -50
  106. package/libusb/msvc/libusb_2015.sln +59 -52
  107. package/libusb/msvc/libusb_2017.sln +186 -0
  108. package/libusb/msvc/libusb_dll.dsp +2 -2
  109. package/libusb/msvc/libusb_dll_2005.vcproj +30 -2
  110. package/libusb/msvc/libusb_dll_2010.vcxproj +26 -90
  111. package/libusb/msvc/libusb_dll_2012.vcxproj +28 -96
  112. package/libusb/msvc/libusb_dll_2013.vcxproj +28 -96
  113. package/libusb/msvc/libusb_dll_2015.vcxproj +107 -0
  114. package/libusb/msvc/libusb_dll_2017.vcxproj +134 -0
  115. package/libusb/msvc/libusb_dll_wince.vcproj +9 -1
  116. package/libusb/msvc/libusb_sources +10 -5
  117. package/libusb/msvc/libusb_static.dsp +2 -2
  118. package/libusb/msvc/libusb_static_2005.vcproj +32 -4
  119. package/libusb/msvc/libusb_static_2010.vcxproj +24 -83
  120. package/libusb/msvc/libusb_static_2012.vcxproj +25 -87
  121. package/libusb/msvc/libusb_static_2013.vcxproj +25 -87
  122. package/libusb/msvc/libusb_static_2015.vcxproj +98 -0
  123. package/libusb/msvc/libusb_static_2017.vcxproj +117 -0
  124. package/libusb/msvc/libusb_static_wince.vcproj +20 -26
  125. package/libusb/msvc/libusb_wince.sln +88 -88
  126. package/libusb/msvc/listdevs_2010.vcxproj +16 -99
  127. package/libusb/msvc/listdevs_2012.vcxproj +16 -102
  128. package/libusb/msvc/listdevs_2013.vcxproj +16 -102
  129. package/libusb/msvc/listdevs_2015.vcxproj +83 -0
  130. package/libusb/msvc/listdevs_2017.vcxproj +106 -0
  131. package/libusb/msvc/listdevs_sources +2 -1
  132. package/libusb/msvc/stress_2010.vcxproj +20 -101
  133. package/libusb/msvc/stress_2012.vcxproj +20 -104
  134. package/libusb/msvc/stress_2013.vcxproj +20 -104
  135. package/libusb/msvc/stress_2015.vcxproj +87 -0
  136. package/libusb/msvc/stress_2017.vcxproj +110 -0
  137. package/libusb/msvc/stress_sources +21 -0
  138. package/libusb/msvc/testlibusb_2010.vcxproj +82 -0
  139. package/libusb/msvc/testlibusb_2012.vcxproj +83 -0
  140. package/libusb/msvc/testlibusb_2013.vcxproj +83 -0
  141. package/libusb/msvc/testlibusb_2015.vcxproj +83 -0
  142. package/libusb/msvc/testlibusb_2017.vcxproj +106 -0
  143. package/libusb/msvc/testlibusb_sources +20 -0
  144. package/libusb/msvc/xusb_2010.vcxproj +17 -98
  145. package/libusb/msvc/xusb_2012.vcxproj +17 -101
  146. package/libusb/msvc/xusb_2013.vcxproj +17 -101
  147. package/libusb/msvc/xusb_2015.vcxproj +83 -0
  148. package/libusb/msvc/xusb_2017.vcxproj +106 -0
  149. package/libusb/msvc/xusb_sources +1 -1
  150. package/libusb/tests/stress.c +2 -2
  151. package/libusb/tests/testlib.c +0 -4
  152. package/libusb/travis-autogen.sh +39 -0
  153. package/libusb.gypi +13 -2
  154. package/package.json +20 -11
  155. package/prebuilds/android-arm/node.napi.armv7.node +0 -0
  156. package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
  157. package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
  158. package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
  159. package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
  160. package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
  161. package/prebuilds/linux-ia32/node.napi.node +0 -0
  162. package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  163. package/prebuilds/linux-x64/node.napi.musl.node +0 -0
  164. package/prebuilds/win32-ia32/node.napi.node +0 -0
  165. package/prebuilds/win32-x64/node.napi.node +0 -0
  166. package/src/device.cc +1 -1
  167. package/usb.js +1 -1
  168. package/.github/workflows/prebuild.yml +0 -49
  169. package/libusb/INSTALL +0 -234
  170. package/libusb/README +0 -28
  171. package/libusb/libusb/os/windows_usb.c +0 -5347
  172. package/libusb/libusb/os/windows_usb.h +0 -971
  173. package/libusb/msvc/fxload_2010.vcxproj.filters +0 -25
  174. package/libusb/msvc/fxload_2012.vcxproj.filters +0 -25
  175. package/libusb/msvc/getopt_2010.vcxproj.filters +0 -26
  176. package/libusb/msvc/getopt_2012.vcxproj.filters +0 -26
  177. package/libusb/msvc/hotplugtest_2010.vcxproj.filters +0 -14
  178. package/libusb/msvc/hotplugtest_2012.vcxproj.filters +0 -14
  179. package/libusb/msvc/libusb_dll_2010.vcxproj.filters +0 -81
  180. package/libusb/msvc/libusb_dll_2012.vcxproj.filters +0 -84
  181. package/libusb/msvc/libusb_static_2010.vcxproj.filters +0 -74
  182. package/libusb/msvc/libusb_static_2012.vcxproj.filters +0 -74
  183. package/libusb/msvc/listdevs_2010.vcxproj.filters +0 -14
  184. package/libusb/msvc/listdevs_2012.vcxproj.filters +0 -14
  185. package/libusb/msvc/stress_2010.vcxproj.filters +0 -25
  186. package/libusb/msvc/stress_2012.vcxproj.filters +0 -25
  187. package/libusb/msvc/xusb_2010.vcxproj.filters +0 -14
  188. package/libusb/msvc/xusb_2012.vcxproj.filters +0 -14
@@ -0,0 +1,783 @@
1
+ /*
2
+ * Windows backend for libusb 1.0
3
+ * Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
4
+ * With contributions from Michael Plante, Orin Eman et al.
5
+ * Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
6
+ * Major code testing contribution by Xiaofan Chen
7
+ *
8
+ * This library is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU Lesser General Public
10
+ * License as published by the Free Software Foundation; either
11
+ * version 2.1 of the License, or (at your option) any later version.
12
+ *
13
+ * This library is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ * Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public
19
+ * License along with this library; if not, write to the Free Software
20
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
+ */
22
+
23
+ #pragma once
24
+
25
+ #include "windows_common.h"
26
+ #include "windows_nt_common.h"
27
+
28
+ #if defined(_MSC_VER)
29
+ // disable /W4 MSVC warnings that are benign
30
+ #pragma warning(disable:4100) // unreferenced formal parameter
31
+ #pragma warning(disable:4127) // conditional expression is constant
32
+ #pragma warning(disable:4201) // nameless struct/union
33
+ #pragma warning(disable:4214) // bit field types other than int
34
+ #pragma warning(disable:4996) // deprecated API calls
35
+ #pragma warning(disable:28159) // more deprecated API calls
36
+ #endif
37
+
38
+ // Missing from MSVC6 setupapi.h
39
+ #ifndef SPDRP_ADDRESS
40
+ #define SPDRP_ADDRESS 28
41
+ #endif
42
+ #ifndef SPDRP_INSTALL_STATE
43
+ #define SPDRP_INSTALL_STATE 34
44
+ #endif
45
+
46
+ #define MAX_CTRL_BUFFER_LENGTH 4096
47
+ #define MAX_USB_STRING_LENGTH 128
48
+ #define MAX_HID_REPORT_SIZE 1024
49
+ #define MAX_HID_DESCRIPTOR_SIZE 256
50
+ #define MAX_GUID_STRING_LENGTH 40
51
+ #define MAX_PATH_LENGTH 128
52
+ #define MAX_KEY_LENGTH 256
53
+ #define LIST_SEPARATOR ';'
54
+
55
+ // Handle code for HID interface that have been claimed ("dibs")
56
+ #define INTERFACE_CLAIMED ((HANDLE)(intptr_t)0xD1B5)
57
+ // Additional return code for HID operations that completed synchronously
58
+ #define LIBUSB_COMPLETED (LIBUSB_SUCCESS + 1)
59
+
60
+ // http://msdn.microsoft.com/en-us/library/ff545978.aspx
61
+ // http://msdn.microsoft.com/en-us/library/ff545972.aspx
62
+ // http://msdn.microsoft.com/en-us/library/ff545982.aspx
63
+ #ifndef GUID_DEVINTERFACE_USB_HOST_CONTROLLER
64
+ const GUID GUID_DEVINTERFACE_USB_HOST_CONTROLLER = {0x3ABF6F2D, 0x71C4, 0x462A, {0x8A, 0x92, 0x1E, 0x68, 0x61, 0xE6, 0xAF, 0x27}};
65
+ #endif
66
+ #ifndef GUID_DEVINTERFACE_USB_DEVICE
67
+ const GUID GUID_DEVINTERFACE_USB_DEVICE = {0xA5DCBF10, 0x6530, 0x11D2, {0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED}};
68
+ #endif
69
+ #ifndef GUID_DEVINTERFACE_USB_HUB
70
+ const GUID GUID_DEVINTERFACE_USB_HUB = {0xF18A0E88, 0xC30C, 0x11D0, {0x88, 0x15, 0x00, 0xA0, 0xC9, 0x06, 0xBE, 0xD8}};
71
+ #endif
72
+ #ifndef GUID_DEVINTERFACE_LIBUSB0_FILTER
73
+ const GUID GUID_DEVINTERFACE_LIBUSB0_FILTER = {0xF9F3FF14, 0xAE21, 0x48A0, {0x8A, 0x25, 0x80, 0x11, 0xA7, 0xA9, 0x31, 0xD9}};
74
+ #endif
75
+
76
+
77
+ /*
78
+ * Multiple USB API backend support
79
+ */
80
+ #define USB_API_UNSUPPORTED 0
81
+ #define USB_API_HUB 1
82
+ #define USB_API_COMPOSITE 2
83
+ #define USB_API_WINUSBX 3
84
+ #define USB_API_HID 4
85
+ #define USB_API_MAX 5
86
+
87
+ // Sub-APIs for WinUSB-like driver APIs (WinUSB, libusbK, libusb-win32 through the libusbK DLL)
88
+ // Must have the same values as the KUSB_DRVID enum from libusbk.h
89
+ #define SUB_API_NOTSET -1
90
+ #define SUB_API_LIBUSBK 0
91
+ #define SUB_API_LIBUSB0 1
92
+ #define SUB_API_WINUSB 2
93
+ #define SUB_API_MAX 3
94
+
95
+ struct windows_usb_api_backend {
96
+ const uint8_t id;
97
+ const char * const designation;
98
+ const char * const * const driver_name_list; // Driver name, without .sys, e.g. "usbccgp"
99
+ const uint8_t nb_driver_names;
100
+ int (*init)(struct libusb_context *ctx);
101
+ void (*exit)(void);
102
+ int (*open)(int sub_api, struct libusb_device_handle *dev_handle);
103
+ void (*close)(int sub_api, struct libusb_device_handle *dev_handle);
104
+ int (*configure_endpoints)(int sub_api, struct libusb_device_handle *dev_handle, int iface);
105
+ int (*claim_interface)(int sub_api, struct libusb_device_handle *dev_handle, int iface);
106
+ int (*set_interface_altsetting)(int sub_api, struct libusb_device_handle *dev_handle, int iface, int altsetting);
107
+ int (*release_interface)(int sub_api, struct libusb_device_handle *dev_handle, int iface);
108
+ int (*clear_halt)(int sub_api, struct libusb_device_handle *dev_handle, unsigned char endpoint);
109
+ int (*reset_device)(int sub_api, struct libusb_device_handle *dev_handle);
110
+ int (*submit_bulk_transfer)(int sub_api, struct usbi_transfer *itransfer);
111
+ int (*submit_iso_transfer)(int sub_api, struct usbi_transfer *itransfer);
112
+ int (*submit_control_transfer)(int sub_api, struct usbi_transfer *itransfer);
113
+ int (*abort_control)(int sub_api, struct usbi_transfer *itransfer);
114
+ int (*abort_transfers)(int sub_api, struct usbi_transfer *itransfer);
115
+ int (*copy_transfer_data)(int sub_api, struct usbi_transfer *itransfer, uint32_t io_size);
116
+ };
117
+
118
+ extern const struct windows_usb_api_backend usb_api_backend[USB_API_MAX];
119
+
120
+ #define PRINT_UNSUPPORTED_API(fname) \
121
+ usbi_dbg("unsupported API call for '%s' " \
122
+ "(unrecognized device driver)", #fname)
123
+
124
+ #define CHECK_SUPPORTED_API(apip, fname) \
125
+ do { \
126
+ if ((apip)->fname == NULL) { \
127
+ PRINT_UNSUPPORTED_API(fname); \
128
+ return LIBUSB_ERROR_NOT_SUPPORTED; \
129
+ } \
130
+ } while (0)
131
+
132
+ /*
133
+ * private structures definition
134
+ * with inline pseudo constructors/destructors
135
+ */
136
+
137
+ // TODO (v2+): move hid desc to libusb.h?
138
+ struct libusb_hid_descriptor {
139
+ uint8_t bLength;
140
+ uint8_t bDescriptorType;
141
+ uint16_t bcdHID;
142
+ uint8_t bCountryCode;
143
+ uint8_t bNumDescriptors;
144
+ uint8_t bClassDescriptorType;
145
+ uint16_t wClassDescriptorLength;
146
+ };
147
+
148
+ #define LIBUSB_DT_HID_SIZE 9
149
+ #define HID_MAX_CONFIG_DESC_SIZE (LIBUSB_DT_CONFIG_SIZE + LIBUSB_DT_INTERFACE_SIZE \
150
+ + LIBUSB_DT_HID_SIZE + 2 * LIBUSB_DT_ENDPOINT_SIZE)
151
+ #define HID_MAX_REPORT_SIZE 1024
152
+ #define HID_IN_EP 0x81
153
+ #define HID_OUT_EP 0x02
154
+ #define LIBUSB_REQ_RECIPIENT(request_type) ((request_type) & 0x1F)
155
+ #define LIBUSB_REQ_TYPE(request_type) ((request_type) & (0x03 << 5))
156
+ #define LIBUSB_REQ_IN(request_type) ((request_type) & LIBUSB_ENDPOINT_IN)
157
+ #define LIBUSB_REQ_OUT(request_type) (!LIBUSB_REQ_IN(request_type))
158
+
159
+ #ifndef CTL_CODE
160
+ #define CTL_CODE(DeviceType, Function, Method, Access) \
161
+ (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
162
+ #endif
163
+
164
+ // The following are used for HID reports IOCTLs
165
+ #define HID_IN_CTL_CODE(id) \
166
+ CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_IN_DIRECT, FILE_ANY_ACCESS)
167
+ #define HID_OUT_CTL_CODE(id) \
168
+ CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
169
+
170
+ #define IOCTL_HID_GET_FEATURE HID_OUT_CTL_CODE(100)
171
+ #define IOCTL_HID_GET_INPUT_REPORT HID_OUT_CTL_CODE(104)
172
+ #define IOCTL_HID_SET_FEATURE HID_IN_CTL_CODE(100)
173
+ #define IOCTL_HID_SET_OUTPUT_REPORT HID_IN_CTL_CODE(101)
174
+
175
+ enum libusb_hid_request_type {
176
+ HID_REQ_GET_REPORT = 0x01,
177
+ HID_REQ_GET_IDLE = 0x02,
178
+ HID_REQ_GET_PROTOCOL = 0x03,
179
+ HID_REQ_SET_REPORT = 0x09,
180
+ HID_REQ_SET_IDLE = 0x0A,
181
+ HID_REQ_SET_PROTOCOL = 0x0B
182
+ };
183
+
184
+ enum libusb_hid_report_type {
185
+ HID_REPORT_TYPE_INPUT = 0x01,
186
+ HID_REPORT_TYPE_OUTPUT = 0x02,
187
+ HID_REPORT_TYPE_FEATURE = 0x03
188
+ };
189
+
190
+ struct hid_device_priv {
191
+ uint16_t vid;
192
+ uint16_t pid;
193
+ uint8_t config;
194
+ uint8_t nb_interfaces;
195
+ bool uses_report_ids[3]; // input, ouptput, feature
196
+ uint16_t input_report_size;
197
+ uint16_t output_report_size;
198
+ uint16_t feature_report_size;
199
+ uint16_t usage;
200
+ uint16_t usagePage;
201
+ WCHAR string[3][MAX_USB_STRING_LENGTH];
202
+ uint8_t string_index[3]; // man, prod, ser
203
+ };
204
+
205
+ static inline struct winusb_device_priv *_device_priv(struct libusb_device *dev)
206
+ {
207
+ return (struct winusb_device_priv *)dev->os_priv;
208
+ }
209
+
210
+ static inline struct winusb_device_priv *winusb_device_priv_init(struct libusb_device *dev)
211
+ {
212
+ struct winusb_device_priv *p = _device_priv(dev);
213
+ int i;
214
+
215
+ p->apib = &usb_api_backend[USB_API_UNSUPPORTED];
216
+ p->sub_api = SUB_API_NOTSET;
217
+ for (i = 0; i < USB_MAXINTERFACES; i++) {
218
+ p->usb_interface[i].apib = &usb_api_backend[USB_API_UNSUPPORTED];
219
+ p->usb_interface[i].sub_api = SUB_API_NOTSET;
220
+ }
221
+
222
+ return p;
223
+ }
224
+
225
+ static inline void winusb_device_priv_release(struct libusb_device *dev)
226
+ {
227
+ struct winusb_device_priv *p = _device_priv(dev);
228
+ int i;
229
+
230
+ free(p->dev_id);
231
+ free(p->path);
232
+ if ((dev->num_configurations > 0) && (p->config_descriptor != NULL)) {
233
+ for (i = 0; i < dev->num_configurations; i++)
234
+ free(p->config_descriptor[i]);
235
+ }
236
+ free(p->config_descriptor);
237
+ free(p->hid);
238
+ for (i = 0; i < USB_MAXINTERFACES; i++) {
239
+ free(p->usb_interface[i].path);
240
+ free(p->usb_interface[i].endpoint);
241
+ }
242
+ }
243
+
244
+ static inline struct winusb_device_handle_priv *_device_handle_priv(
245
+ struct libusb_device_handle *handle)
246
+ {
247
+ return (struct winusb_device_handle_priv *)handle->os_priv;
248
+ }
249
+
250
+ // used to match a device driver (including filter drivers) against a supported API
251
+ struct driver_lookup {
252
+ char list[MAX_KEY_LENGTH + 1]; // REG_MULTI_SZ list of services (driver) names
253
+ const DWORD reg_prop; // SPDRP registry key to use to retrieve list
254
+ const char* designation; // internal designation (for debug output)
255
+ };
256
+
257
+ /*
258
+ * Windows DDK API definitions. Most of it copied from MinGW's includes
259
+ */
260
+ typedef DWORD DEVNODE, DEVINST;
261
+ typedef DEVNODE *PDEVNODE, *PDEVINST;
262
+ typedef DWORD RETURN_TYPE;
263
+ typedef RETURN_TYPE CONFIGRET;
264
+
265
+ #define CR_SUCCESS 0x00000000
266
+
267
+ /* Cfgmgr32 dependencies */
268
+ DLL_DECLARE_HANDLE(Cfgmgr32);
269
+ DLL_DECLARE_FUNC(WINAPI, CONFIGRET, CM_Get_Parent, (PDEVINST, DEVINST, ULONG));
270
+ DLL_DECLARE_FUNC(WINAPI, CONFIGRET, CM_Get_Child, (PDEVINST, DEVINST, ULONG));
271
+
272
+ /* AdvAPI32 dependencies */
273
+ DLL_DECLARE_HANDLE(AdvAPI32);
274
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, LONG, p, RegQueryValueExW, (HKEY, LPCWSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD));
275
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, LONG, p, RegCloseKey, (HKEY));
276
+
277
+ /* OLE32 dependency */
278
+ DLL_DECLARE_HANDLE(OLE32);
279
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, HRESULT, p, IIDFromString, (LPCOLESTR, LPIID));
280
+
281
+ /* SetupAPI dependencies */
282
+ DLL_DECLARE_HANDLE(SetupAPI);
283
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, HDEVINFO, p, SetupDiGetClassDevsA, (LPCGUID, PCSTR, HWND, DWORD));
284
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiEnumDeviceInfo, (HDEVINFO, DWORD, PSP_DEVINFO_DATA));
285
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiEnumDeviceInterfaces, (HDEVINFO, PSP_DEVINFO_DATA,
286
+ LPCGUID, DWORD, PSP_DEVICE_INTERFACE_DATA));
287
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiGetDeviceInstanceIdA, (HDEVINFO, PSP_DEVINFO_DATA,
288
+ PCSTR, DWORD, PDWORD));
289
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiGetDeviceInterfaceDetailA, (HDEVINFO, PSP_DEVICE_INTERFACE_DATA,
290
+ PSP_DEVICE_INTERFACE_DETAIL_DATA_A, DWORD, PDWORD, PSP_DEVINFO_DATA));
291
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiGetDeviceRegistryPropertyA, (HDEVINFO,
292
+ PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD));
293
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiDestroyDeviceInfoList, (HDEVINFO));
294
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, HKEY, p, SetupDiOpenDevRegKey, (HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD, REGSAM));
295
+ DLL_DECLARE_FUNC_PREFIXED(WINAPI, HKEY, p, SetupDiOpenDeviceInterfaceRegKey, (HDEVINFO, PSP_DEVICE_INTERFACE_DATA, DWORD, DWORD));
296
+
297
+
298
+ #ifndef USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION
299
+ #define USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION 260
300
+ #endif
301
+ #ifndef USB_GET_NODE_CONNECTION_INFORMATION_EX
302
+ #define USB_GET_NODE_CONNECTION_INFORMATION_EX 274
303
+ #endif
304
+ #ifndef USB_GET_NODE_CONNECTION_INFORMATION_EX_V2
305
+ #define USB_GET_NODE_CONNECTION_INFORMATION_EX_V2 279
306
+ #endif
307
+
308
+ #ifndef FILE_DEVICE_USB
309
+ #define FILE_DEVICE_USB FILE_DEVICE_UNKNOWN
310
+ #endif
311
+
312
+ #define USB_CTL_CODE(id) \
313
+ CTL_CODE(FILE_DEVICE_USB, (id), METHOD_BUFFERED, FILE_ANY_ACCESS)
314
+
315
+ #define IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION \
316
+ USB_CTL_CODE(USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION)
317
+
318
+ #define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX \
319
+ USB_CTL_CODE(USB_GET_NODE_CONNECTION_INFORMATION_EX)
320
+
321
+ #define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX_V2 \
322
+ USB_CTL_CODE(USB_GET_NODE_CONNECTION_INFORMATION_EX_V2)
323
+
324
+ typedef enum USB_CONNECTION_STATUS {
325
+ NoDeviceConnected,
326
+ DeviceConnected,
327
+ DeviceFailedEnumeration,
328
+ DeviceGeneralFailure,
329
+ DeviceCausedOvercurrent,
330
+ DeviceNotEnoughPower,
331
+ DeviceNotEnoughBandwidth,
332
+ DeviceHubNestedTooDeeply,
333
+ DeviceInLegacyHub
334
+ } USB_CONNECTION_STATUS, *PUSB_CONNECTION_STATUS;
335
+
336
+ typedef enum USB_HUB_NODE {
337
+ UsbHub,
338
+ UsbMIParent
339
+ } USB_HUB_NODE;
340
+
341
+ // Most of the structures below need to be packed
342
+ #include <pshpack1.h>
343
+
344
+ typedef struct _USB_DESCRIPTOR_REQUEST {
345
+ ULONG ConnectionIndex;
346
+ struct {
347
+ UCHAR bmRequest;
348
+ UCHAR bRequest;
349
+ USHORT wValue;
350
+ USHORT wIndex;
351
+ USHORT wLength;
352
+ } SetupPacket;
353
+ // UCHAR Data[0];
354
+ } USB_DESCRIPTOR_REQUEST, *PUSB_DESCRIPTOR_REQUEST;
355
+
356
+ typedef struct _USB_CONFIGURATION_DESCRIPTOR_SHORT {
357
+ USB_DESCRIPTOR_REQUEST req;
358
+ USB_CONFIGURATION_DESCRIPTOR desc;
359
+ } USB_CONFIGURATION_DESCRIPTOR_SHORT;
360
+
361
+ typedef struct USB_INTERFACE_DESCRIPTOR {
362
+ UCHAR bLength;
363
+ UCHAR bDescriptorType;
364
+ UCHAR bInterfaceNumber;
365
+ UCHAR bAlternateSetting;
366
+ UCHAR bNumEndpoints;
367
+ UCHAR bInterfaceClass;
368
+ UCHAR bInterfaceSubClass;
369
+ UCHAR bInterfaceProtocol;
370
+ UCHAR iInterface;
371
+ } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
372
+
373
+ typedef struct _USB_NODE_CONNECTION_INFORMATION_EX {
374
+ ULONG ConnectionIndex;
375
+ USB_DEVICE_DESCRIPTOR DeviceDescriptor;
376
+ UCHAR CurrentConfigurationValue;
377
+ UCHAR Speed;
378
+ BOOLEAN DeviceIsHub;
379
+ USHORT DeviceAddress;
380
+ ULONG NumberOfOpenPipes;
381
+ USB_CONNECTION_STATUS ConnectionStatus;
382
+ // USB_PIPE_INFO PipeList[0];
383
+ } USB_NODE_CONNECTION_INFORMATION_EX, *PUSB_NODE_CONNECTION_INFORMATION_EX;
384
+
385
+ typedef union _USB_PROTOCOLS {
386
+ ULONG ul;
387
+ struct {
388
+ ULONG Usb110:1;
389
+ ULONG Usb200:1;
390
+ ULONG Usb300:1;
391
+ ULONG ReservedMBZ:29;
392
+ };
393
+ } USB_PROTOCOLS, *PUSB_PROTOCOLS;
394
+
395
+ typedef union _USB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS {
396
+ ULONG ul;
397
+ struct {
398
+ ULONG DeviceIsOperatingAtSuperSpeedOrHigher:1;
399
+ ULONG DeviceIsSuperSpeedCapableOrHigher:1;
400
+ ULONG DeviceIsOperatingAtSuperSpeedPlusOrHigher:1;
401
+ ULONG DeviceIsSuperSpeedPlusCapableOrHigher:1;
402
+ ULONG ReservedMBZ:28;
403
+ };
404
+ } USB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS, *PUSB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS;
405
+
406
+ typedef struct _USB_NODE_CONNECTION_INFORMATION_EX_V2 {
407
+ ULONG ConnectionIndex;
408
+ ULONG Length;
409
+ USB_PROTOCOLS SupportedUsbProtocols;
410
+ USB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS Flags;
411
+ } USB_NODE_CONNECTION_INFORMATION_EX_V2, *PUSB_NODE_CONNECTION_INFORMATION_EX_V2;
412
+
413
+ #include <poppack.h>
414
+
415
+ /* winusb.dll interface */
416
+
417
+ /* pipe policies */
418
+ #define SHORT_PACKET_TERMINATE 0x01
419
+ #define AUTO_CLEAR_STALL 0x02
420
+ #define PIPE_TRANSFER_TIMEOUT 0x03
421
+ #define IGNORE_SHORT_PACKETS 0x04
422
+ #define ALLOW_PARTIAL_READS 0x05
423
+ #define AUTO_FLUSH 0x06
424
+ #define RAW_IO 0x07
425
+ #define MAXIMUM_TRANSFER_SIZE 0x08
426
+ /* libusbK */
427
+ #define ISO_ALWAYS_START_ASAP 0x21
428
+
429
+ typedef enum _USBD_PIPE_TYPE {
430
+ UsbdPipeTypeControl,
431
+ UsbdPipeTypeIsochronous,
432
+ UsbdPipeTypeBulk,
433
+ UsbdPipeTypeInterrupt
434
+ } USBD_PIPE_TYPE;
435
+
436
+ #include <pshpack1.h>
437
+
438
+ typedef struct _WINUSB_SETUP_PACKET {
439
+ UCHAR RequestType;
440
+ UCHAR Request;
441
+ USHORT Value;
442
+ USHORT Index;
443
+ USHORT Length;
444
+ } WINUSB_SETUP_PACKET, *PWINUSB_SETUP_PACKET;
445
+
446
+ #include <poppack.h>
447
+
448
+ typedef void *WINUSB_INTERFACE_HANDLE, *PWINUSB_INTERFACE_HANDLE;
449
+
450
+ typedef BOOL (WINAPI *WinUsb_AbortPipe_t)(
451
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
452
+ UCHAR PipeID
453
+ );
454
+ typedef BOOL (WINAPI *WinUsb_ControlTransfer_t)(
455
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
456
+ WINUSB_SETUP_PACKET SetupPacket,
457
+ PUCHAR Buffer,
458
+ ULONG BufferLength,
459
+ PULONG LengthTransferred,
460
+ LPOVERLAPPED Overlapped
461
+ );
462
+ typedef BOOL (WINAPI *WinUsb_FlushPipe_t)(
463
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
464
+ UCHAR PipeID
465
+ );
466
+ typedef BOOL (WINAPI *WinUsb_Free_t)(
467
+ WINUSB_INTERFACE_HANDLE InterfaceHandle
468
+ );
469
+ typedef BOOL (WINAPI *WinUsb_GetAssociatedInterface_t)(
470
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
471
+ UCHAR AssociatedInterfaceIndex,
472
+ PWINUSB_INTERFACE_HANDLE AssociatedInterfaceHandle
473
+ );
474
+ typedef BOOL (WINAPI *WinUsb_Initialize_t)(
475
+ HANDLE DeviceHandle,
476
+ PWINUSB_INTERFACE_HANDLE InterfaceHandle
477
+ );
478
+ typedef BOOL (WINAPI *WinUsb_ReadPipe_t)(
479
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
480
+ UCHAR PipeID,
481
+ PUCHAR Buffer,
482
+ ULONG BufferLength,
483
+ PULONG LengthTransferred,
484
+ LPOVERLAPPED Overlapped
485
+ );
486
+ typedef BOOL (WINAPI *WinUsb_ResetDevice_t)(
487
+ WINUSB_INTERFACE_HANDLE InterfaceHandle
488
+ );
489
+ typedef BOOL (WINAPI *WinUsb_ResetPipe_t)(
490
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
491
+ UCHAR PipeID
492
+ );
493
+ typedef BOOL (WINAPI *WinUsb_SetCurrentAlternateSetting_t)(
494
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
495
+ UCHAR AlternateSetting
496
+ );
497
+ typedef BOOL (WINAPI *WinUsb_SetPipePolicy_t)(
498
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
499
+ UCHAR PipeID,
500
+ ULONG PolicyType,
501
+ ULONG ValueLength,
502
+ PVOID Value
503
+ );
504
+ typedef BOOL (WINAPI *WinUsb_WritePipe_t)(
505
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
506
+ UCHAR PipeID,
507
+ PUCHAR Buffer,
508
+ ULONG BufferLength,
509
+ PULONG LengthTransferred,
510
+ LPOVERLAPPED Overlapped
511
+ );
512
+
513
+ typedef PVOID WINUSB_ISOCH_BUFFER_HANDLE, *PWINUSB_ISOCH_BUFFER_HANDLE;
514
+
515
+ typedef BOOL (WINAPI *WinUsb_RegisterIsochBuffer_t)(
516
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
517
+ UCHAR PipeID,
518
+ PVOID Buffer,
519
+ ULONG BufferLength,
520
+ PWINUSB_ISOCH_BUFFER_HANDLE BufferHandle
521
+ );
522
+
523
+ typedef BOOL (WINAPI *WinUsb_UnregisterIsochBuffer_t)(
524
+ WINUSB_ISOCH_BUFFER_HANDLE BufferHandle
525
+ );
526
+
527
+ typedef BOOL (WINAPI *WinUsb_WriteIsochPipeAsap_t)(
528
+ WINUSB_ISOCH_BUFFER_HANDLE BufferHandle,
529
+ ULONG Offset,
530
+ ULONG Length,
531
+ BOOL ContinueStream,
532
+ LPOVERLAPPED Overlapped
533
+ );
534
+
535
+ typedef LONG USBD_STATUS;
536
+ typedef struct {
537
+ ULONG Offset;
538
+ ULONG Length;
539
+ USBD_STATUS Status;
540
+ } USBD_ISO_PACKET_DESCRIPTOR, *PUSBD_ISO_PACKET_DESCRIPTOR;
541
+
542
+ typedef BOOL (WINAPI *WinUsb_ReadIsochPipeAsap_t)(
543
+ PWINUSB_ISOCH_BUFFER_HANDLE BufferHandle,
544
+ ULONG Offset,
545
+ ULONG Length,
546
+ BOOL ContinueStream,
547
+ ULONG NumberOfPackets,
548
+ PUSBD_ISO_PACKET_DESCRIPTOR IsoPacketDescriptors,
549
+ LPOVERLAPPED Overlapped
550
+ );
551
+
552
+ typedef struct {
553
+ USBD_PIPE_TYPE PipeType;
554
+ UCHAR PipeId;
555
+ USHORT MaximumPacketSize;
556
+ UCHAR Interval;
557
+ ULONG MaximumBytesPerInterval;
558
+ } WINUSB_PIPE_INFORMATION_EX, *PWINUSB_PIPE_INFORMATION_EX;
559
+
560
+ typedef BOOL (WINAPI *WinUsb_QueryPipeEx_t)(
561
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
562
+ UCHAR AlternateInterfaceHandle,
563
+ UCHAR PipeIndex,
564
+ PWINUSB_PIPE_INFORMATION_EX PipeInformationEx
565
+ );
566
+
567
+ /* /!\ These must match the ones from the official libusbk.h */
568
+ typedef enum _KUSB_FNID {
569
+ KUSB_FNID_Init,
570
+ KUSB_FNID_Free,
571
+ KUSB_FNID_ClaimInterface,
572
+ KUSB_FNID_ReleaseInterface,
573
+ KUSB_FNID_SetAltInterface,
574
+ KUSB_FNID_GetAltInterface,
575
+ KUSB_FNID_GetDescriptor,
576
+ KUSB_FNID_ControlTransfer,
577
+ KUSB_FNID_SetPowerPolicy,
578
+ KUSB_FNID_GetPowerPolicy,
579
+ KUSB_FNID_SetConfiguration,
580
+ KUSB_FNID_GetConfiguration,
581
+ KUSB_FNID_ResetDevice,
582
+ KUSB_FNID_Initialize,
583
+ KUSB_FNID_SelectInterface,
584
+ KUSB_FNID_GetAssociatedInterface,
585
+ KUSB_FNID_Clone,
586
+ KUSB_FNID_QueryInterfaceSettings,
587
+ KUSB_FNID_QueryDeviceInformation,
588
+ KUSB_FNID_SetCurrentAlternateSetting,
589
+ KUSB_FNID_GetCurrentAlternateSetting,
590
+ KUSB_FNID_QueryPipe,
591
+ KUSB_FNID_SetPipePolicy,
592
+ KUSB_FNID_GetPipePolicy,
593
+ KUSB_FNID_ReadPipe,
594
+ KUSB_FNID_WritePipe,
595
+ KUSB_FNID_ResetPipe,
596
+ KUSB_FNID_AbortPipe,
597
+ KUSB_FNID_FlushPipe,
598
+ KUSB_FNID_IsoReadPipe,
599
+ KUSB_FNID_IsoWritePipe,
600
+ KUSB_FNID_GetCurrentFrameNumber,
601
+ KUSB_FNID_GetOverlappedResult,
602
+ KUSB_FNID_GetProperty,
603
+ KUSB_FNID_COUNT,
604
+ } KUSB_FNID;
605
+
606
+ typedef struct _KLIB_VERSION {
607
+ INT Major;
608
+ INT Minor;
609
+ INT Micro;
610
+ INT Nano;
611
+ } KLIB_VERSION, *PKLIB_VERSION;
612
+
613
+ typedef BOOL (WINAPI *LibK_GetProcAddress_t)(
614
+ PVOID *ProcAddress,
615
+ ULONG DriverID,
616
+ ULONG FunctionID
617
+ );
618
+
619
+ typedef VOID (WINAPI *LibK_GetVersion_t)(
620
+ PKLIB_VERSION Version
621
+ );
622
+
623
+ //KISO_PACKET is equivalent of libusb_iso_packet_descriptor except uses absolute "offset" field instead of sequential Lengths
624
+ typedef struct _KISO_PACKET {
625
+ UINT offset;
626
+ USHORT actual_length; //changed from libusbk_shared.h "Length" for clarity
627
+ USHORT status;
628
+ } KISO_PACKET, *PKISO_PACKET;
629
+
630
+ typedef enum _KISO_FLAG {
631
+ KISO_FLAG_NONE = 0,
632
+ KISO_FLAG_SET_START_FRAME = 0x00000001,
633
+ } KISO_FLAG;
634
+
635
+ //KISO_CONTEXT is the conceptual equivalent of libusb_transfer except is isochronous-specific and must match libusbk's version
636
+ typedef struct _KISO_CONTEXT {
637
+ KISO_FLAG Flags;
638
+ UINT StartFrame;
639
+ SHORT ErrorCount;
640
+ SHORT NumberOfPackets;
641
+ UINT UrbHdrStatus;
642
+ KISO_PACKET IsoPackets[0];
643
+ } KISO_CONTEXT, *PKISO_CONTEXT;
644
+
645
+ typedef BOOL(WINAPI *WinUsb_IsoReadPipe_t)(
646
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
647
+ UCHAR PipeID,
648
+ PUCHAR Buffer,
649
+ ULONG BufferLength,
650
+ LPOVERLAPPED Overlapped,
651
+ PKISO_CONTEXT IsoContext
652
+ );
653
+
654
+ typedef BOOL(WINAPI *WinUsb_IsoWritePipe_t)(
655
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
656
+ UCHAR PipeID,
657
+ PUCHAR Buffer,
658
+ ULONG BufferLength,
659
+ LPOVERLAPPED Overlapped,
660
+ PKISO_CONTEXT IsoContext
661
+ );
662
+
663
+ struct winusb_interface {
664
+ bool initialized;
665
+ bool CancelIoEx_supported;
666
+ WinUsb_AbortPipe_t AbortPipe;
667
+ WinUsb_ControlTransfer_t ControlTransfer;
668
+ WinUsb_FlushPipe_t FlushPipe;
669
+ WinUsb_Free_t Free;
670
+ WinUsb_GetAssociatedInterface_t GetAssociatedInterface;
671
+ WinUsb_Initialize_t Initialize;
672
+ WinUsb_ReadPipe_t ReadPipe;
673
+ WinUsb_ResetDevice_t ResetDevice;
674
+ WinUsb_ResetPipe_t ResetPipe;
675
+ WinUsb_SetCurrentAlternateSetting_t SetCurrentAlternateSetting;
676
+ WinUsb_SetPipePolicy_t SetPipePolicy;
677
+ WinUsb_WritePipe_t WritePipe;
678
+
679
+ // Isochoronous functions for LibUSBk sub api:
680
+ WinUsb_IsoReadPipe_t IsoReadPipe;
681
+ WinUsb_IsoWritePipe_t IsoWritePipe;
682
+
683
+ // Isochronous functions for Microsoft WinUSB sub api (native WinUSB):
684
+ WinUsb_RegisterIsochBuffer_t RegisterIsochBuffer;
685
+ WinUsb_UnregisterIsochBuffer_t UnregisterIsochBuffer;
686
+ WinUsb_WriteIsochPipeAsap_t WriteIsochPipeAsap;
687
+ WinUsb_ReadIsochPipeAsap_t ReadIsochPipeAsap;
688
+ WinUsb_QueryPipeEx_t QueryPipeEx;
689
+ };
690
+
691
+ /* hid.dll interface */
692
+
693
+ #define HIDP_STATUS_SUCCESS 0x110000
694
+ typedef void * PHIDP_PREPARSED_DATA;
695
+
696
+ #include <pshpack1.h>
697
+
698
+ typedef struct _HIDD_ATTIRBUTES {
699
+ ULONG Size;
700
+ USHORT VendorID;
701
+ USHORT ProductID;
702
+ USHORT VersionNumber;
703
+ } HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
704
+
705
+ #include <poppack.h>
706
+
707
+ typedef USHORT USAGE;
708
+ typedef struct _HIDP_CAPS {
709
+ USAGE Usage;
710
+ USAGE UsagePage;
711
+ USHORT InputReportByteLength;
712
+ USHORT OutputReportByteLength;
713
+ USHORT FeatureReportByteLength;
714
+ USHORT Reserved[17];
715
+ USHORT NumberLinkCollectionNodes;
716
+ USHORT NumberInputButtonCaps;
717
+ USHORT NumberInputValueCaps;
718
+ USHORT NumberInputDataIndices;
719
+ USHORT NumberOutputButtonCaps;
720
+ USHORT NumberOutputValueCaps;
721
+ USHORT NumberOutputDataIndices;
722
+ USHORT NumberFeatureButtonCaps;
723
+ USHORT NumberFeatureValueCaps;
724
+ USHORT NumberFeatureDataIndices;
725
+ } HIDP_CAPS, *PHIDP_CAPS;
726
+
727
+ typedef enum _HIDP_REPORT_TYPE {
728
+ HidP_Input,
729
+ HidP_Output,
730
+ HidP_Feature
731
+ } HIDP_REPORT_TYPE;
732
+
733
+ typedef struct _HIDP_VALUE_CAPS {
734
+ USAGE UsagePage;
735
+ UCHAR ReportID;
736
+ BOOLEAN IsAlias;
737
+ USHORT BitField;
738
+ USHORT LinkCollection;
739
+ USAGE LinkUsage;
740
+ USAGE LinkUsagePage;
741
+ BOOLEAN IsRange;
742
+ BOOLEAN IsStringRange;
743
+ BOOLEAN IsDesignatorRange;
744
+ BOOLEAN IsAbsolute;
745
+ BOOLEAN HasNull;
746
+ UCHAR Reserved;
747
+ USHORT BitSize;
748
+ USHORT ReportCount;
749
+ USHORT Reserved2[5];
750
+ ULONG UnitsExp;
751
+ ULONG Units;
752
+ LONG LogicalMin, LogicalMax;
753
+ LONG PhysicalMin, PhysicalMax;
754
+ union {
755
+ struct {
756
+ USAGE UsageMin, UsageMax;
757
+ USHORT StringMin, StringMax;
758
+ USHORT DesignatorMin, DesignatorMax;
759
+ USHORT DataIndexMin, DataIndexMax;
760
+ } Range;
761
+ struct {
762
+ USAGE Usage, Reserved1;
763
+ USHORT StringIndex, Reserved2;
764
+ USHORT DesignatorIndex, Reserved3;
765
+ USHORT DataIndex, Reserved4;
766
+ } NotRange;
767
+ } u;
768
+ } HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS;
769
+
770
+ DLL_DECLARE_HANDLE(hid);
771
+ DLL_DECLARE_FUNC(WINAPI, VOID, HidD_GetHidGuid, (LPGUID));
772
+ DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetAttributes, (HANDLE, PHIDD_ATTRIBUTES));
773
+ DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetPreparsedData, (HANDLE, PHIDP_PREPARSED_DATA *));
774
+ DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_FreePreparsedData, (PHIDP_PREPARSED_DATA));
775
+ DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetManufacturerString, (HANDLE, PVOID, ULONG));
776
+ DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetProductString, (HANDLE, PVOID, ULONG));
777
+ DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetSerialNumberString, (HANDLE, PVOID, ULONG));
778
+ DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetIndexedString, (HANDLE, ULONG, PVOID, ULONG));
779
+ DLL_DECLARE_FUNC(WINAPI, LONG, HidP_GetCaps, (PHIDP_PREPARSED_DATA, PHIDP_CAPS));
780
+ DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_SetNumInputBuffers, (HANDLE, ULONG));
781
+ DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetPhysicalDescriptor, (HANDLE, PVOID, ULONG));
782
+ DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_FlushQueue, (HANDLE));
783
+ DLL_DECLARE_FUNC(WINAPI, BOOL, HidP_GetValueCaps, (HIDP_REPORT_TYPE, PHIDP_VALUE_CAPS, PULONG, PHIDP_PREPARSED_DATA));