usb 2.17.0 → 3.0.0-alpha.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 (207) hide show
  1. package/LICENSE +18 -4
  2. package/README.md +25 -516
  3. package/dist/index.d.ts +67 -13
  4. package/dist/index.js +333 -64
  5. package/index.d.ts +89 -0
  6. package/index.js +583 -0
  7. package/package.json +53 -33
  8. package/CHANGELOG.md +0 -294
  9. package/binding.gyp +0 -128
  10. package/dist/index.js.map +0 -1
  11. package/dist/usb/bindings.d.ts +0 -266
  12. package/dist/usb/bindings.js +0 -10
  13. package/dist/usb/bindings.js.map +0 -1
  14. package/dist/usb/capability.d.ts +0 -13
  15. package/dist/usb/capability.js +0 -17
  16. package/dist/usb/capability.js.map +0 -1
  17. package/dist/usb/descriptors.d.ts +0 -128
  18. package/dist/usb/descriptors.js +0 -3
  19. package/dist/usb/descriptors.js.map +0 -1
  20. package/dist/usb/device.d.ts +0 -100
  21. package/dist/usb/device.js +0 -297
  22. package/dist/usb/device.js.map +0 -1
  23. package/dist/usb/endpoint.d.ts +0 -94
  24. package/dist/usb/endpoint.js +0 -219
  25. package/dist/usb/endpoint.js.map +0 -1
  26. package/dist/usb/index.d.ts +0 -31
  27. package/dist/usb/index.js +0 -116
  28. package/dist/usb/index.js.map +0 -1
  29. package/dist/usb/interface.d.ts +0 -80
  30. package/dist/usb/interface.js +0 -133
  31. package/dist/usb/interface.js.map +0 -1
  32. package/dist/webusb/index.d.ts +0 -64
  33. package/dist/webusb/index.js +0 -295
  34. package/dist/webusb/index.js.map +0 -1
  35. package/dist/webusb/webusb-device.d.ts +0 -54
  36. package/dist/webusb/webusb-device.js +0 -434
  37. package/dist/webusb/webusb-device.js.map +0 -1
  38. package/libusb/.clang-tidy +0 -34
  39. package/libusb/.codespellrc +0 -3
  40. package/libusb/.private/README.txt +0 -5
  41. package/libusb/.private/appveyor_build.sh +0 -26
  42. package/libusb/.private/bm.sh +0 -54
  43. package/libusb/.private/ci-build.sh +0 -92
  44. package/libusb/.private/ci-container-build.sh +0 -67
  45. package/libusb/.private/post-rewrite.sh +0 -32
  46. package/libusb/.private/pre-commit.sh +0 -52
  47. package/libusb/.private/wbs.txt +0 -43
  48. package/libusb/.travis.yml +0 -58
  49. package/libusb/AUTHORS +0 -231
  50. package/libusb/COPYING +0 -504
  51. package/libusb/ChangeLog +0 -365
  52. package/libusb/HACKING +0 -25
  53. package/libusb/INSTALL_WIN.txt +0 -52
  54. package/libusb/KEYS +0 -123
  55. package/libusb/Makefile.am +0 -50
  56. package/libusb/NEWS +0 -2
  57. package/libusb/PORTING +0 -94
  58. package/libusb/README +0 -29
  59. package/libusb/README.git +0 -41
  60. package/libusb/TODO +0 -2
  61. package/libusb/Xcode/common.xcconfig +0 -92
  62. package/libusb/Xcode/config.h +0 -31
  63. package/libusb/Xcode/debug.xcconfig +0 -32
  64. package/libusb/Xcode/libusb.xcconfig +0 -21
  65. package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +0 -1391
  66. package/libusb/Xcode/libusb_debug.xcconfig +0 -21
  67. package/libusb/Xcode/libusb_release.xcconfig +0 -21
  68. package/libusb/Xcode/release.xcconfig +0 -30
  69. package/libusb/android/README +0 -152
  70. package/libusb/android/config.h +0 -55
  71. package/libusb/android/examples/unrooted_android.c +0 -301
  72. package/libusb/android/examples/unrooted_android.h +0 -36
  73. package/libusb/android/jni/Android.mk +0 -23
  74. package/libusb/android/jni/Application.mk +0 -40
  75. package/libusb/android/jni/examples.mk +0 -168
  76. package/libusb/android/jni/libusb.mk +0 -60
  77. package/libusb/android/jni/tests.mk +0 -45
  78. package/libusb/appveyor.yml +0 -108
  79. package/libusb/autogen.sh +0 -10
  80. package/libusb/bootstrap.sh +0 -10
  81. package/libusb/configure.ac +0 -450
  82. package/libusb/doc/Makefile.in +0 -22
  83. package/libusb/doc/doxygen.cfg.in +0 -2571
  84. package/libusb/doc/libusb.png +0 -0
  85. package/libusb/examples/Makefile.am +0 -12
  86. package/libusb/examples/dpfp.c +0 -711
  87. package/libusb/examples/ezusb.c +0 -846
  88. package/libusb/examples/ezusb.h +0 -109
  89. package/libusb/examples/fxload.c +0 -310
  90. package/libusb/examples/hotplugtest.c +0 -147
  91. package/libusb/examples/listdevs.c +0 -73
  92. package/libusb/examples/sam3u_benchmark.c +0 -228
  93. package/libusb/examples/testlibusb.c +0 -312
  94. package/libusb/examples/xusb.c +0 -1254
  95. package/libusb/libusb/Makefile.am +0 -98
  96. package/libusb/libusb/Makefile.am.extra +0 -26
  97. package/libusb/libusb/core.c +0 -2925
  98. package/libusb/libusb/descriptor.c +0 -1558
  99. package/libusb/libusb/hotplug.c +0 -489
  100. package/libusb/libusb/io.c +0 -2865
  101. package/libusb/libusb/libusb-1.0.def +0 -199
  102. package/libusb/libusb/libusb-1.0.rc +0 -53
  103. package/libusb/libusb/libusb.h +0 -2421
  104. package/libusb/libusb/libusbi.h +0 -1535
  105. package/libusb/libusb/os/darwin_usb.c +0 -2977
  106. package/libusb/libusb/os/darwin_usb.h +0 -156
  107. package/libusb/libusb/os/emscripten_webusb.cpp +0 -875
  108. package/libusb/libusb/os/events_posix.c +0 -340
  109. package/libusb/libusb/os/events_posix.h +0 -62
  110. package/libusb/libusb/os/events_windows.c +0 -214
  111. package/libusb/libusb/os/events_windows.h +0 -46
  112. package/libusb/libusb/os/haiku_pollfs.cpp +0 -372
  113. package/libusb/libusb/os/haiku_usb.h +0 -113
  114. package/libusb/libusb/os/haiku_usb_backend.cpp +0 -532
  115. package/libusb/libusb/os/haiku_usb_raw.cpp +0 -231
  116. package/libusb/libusb/os/haiku_usb_raw.h +0 -188
  117. package/libusb/libusb/os/linux_netlink.c +0 -401
  118. package/libusb/libusb/os/linux_udev.c +0 -321
  119. package/libusb/libusb/os/linux_usbfs.c +0 -2829
  120. package/libusb/libusb/os/linux_usbfs.h +0 -221
  121. package/libusb/libusb/os/netbsd_usb.c +0 -617
  122. package/libusb/libusb/os/null_usb.c +0 -111
  123. package/libusb/libusb/os/openbsd_usb.c +0 -700
  124. package/libusb/libusb/os/sunos_usb.c +0 -1619
  125. package/libusb/libusb/os/sunos_usb.h +0 -79
  126. package/libusb/libusb/os/threads_posix.c +0 -126
  127. package/libusb/libusb/os/threads_posix.h +0 -98
  128. package/libusb/libusb/os/threads_windows.c +0 -40
  129. package/libusb/libusb/os/threads_windows.h +0 -113
  130. package/libusb/libusb/os/windows_common.c +0 -923
  131. package/libusb/libusb/os/windows_common.h +0 -424
  132. package/libusb/libusb/os/windows_usbdk.c +0 -724
  133. package/libusb/libusb/os/windows_usbdk.h +0 -106
  134. package/libusb/libusb/os/windows_winusb.c +0 -4766
  135. package/libusb/libusb/os/windows_winusb.h +0 -787
  136. package/libusb/libusb/strerror.c +0 -223
  137. package/libusb/libusb/sync.c +0 -342
  138. package/libusb/libusb/version.h +0 -18
  139. package/libusb/libusb/version_nano.h +0 -1
  140. package/libusb/libusb-1.0.pc.in +0 -11
  141. package/libusb/msvc/Base.props +0 -60
  142. package/libusb/msvc/Configuration.Application.props +0 -7
  143. package/libusb/msvc/Configuration.Base.props +0 -47
  144. package/libusb/msvc/Configuration.DynamicLibrary.props +0 -21
  145. package/libusb/msvc/Configuration.StaticLibrary.props +0 -7
  146. package/libusb/msvc/ProjectConfigurations.Base.props +0 -69
  147. package/libusb/msvc/build_all.ps1 +0 -17
  148. package/libusb/msvc/config.h +0 -58
  149. package/libusb/msvc/dpfp.vcxproj +0 -33
  150. package/libusb/msvc/dpfp_threaded.vcxproj +0 -38
  151. package/libusb/msvc/fxload.vcxproj +0 -46
  152. package/libusb/msvc/getopt/getopt.c +0 -1060
  153. package/libusb/msvc/getopt/getopt.h +0 -180
  154. package/libusb/msvc/getopt/getopt1.c +0 -188
  155. package/libusb/msvc/getopt.vcxproj +0 -33
  156. package/libusb/msvc/hotplugtest.vcxproj +0 -32
  157. package/libusb/msvc/init_context.vcxproj +0 -35
  158. package/libusb/msvc/libusb.sln +0 -542
  159. package/libusb/msvc/libusb_dll.vcxproj +0 -61
  160. package/libusb/msvc/libusb_static.vcxproj +0 -49
  161. package/libusb/msvc/listdevs.vcxproj +0 -32
  162. package/libusb/msvc/sam3u_benchmark.vcxproj +0 -33
  163. package/libusb/msvc/set_option.vcxproj +0 -35
  164. package/libusb/msvc/stress.vcxproj +0 -35
  165. package/libusb/msvc/stress_mt.vcxproj +0 -33
  166. package/libusb/msvc/testlibusb.vcxproj +0 -32
  167. package/libusb/msvc/xusb.vcxproj +0 -38
  168. package/libusb/tests/Makefile.am +0 -40
  169. package/libusb/tests/init_context.c +0 -153
  170. package/libusb/tests/libusb_testlib.h +0 -76
  171. package/libusb/tests/macos.c +0 -130
  172. package/libusb/tests/set_option.c +0 -253
  173. package/libusb/tests/stress.c +0 -172
  174. package/libusb/tests/stress_mt.c +0 -267
  175. package/libusb/tests/testlib.c +0 -184
  176. package/libusb/tests/umockdev.c +0 -1175
  177. package/libusb/tests/webusb-test-shim/index.js +0 -12
  178. package/libusb/tests/webusb-test-shim/package-lock.json +0 -50
  179. package/libusb/tests/webusb-test-shim/package.json +0 -10
  180. package/libusb.gypi +0 -154
  181. package/libusb_config/config.h +0 -1
  182. package/prebuilds/android-arm/node.napi.armv7.node +0 -0
  183. package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
  184. package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
  185. package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
  186. package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
  187. package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
  188. package/prebuilds/linux-ia32/node.napi.node +0 -0
  189. package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  190. package/prebuilds/linux-x64/node.napi.musl.node +0 -0
  191. package/prebuilds/win32-arm64/node.napi.node +0 -0
  192. package/prebuilds/win32-ia32/node.napi.node +0 -0
  193. package/prebuilds/win32-x64/node.napi.node +0 -0
  194. package/src/device.cc +0 -439
  195. package/src/helpers.h +0 -64
  196. package/src/hotplug/hotplug.h +0 -22
  197. package/src/hotplug/libusb.cc +0 -90
  198. package/src/hotplug/windows.cc +0 -168
  199. package/src/node_usb.cc +0 -314
  200. package/src/node_usb.h +0 -131
  201. package/src/thread_name.cc +0 -79
  202. package/src/thread_name.h +0 -11
  203. package/src/transfer.cc +0 -143
  204. package/src/uv_async_queue.h +0 -41
  205. package/test/usb.coffee +0 -250
  206. package/test/webusb.coffee +0 -227
  207. package/test/worker.cjs +0 -13
@@ -1,424 +0,0 @@
1
- /*
2
- * Windows backend common header for libusb 1.0
3
- *
4
- * This file brings together header code common between
5
- * the desktop Windows backends.
6
- * Copyright © 2012-2013 RealVNC Ltd.
7
- * Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
8
- * Copyright © 2014-2020 Chris Dickens <christopher.a.dickens@gmail.com>
9
- * With contributions from Michael Plante, Orin Eman et al.
10
- * Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
11
- * Major code testing contribution by Xiaofan Chen
12
- *
13
- * This library is free software; you can redistribute it and/or
14
- * modify it under the terms of the GNU Lesser General Public
15
- * License as published by the Free Software Foundation; either
16
- * version 2.1 of the License, or (at your option) any later version.
17
- *
18
- * This library is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
- * Lesser General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU Lesser General Public
24
- * License along with this library; if not, write to the Free Software
25
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26
- */
27
-
28
- #ifndef LIBUSB_WINDOWS_COMMON_H
29
- #define LIBUSB_WINDOWS_COMMON_H
30
-
31
- #include <stdbool.h>
32
-
33
- /*
34
- * Workaround for the mess that exists with the DWORD and ULONG types.
35
- * Visual Studio unconditionally defines these types as 'unsigned long'
36
- * and a long is always 32-bits, even on 64-bit builds. GCC on the other
37
- * hand varies the width of a long, matching it to the build. To make
38
- * matters worse, the platform headers for these GCC builds define a
39
- * DWORD/ULONG to be 'unsigned long' on 32-bit builds and 'unsigned int'
40
- * on 64-bit builds. This creates a great deal of warnings for compilers
41
- * that support printf format checking since it will never actually be
42
- * an unsigned long.
43
- */
44
- #if defined(_MSC_VER)
45
- #define ULONG_CAST(x) (x)
46
- #else
47
- #define ULONG_CAST(x) ((unsigned long)(x))
48
- #endif
49
-
50
- #if defined(__CYGWIN__)
51
- #define _stricmp strcasecmp
52
- #define _strdup strdup
53
- // _beginthreadex is MSVCRT => unavailable for cygwin. Fallback to using CreateThread
54
- #define _beginthreadex(a, b, c, d, e, f) CreateThread(a, b, (LPTHREAD_START_ROUTINE)c, d, e, (LPDWORD)f)
55
- #else
56
- #include <process.h>
57
- #endif
58
-
59
- #define safe_free(p) do {if (p != NULL) {free((void *)p); p = NULL;}} while (0)
60
-
61
- /*
62
- * API macros - leveraged from libusb-win32 1.x
63
- */
64
- #define DLL_STRINGIFY(s) #s
65
-
66
- /*
67
- * Macros for handling DLL themselves
68
- */
69
- #define DLL_HANDLE_NAME(name) __dll_##name##_handle
70
-
71
- #define DLL_DECLARE_HANDLE(name) \
72
- static HMODULE DLL_HANDLE_NAME(name)
73
-
74
- #define DLL_GET_HANDLE(ctx, name) \
75
- do { \
76
- DLL_HANDLE_NAME(name) = load_system_library(ctx, \
77
- DLL_STRINGIFY(name)); \
78
- if (!DLL_HANDLE_NAME(name)) \
79
- return false; \
80
- } while (0)
81
-
82
- #define DLL_FREE_HANDLE(name) \
83
- do { \
84
- if (DLL_HANDLE_NAME(name)) { \
85
- FreeLibrary(DLL_HANDLE_NAME(name)); \
86
- DLL_HANDLE_NAME(name) = NULL; \
87
- } \
88
- } while (0)
89
-
90
- /*
91
- * Macros for handling functions within a DLL
92
- */
93
- #define DLL_FUNC_NAME(name) __dll_##name##_func_t
94
-
95
- #define DLL_DECLARE_FUNC_PREFIXNAME(api, ret, prefixname, name, args) \
96
- typedef ret (api * DLL_FUNC_NAME(name))args; \
97
- static DLL_FUNC_NAME(name) prefixname
98
-
99
- #define DLL_DECLARE_FUNC(api, ret, name, args) \
100
- DLL_DECLARE_FUNC_PREFIXNAME(api, ret, name, name, args)
101
- #define DLL_DECLARE_FUNC_PREFIXED(api, ret, prefix, name, args) \
102
- DLL_DECLARE_FUNC_PREFIXNAME(api, ret, prefix##name, name, args)
103
-
104
- #define DLL_LOAD_FUNC_PREFIXNAME(dll, prefixname, name, ret_on_failure) \
105
- do { \
106
- HMODULE h = DLL_HANDLE_NAME(dll); \
107
- prefixname = (DLL_FUNC_NAME(name))GetProcAddress(h, \
108
- DLL_STRINGIFY(name)); \
109
- if (prefixname) \
110
- break; \
111
- prefixname = (DLL_FUNC_NAME(name))GetProcAddress(h, \
112
- DLL_STRINGIFY(name) DLL_STRINGIFY(A)); \
113
- if (prefixname) \
114
- break; \
115
- prefixname = (DLL_FUNC_NAME(name))GetProcAddress(h, \
116
- DLL_STRINGIFY(name) DLL_STRINGIFY(W)); \
117
- if (prefixname) \
118
- break; \
119
- if (ret_on_failure) \
120
- return false; \
121
- } while (0)
122
-
123
- #define DLL_LOAD_FUNC(dll, name, ret_on_failure) \
124
- DLL_LOAD_FUNC_PREFIXNAME(dll, name, name, ret_on_failure)
125
- #define DLL_LOAD_FUNC_PREFIXED(dll, prefix, name, ret_on_failure) \
126
- DLL_LOAD_FUNC_PREFIXNAME(dll, prefix##name, name, ret_on_failure)
127
-
128
- // https://msdn.microsoft.com/en-us/library/windows/hardware/ff539136(v=vs.85).aspx
129
- #if !defined(USBD_SUCCESS)
130
- typedef LONG USBD_STATUS;
131
-
132
- #define USBD_SUCCESS(Status) ((USBD_STATUS)(Status) >= 0)
133
-
134
- #define USBD_STATUS_STALL_PID ((USBD_STATUS)0xC0000004L)
135
- #define USBD_STATUS_ENDPOINT_HALTED ((USBD_STATUS)0xC0000030L)
136
- #define USBD_STATUS_TIMEOUT ((USBD_STATUS)0xC0006000L)
137
- #define USBD_STATUS_DEVICE_GONE ((USBD_STATUS)0xC0007000L)
138
- #define USBD_STATUS_CANCELED ((USBD_STATUS)0xC0010000L)
139
- #endif
140
-
141
- // error code added with Windows SDK 10.0.18362
142
- #ifndef ERROR_NO_SUCH_DEVICE
143
- #define ERROR_NO_SUCH_DEVICE 433L
144
- #endif
145
-
146
- /* Windows versions */
147
- enum windows_version {
148
- WINDOWS_UNDEFINED,
149
- WINDOWS_2000,
150
- WINDOWS_XP,
151
- WINDOWS_2003, // Also XP x64
152
- WINDOWS_VISTA,
153
- WINDOWS_7,
154
- WINDOWS_8,
155
- WINDOWS_8_1,
156
- WINDOWS_10,
157
- WINDOWS_11,
158
- WINDOWS_12_OR_LATER
159
- };
160
-
161
- extern enum windows_version windows_version;
162
-
163
- #include <pshpack1.h>
164
-
165
- typedef struct USB_DEVICE_DESCRIPTOR {
166
- UCHAR bLength;
167
- UCHAR bDescriptorType;
168
- USHORT bcdUSB;
169
- UCHAR bDeviceClass;
170
- UCHAR bDeviceSubClass;
171
- UCHAR bDeviceProtocol;
172
- UCHAR bMaxPacketSize0;
173
- USHORT idVendor;
174
- USHORT idProduct;
175
- USHORT bcdDevice;
176
- UCHAR iManufacturer;
177
- UCHAR iProduct;
178
- UCHAR iSerialNumber;
179
- UCHAR bNumConfigurations;
180
- } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
181
-
182
- typedef struct USB_CONFIGURATION_DESCRIPTOR {
183
- UCHAR bLength;
184
- UCHAR bDescriptorType;
185
- USHORT wTotalLength;
186
- UCHAR bNumInterfaces;
187
- UCHAR bConfigurationValue;
188
- UCHAR iConfiguration;
189
- UCHAR bmAttributes;
190
- UCHAR MaxPower;
191
- } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
192
-
193
- #include <poppack.h>
194
-
195
- #define MAX_DEVICE_ID_LEN 200
196
-
197
- typedef struct USB_DK_DEVICE_ID {
198
- WCHAR DeviceID[MAX_DEVICE_ID_LEN];
199
- WCHAR InstanceID[MAX_DEVICE_ID_LEN];
200
- } USB_DK_DEVICE_ID, *PUSB_DK_DEVICE_ID;
201
-
202
- typedef struct USB_DK_DEVICE_INFO {
203
- USB_DK_DEVICE_ID ID;
204
- ULONG64 FilterID;
205
- ULONG64 Port;
206
- ULONG64 Speed;
207
- USB_DEVICE_DESCRIPTOR DeviceDescriptor;
208
- } USB_DK_DEVICE_INFO, *PUSB_DK_DEVICE_INFO;
209
-
210
- typedef struct USB_DK_ISO_TRANSFER_RESULT {
211
- ULONG64 ActualLength;
212
- ULONG64 TransferResult;
213
- } USB_DK_ISO_TRANSFER_RESULT, *PUSB_DK_ISO_TRANSFER_RESULT;
214
-
215
- typedef struct USB_DK_GEN_TRANSFER_RESULT {
216
- ULONG64 BytesTransferred;
217
- ULONG64 UsbdStatus; // USBD_STATUS code
218
- } USB_DK_GEN_TRANSFER_RESULT, *PUSB_DK_GEN_TRANSFER_RESULT;
219
-
220
- typedef struct USB_DK_TRANSFER_RESULT {
221
- USB_DK_GEN_TRANSFER_RESULT GenResult;
222
- PVOID64 IsochronousResultsArray; // array of USB_DK_ISO_TRANSFER_RESULT
223
- } USB_DK_TRANSFER_RESULT, *PUSB_DK_TRANSFER_RESULT;
224
-
225
- typedef struct USB_DK_TRANSFER_REQUEST {
226
- ULONG64 EndpointAddress;
227
- PVOID64 Buffer;
228
- ULONG64 BufferLength;
229
- ULONG64 TransferType;
230
- ULONG64 IsochronousPacketsArraySize;
231
- PVOID64 IsochronousPacketsArray;
232
- USB_DK_TRANSFER_RESULT Result;
233
- } USB_DK_TRANSFER_REQUEST, *PUSB_DK_TRANSFER_REQUEST;
234
-
235
- struct usbdk_device_priv {
236
- USB_DK_DEVICE_ID ID;
237
- PUSB_CONFIGURATION_DESCRIPTOR *config_descriptors;
238
- HANDLE redirector_handle;
239
- HANDLE system_handle;
240
- uint8_t active_configuration;
241
- };
242
-
243
- struct winusb_device_priv {
244
- bool initialized;
245
- bool root_hub;
246
- uint8_t active_config;
247
- uint8_t depth; // distance to HCD
248
- const struct windows_usb_api_backend *apib;
249
- char *dev_id;
250
- char *path; // device interface path
251
- int sub_api; // for WinUSB-like APIs
252
- struct {
253
- char *path; // each interface needs a device interface path,
254
- const struct windows_usb_api_backend *apib; // an API backend (multiple drivers support),
255
- int sub_api;
256
- int8_t nb_endpoints; // and a set of endpoint addresses (USB_MAXENDPOINTS)
257
- uint8_t *endpoint;
258
- int current_altsetting;
259
- bool restricted_functionality; // indicates if the interface functionality is restricted
260
- // by Windows (eg. HID keyboards or mice cannot do R/W)
261
- uint8_t num_associated_interfaces; // If non-zero, the interface is part of a grouped
262
- // set of associated interfaces (defined by an IAD)
263
- // and this is the number of interfaces within the
264
- // associated group (bInterfaceCount in IAD).
265
- uint8_t first_associated_interface; // For associated interfaces, this is the index of
266
- // the first interface (bFirstInterface in IAD) for
267
- // the grouped set of associated interfaces.
268
- } usb_interface[USB_MAXINTERFACES];
269
- struct hid_device_priv *hid;
270
- PUSB_CONFIGURATION_DESCRIPTOR *config_descriptor; // list of pointers to the cached config descriptors
271
- GUID class_guid; // checked for change during re-enumeration
272
- };
273
-
274
- struct usbdk_device_handle_priv {
275
- // Not currently used
276
- char dummy;
277
- };
278
-
279
- enum WINUSB_ZLP {
280
- WINUSB_ZLP_UNSET = 0,
281
- WINUSB_ZLP_OFF = 1,
282
- WINUSB_ZLP_ON = 2
283
- };
284
-
285
- struct winusb_device_handle_priv {
286
- int active_interface;
287
- struct {
288
- HANDLE dev_handle; // WinUSB needs an extra handle for the file
289
- HANDLE api_handle; // used by the API to communicate with the device
290
- uint8_t zlp[USB_MAXENDPOINTS]; // Current per-endpoint SHORT_PACKET_TERMINATE status (enum WINUSB_ZLP)
291
- } interface_handle[USB_MAXINTERFACES];
292
- int autoclaim_count[USB_MAXINTERFACES]; // For auto-release
293
- };
294
-
295
- struct usbdk_transfer_priv {
296
- USB_DK_TRANSFER_REQUEST request;
297
- PULONG64 IsochronousPacketsArray;
298
- PUSB_DK_ISO_TRANSFER_RESULT IsochronousResultsArray;
299
- };
300
-
301
- struct winusb_transfer_priv {
302
- uint8_t interface_number;
303
-
304
- uint8_t *hid_buffer; // 1 byte extended data buffer, required for HID
305
- uint8_t *hid_dest; // transfer buffer destination, required for HID
306
- size_t hid_expected_size;
307
-
308
- // For isochronous transfers with LibUSBk driver:
309
- void *iso_context;
310
-
311
- // For isochronous transfers with Microsoft WinUSB driver:
312
- void *isoch_buffer_handle; // The isoch_buffer_handle to free at the end of the transfer
313
- BOOL iso_break_stream; // Whether the isoch. stream was to be continued in the last call of libusb_submit_transfer.
314
- // As we this structure is zeroed out upon initialization, we need to use inverse logic here.
315
- libusb_transfer_cb_fn iso_user_callback; // Original transfer callback of the user. Might be used for isochronous transfers.
316
- };
317
-
318
- struct windows_backend {
319
- int (*init)(struct libusb_context *ctx);
320
- void (*exit)(struct libusb_context *ctx);
321
- int (*get_device_list)(struct libusb_context *ctx,
322
- struct discovered_devs **discdevs);
323
- int (*open)(struct libusb_device_handle *dev_handle);
324
- void (*close)(struct libusb_device_handle *dev_handle);
325
- int (*get_active_config_descriptor)(struct libusb_device *device,
326
- void *buffer, size_t len);
327
- int (*get_config_descriptor)(struct libusb_device *device,
328
- uint8_t config_index, void *buffer, size_t len);
329
- int (*get_config_descriptor_by_value)(struct libusb_device *device,
330
- uint8_t bConfigurationValue, void **buffer);
331
- int (*get_configuration)(struct libusb_device_handle *dev_handle, uint8_t *config);
332
- int (*set_configuration)(struct libusb_device_handle *dev_handle, uint8_t config);
333
- int (*claim_interface)(struct libusb_device_handle *dev_handle, uint8_t interface_number);
334
- int (*release_interface)(struct libusb_device_handle *dev_handle, uint8_t interface_number);
335
- int (*set_interface_altsetting)(struct libusb_device_handle *dev_handle,
336
- uint8_t interface_number, uint8_t altsetting);
337
- int (*clear_halt)(struct libusb_device_handle *dev_handle,
338
- unsigned char endpoint);
339
- int (*reset_device)(struct libusb_device_handle *dev_handle);
340
- void (*destroy_device)(struct libusb_device *dev);
341
- int (*submit_transfer)(struct usbi_transfer *itransfer);
342
- int (*cancel_transfer)(struct usbi_transfer *itransfer);
343
- void (*clear_transfer_priv)(struct usbi_transfer *itransfer);
344
- enum libusb_transfer_status (*copy_transfer_data)(struct usbi_transfer *itransfer, DWORD length);
345
- };
346
-
347
- struct windows_context_priv {
348
- const struct windows_backend *backend;
349
- HANDLE completion_port;
350
- HANDLE completion_port_thread;
351
- };
352
-
353
- union windows_device_priv {
354
- struct usbdk_device_priv usbdk_priv;
355
- struct winusb_device_priv winusb_priv;
356
- };
357
-
358
- struct windows_device_handle_priv {
359
- struct list_head active_transfers;
360
- union {
361
- struct usbdk_device_handle_priv usbdk_priv;
362
- struct winusb_device_handle_priv winusb_priv;
363
- };
364
- };
365
-
366
- struct windows_transfer_priv {
367
- OVERLAPPED overlapped;
368
- HANDLE handle;
369
- struct list_head list;
370
- union {
371
- struct usbdk_transfer_priv usbdk_priv;
372
- struct winusb_transfer_priv winusb_priv;
373
- };
374
- };
375
-
376
- static inline struct usbdk_device_handle_priv *get_usbdk_device_handle_priv(struct libusb_device_handle *dev_handle)
377
- {
378
- struct windows_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
379
- return &handle_priv->usbdk_priv;
380
- }
381
-
382
- static inline struct winusb_device_handle_priv *get_winusb_device_handle_priv(struct libusb_device_handle *dev_handle)
383
- {
384
- struct windows_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
385
- return &handle_priv->winusb_priv;
386
- }
387
-
388
- static inline OVERLAPPED *get_transfer_priv_overlapped(struct usbi_transfer *itransfer)
389
- {
390
- struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
391
- return &transfer_priv->overlapped;
392
- }
393
-
394
- static inline void set_transfer_priv_handle(struct usbi_transfer *itransfer, HANDLE handle)
395
- {
396
- struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
397
- transfer_priv->handle = handle;
398
- }
399
-
400
- static inline struct usbdk_transfer_priv *get_usbdk_transfer_priv(struct usbi_transfer *itransfer)
401
- {
402
- struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
403
- return &transfer_priv->usbdk_priv;
404
- }
405
-
406
- static inline struct winusb_transfer_priv *get_winusb_transfer_priv(struct usbi_transfer *itransfer)
407
- {
408
- struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
409
- return &transfer_priv->winusb_priv;
410
- }
411
-
412
- extern const struct windows_backend usbdk_backend;
413
- extern const struct windows_backend winusb_backend;
414
-
415
- HMODULE load_system_library(struct libusb_context *ctx, const char *name);
416
- unsigned long htab_hash(const char *str);
417
- enum libusb_transfer_status usbd_status_to_libusb_transfer_status(USBD_STATUS status);
418
- void windows_force_sync_completion(struct usbi_transfer *itransfer, ULONG size);
419
-
420
- #if defined(ENABLE_LOGGING)
421
- const char *windows_error_str(DWORD error_code);
422
- #endif
423
-
424
- #endif