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,787 +0,0 @@
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
- #ifndef LIBUSB_WINDOWS_WINUSB_H
24
- #define LIBUSB_WINDOWS_WINUSB_H
25
-
26
- #include <devioctl.h>
27
- #include <initguid.h>
28
- #include <usbiodef.h>
29
-
30
- #include "windows_common.h"
31
-
32
- #define MAX_CTRL_BUFFER_LENGTH 4096
33
- #define MAX_USB_STRING_LENGTH 128
34
- #define MAX_HID_REPORT_SIZE 1024
35
- #define MAX_HID_DESCRIPTOR_SIZE 256
36
- #define MAX_GUID_STRING_LENGTH 39
37
- #define MAX_PATH_LENGTH 256
38
- #define MAX_KEY_LENGTH 256
39
- #define LIST_SEPARATOR ';'
40
-
41
- // Handle code for HID interface that have been claimed ("dibs")
42
- #define INTERFACE_CLAIMED ((HANDLE)(intptr_t)0xD1B5)
43
- // Additional return code for HID operations that completed synchronously
44
- #define LIBUSB_COMPLETED (LIBUSB_SUCCESS + 1)
45
-
46
- // libusb0 Filter Device Interface GUID
47
- DEFINE_GUID(GUID_DEVINTERFACE_LIBUSB0_FILTER, 0xF9F3FF14, 0xAE21, 0x48A0, 0x8A, 0x25, 0x80, 0x11, 0xA7, 0xA9, 0x31, 0xD9);
48
-
49
- // The following define MUST be == sizeof(USB_DESCRIPTOR_REQUEST)
50
- #define USB_DESCRIPTOR_REQUEST_SIZE 12U
51
-
52
- /*
53
- * Multiple USB API backend support
54
- */
55
- #define USB_API_UNSUPPORTED 0
56
- #define USB_API_HUB 1
57
- #define USB_API_COMPOSITE 2
58
- #define USB_API_WINUSBX 3
59
- #define USB_API_HID 4
60
- #define USB_API_MAX 5
61
-
62
- // Sub-APIs for WinUSB-like driver APIs (WinUSB, libusbK, libusb-win32 through the libusbK DLL)
63
- // Must have the same values as the KUSB_DRVID enum from libusbk.h
64
- #define SUB_API_NOTSET -1
65
- #define SUB_API_LIBUSBK 0
66
- #define SUB_API_LIBUSB0 1
67
- #define SUB_API_WINUSB 2
68
- #define SUB_API_MAX 3
69
-
70
- struct windows_usb_api_backend {
71
- const uint8_t id;
72
- const char * const designation;
73
- const char * const * const driver_name_list; // Driver name, without .sys, e.g. "usbccgp"
74
- const uint8_t nb_driver_names;
75
- bool (*init)(struct libusb_context *ctx);
76
- void (*exit)(void);
77
- int (*open)(int sub_api, struct libusb_device_handle *dev_handle);
78
- void (*close)(int sub_api, struct libusb_device_handle *dev_handle);
79
- int (*configure_endpoints)(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
80
- int (*claim_interface)(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
81
- int (*set_interface_altsetting)(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting);
82
- int (*release_interface)(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
83
- int (*clear_halt)(int sub_api, struct libusb_device_handle *dev_handle, unsigned char endpoint);
84
- int (*reset_device)(int sub_api, struct libusb_device_handle *dev_handle);
85
- int (*submit_bulk_transfer)(int sub_api, struct usbi_transfer *itransfer);
86
- int (*submit_iso_transfer)(int sub_api, struct usbi_transfer *itransfer);
87
- int (*submit_control_transfer)(int sub_api, struct usbi_transfer *itransfer);
88
- int (*cancel_transfer)(int sub_api, struct usbi_transfer *itransfer);
89
- enum libusb_transfer_status (*copy_transfer_data)(int sub_api, struct usbi_transfer *itransfer, DWORD length);
90
- };
91
-
92
- extern const struct windows_usb_api_backend usb_api_backend[USB_API_MAX];
93
-
94
- #define PRINT_UNSUPPORTED_API(fname) \
95
- usbi_dbg(NULL, "unsupported API call for '%s' " \
96
- "(unrecognized device driver)", #fname)
97
-
98
- #define CHECK_SUPPORTED_API(apip, fname) \
99
- do { \
100
- if ((apip)->fname == NULL) { \
101
- PRINT_UNSUPPORTED_API(fname); \
102
- return LIBUSB_ERROR_NOT_SUPPORTED; \
103
- } \
104
- } while (0)
105
-
106
- /*
107
- * private structures definition
108
- * with inline pseudo constructors/destructors
109
- */
110
-
111
- // TODO (v2+): move hid desc to libusb.h?
112
- struct libusb_hid_descriptor {
113
- uint8_t bLength;
114
- uint8_t bDescriptorType;
115
- uint16_t bcdHID;
116
- uint8_t bCountryCode;
117
- uint8_t bNumDescriptors;
118
- uint8_t bClassDescriptorType;
119
- uint16_t wClassDescriptorLength;
120
- };
121
-
122
- #define LIBUSB_DT_HID_SIZE 9
123
- #define HID_MAX_CONFIG_DESC_SIZE (LIBUSB_DT_CONFIG_SIZE + LIBUSB_DT_INTERFACE_SIZE \
124
- + LIBUSB_DT_HID_SIZE + 2 * LIBUSB_DT_ENDPOINT_SIZE)
125
- #define HID_MAX_REPORT_SIZE 1024
126
- #define HID_IN_EP 0x81
127
- #define HID_OUT_EP 0x02
128
- #define LIBUSB_REQ_RECIPIENT(request_type) ((request_type) & 0x1F)
129
- #define LIBUSB_REQ_TYPE(request_type) ((request_type) & (0x03 << 5))
130
- #define LIBUSB_REQ_IN(request_type) ((request_type) & LIBUSB_ENDPOINT_IN)
131
- #define LIBUSB_REQ_OUT(request_type) (!LIBUSB_REQ_IN(request_type))
132
-
133
- // The following are used for HID reports IOCTLs
134
- #define HID_IN_CTL_CODE(id) \
135
- CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_IN_DIRECT, FILE_ANY_ACCESS)
136
- #define HID_OUT_CTL_CODE(id) \
137
- CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
138
-
139
- #define IOCTL_HID_GET_FEATURE HID_OUT_CTL_CODE(100)
140
- #define IOCTL_HID_GET_INPUT_REPORT HID_OUT_CTL_CODE(104)
141
- #define IOCTL_HID_SET_FEATURE HID_IN_CTL_CODE(100)
142
- #define IOCTL_HID_SET_OUTPUT_REPORT HID_IN_CTL_CODE(101)
143
-
144
- enum libusb_hid_request_type {
145
- HID_REQ_GET_REPORT = 0x01,
146
- HID_REQ_GET_IDLE = 0x02,
147
- HID_REQ_GET_PROTOCOL = 0x03,
148
- HID_REQ_SET_REPORT = 0x09,
149
- HID_REQ_SET_IDLE = 0x0A,
150
- HID_REQ_SET_PROTOCOL = 0x0B
151
- };
152
-
153
- enum libusb_hid_report_type {
154
- HID_REPORT_TYPE_INPUT = 0x01,
155
- HID_REPORT_TYPE_OUTPUT = 0x02,
156
- HID_REPORT_TYPE_FEATURE = 0x03
157
- };
158
-
159
- struct hid_device_priv {
160
- uint16_t vid;
161
- uint16_t pid;
162
- uint8_t config;
163
- uint8_t nb_interfaces;
164
- bool uses_report_ids[3]; // input, ouptput, feature
165
- uint16_t input_report_size;
166
- uint16_t output_report_size;
167
- uint16_t feature_report_size;
168
- uint16_t usage;
169
- uint16_t usagePage;
170
- WCHAR string[3][MAX_USB_STRING_LENGTH];
171
- uint8_t string_index[3]; // man, prod, ser
172
- };
173
-
174
- static inline struct winusb_device_priv *winusb_device_priv_init(struct libusb_device *dev)
175
- {
176
- struct winusb_device_priv *priv = usbi_get_device_priv(dev);
177
- int i;
178
-
179
- priv->apib = &usb_api_backend[USB_API_UNSUPPORTED];
180
- priv->sub_api = SUB_API_NOTSET;
181
- for (i = 0; i < USB_MAXINTERFACES; i++) {
182
- priv->usb_interface[i].apib = &usb_api_backend[USB_API_UNSUPPORTED];
183
- priv->usb_interface[i].sub_api = SUB_API_NOTSET;
184
- }
185
-
186
- return priv;
187
- }
188
-
189
- static inline void winusb_device_priv_release(struct libusb_device *dev)
190
- {
191
- struct winusb_device_priv *priv = usbi_get_device_priv(dev);
192
- int i;
193
-
194
- free(priv->dev_id);
195
- free(priv->path);
196
- if ((dev->device_descriptor.bNumConfigurations > 0) && (priv->config_descriptor != NULL)) {
197
- for (i = 0; i < dev->device_descriptor.bNumConfigurations; i++) {
198
- if (priv->config_descriptor[i] == NULL)
199
- continue;
200
- free((UCHAR *)priv->config_descriptor[i] - USB_DESCRIPTOR_REQUEST_SIZE);
201
- }
202
- }
203
- free(priv->config_descriptor);
204
- free(priv->hid);
205
- for (i = 0; i < USB_MAXINTERFACES; i++) {
206
- free(priv->usb_interface[i].path);
207
- free(priv->usb_interface[i].endpoint);
208
- }
209
- }
210
-
211
- // used to match a device driver (including filter drivers) against a supported API
212
- struct driver_lookup {
213
- char list[MAX_KEY_LENGTH + 1]; // REG_MULTI_SZ list of services (driver) names
214
- const DWORD reg_prop; // SPDRP registry key to use to retrieve list
215
- const char *designation; // internal designation (for debug output)
216
- };
217
-
218
- /*
219
- * Windows DDK API definitions. Most of it copied from MinGW's includes
220
- */
221
- typedef DWORD DEVNODE, DEVINST;
222
- typedef DEVNODE *PDEVNODE, *PDEVINST;
223
- typedef DWORD RETURN_TYPE;
224
- typedef RETURN_TYPE CONFIGRET;
225
-
226
- #define CR_SUCCESS 0x00000000
227
-
228
- /* Cfgmgr32 dependencies */
229
- DLL_DECLARE_HANDLE(Cfgmgr32);
230
- DLL_DECLARE_FUNC(WINAPI, CONFIGRET, CM_Get_Parent, (PDEVINST, DEVINST, ULONG));
231
- DLL_DECLARE_FUNC(WINAPI, CONFIGRET, CM_Get_Child, (PDEVINST, DEVINST, ULONG));
232
-
233
- /* AdvAPI32 dependencies */
234
- DLL_DECLARE_HANDLE(AdvAPI32);
235
- DLL_DECLARE_FUNC_PREFIXED(WINAPI, LONG, p, RegQueryValueExA, (HKEY, LPCSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD));
236
- DLL_DECLARE_FUNC_PREFIXED(WINAPI, LONG, p, RegCloseKey, (HKEY));
237
-
238
- /* SetupAPI dependencies */
239
- DLL_DECLARE_HANDLE(SetupAPI);
240
- DLL_DECLARE_FUNC_PREFIXED(WINAPI, HDEVINFO, p, SetupDiGetClassDevsA, (LPCGUID, PCSTR, HWND, DWORD));
241
- DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiEnumDeviceInfo, (HDEVINFO, DWORD, PSP_DEVINFO_DATA));
242
- DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiEnumDeviceInterfaces, (HDEVINFO, PSP_DEVINFO_DATA,
243
- LPCGUID, DWORD, PSP_DEVICE_INTERFACE_DATA));
244
- DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiGetDeviceInstanceIdA, (HDEVINFO, PSP_DEVINFO_DATA,
245
- PCSTR, DWORD, PDWORD));
246
- DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiGetDeviceInterfaceDetailA, (HDEVINFO, PSP_DEVICE_INTERFACE_DATA,
247
- PSP_DEVICE_INTERFACE_DETAIL_DATA_A, DWORD, PDWORD, PSP_DEVINFO_DATA));
248
- DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiGetDeviceRegistryPropertyA, (HDEVINFO,
249
- PSP_DEVINFO_DATA, DWORD, PDWORD, PBYTE, DWORD, PDWORD));
250
- DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, SetupDiDestroyDeviceInfoList, (HDEVINFO));
251
- DLL_DECLARE_FUNC_PREFIXED(WINAPI, HKEY, p, SetupDiOpenDevRegKey, (HDEVINFO, PSP_DEVINFO_DATA, DWORD, DWORD, DWORD, REGSAM));
252
- DLL_DECLARE_FUNC_PREFIXED(WINAPI, HKEY, p, SetupDiOpenDeviceInterfaceRegKey, (HDEVINFO, PSP_DEVICE_INTERFACE_DATA, DWORD, DWORD));
253
-
254
- #define FILE_DEVICE_USB FILE_DEVICE_UNKNOWN
255
-
256
- #define USB_GET_NODE_INFORMATION 258
257
- #define USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION 260
258
- #define USB_GET_NODE_CONNECTION_INFORMATION_EX 274
259
- #define USB_GET_NODE_CONNECTION_INFORMATION_EX_V2 279
260
-
261
- #define USB_CTL_CODE(id) \
262
- CTL_CODE(FILE_DEVICE_USB, (id), METHOD_BUFFERED, FILE_ANY_ACCESS)
263
-
264
- #define IOCTL_USB_GET_NODE_INFORMATION \
265
- USB_CTL_CODE(USB_GET_NODE_INFORMATION)
266
-
267
- #define IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION \
268
- USB_CTL_CODE(USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION)
269
-
270
- #define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX \
271
- USB_CTL_CODE(USB_GET_NODE_CONNECTION_INFORMATION_EX)
272
-
273
- #define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX_V2 \
274
- USB_CTL_CODE(USB_GET_NODE_CONNECTION_INFORMATION_EX_V2)
275
-
276
- typedef enum _USB_CONNECTION_STATUS {
277
- NoDeviceConnected,
278
- DeviceConnected,
279
- DeviceFailedEnumeration,
280
- DeviceGeneralFailure,
281
- DeviceCausedOvercurrent,
282
- DeviceNotEnoughPower,
283
- DeviceNotEnoughBandwidth,
284
- DeviceHubNestedTooDeeply,
285
- DeviceInLegacyHub,
286
- DeviceEnumerating,
287
- DeviceReset
288
- } USB_CONNECTION_STATUS;
289
-
290
- typedef enum _USB_DEVICE_SPEED {
291
- UsbLowSpeed = 0,
292
- UsbFullSpeed,
293
- UsbHighSpeed,
294
- UsbSuperSpeed,
295
- UsbSuperSpeedPlus // Not in Microsoft headers
296
- } USB_DEVICE_SPEED;
297
-
298
- typedef enum _USB_HUB_NODE {
299
- UsbHub,
300
- UsbMIParent
301
- } USB_HUB_NODE;
302
-
303
- #if defined(_MSC_VER)
304
- // disable /W4 MSVC warnings that are benign
305
- #pragma warning(push)
306
- #pragma warning(disable:4214) // bit field types other than int
307
- #endif
308
-
309
- // Most of the structures below need to be packed
310
- #include <pshpack1.h>
311
-
312
- typedef struct _USB_HUB_DESCRIPTOR {
313
- UCHAR bDescriptorLength;
314
- UCHAR bDescriptorType;
315
- UCHAR bNumberOfPorts;
316
- USHORT wHubCharacteristics;
317
- UCHAR bPowerOnToPowerGood;
318
- UCHAR bHubControlCurrent;
319
- UCHAR bRemoveAndPowerMask[64];
320
- } USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
321
-
322
- typedef struct _USB_HUB_INFORMATION {
323
- USB_HUB_DESCRIPTOR HubDescriptor;
324
- BOOLEAN HubIsBusPowered;
325
- } USB_HUB_INFORMATION, *PUSB_HUB_INFORMATION;
326
-
327
- typedef struct _USB_NODE_INFORMATION {
328
- USB_HUB_NODE NodeType;
329
- union {
330
- USB_HUB_INFORMATION HubInformation;
331
- // USB_MI_PARENT_INFORMATION MiParentInformation;
332
- } u;
333
- } USB_NODE_INFORMATION, *PUSB_NODE_INFORMATION;
334
-
335
- typedef struct _USB_DESCRIPTOR_REQUEST {
336
- ULONG ConnectionIndex;
337
- struct {
338
- UCHAR bmRequest;
339
- UCHAR bRequest;
340
- USHORT wValue;
341
- USHORT wIndex;
342
- USHORT wLength;
343
- } SetupPacket;
344
- // UCHAR Data[0];
345
- } USB_DESCRIPTOR_REQUEST, *PUSB_DESCRIPTOR_REQUEST;
346
-
347
- typedef struct _USB_CONFIGURATION_DESCRIPTOR_SHORT {
348
- USB_DESCRIPTOR_REQUEST req;
349
- USB_CONFIGURATION_DESCRIPTOR desc;
350
- } USB_CONFIGURATION_DESCRIPTOR_SHORT;
351
-
352
- typedef struct USB_INTERFACE_DESCRIPTOR {
353
- UCHAR bLength;
354
- UCHAR bDescriptorType;
355
- UCHAR bInterfaceNumber;
356
- UCHAR bAlternateSetting;
357
- UCHAR bNumEndpoints;
358
- UCHAR bInterfaceClass;
359
- UCHAR bInterfaceSubClass;
360
- UCHAR bInterfaceProtocol;
361
- UCHAR iInterface;
362
- } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
363
-
364
- typedef struct _USB_NODE_CONNECTION_INFORMATION_EX {
365
- ULONG ConnectionIndex;
366
- USB_DEVICE_DESCRIPTOR DeviceDescriptor;
367
- UCHAR CurrentConfigurationValue;
368
- UCHAR Speed;
369
- BOOLEAN DeviceIsHub;
370
- USHORT DeviceAddress;
371
- ULONG NumberOfOpenPipes;
372
- USB_CONNECTION_STATUS ConnectionStatus;
373
- // USB_PIPE_INFO PipeList[0];
374
- } USB_NODE_CONNECTION_INFORMATION_EX, *PUSB_NODE_CONNECTION_INFORMATION_EX;
375
-
376
- typedef union _USB_PROTOCOLS {
377
- ULONG ul;
378
- struct {
379
- ULONG Usb110:1;
380
- ULONG Usb200:1;
381
- ULONG Usb300:1;
382
- ULONG ReservedMBZ:29;
383
- };
384
- } USB_PROTOCOLS, *PUSB_PROTOCOLS;
385
-
386
- typedef union _USB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS {
387
- ULONG ul;
388
- struct {
389
- ULONG DeviceIsOperatingAtSuperSpeedOrHigher:1;
390
- ULONG DeviceIsSuperSpeedCapableOrHigher:1;
391
- ULONG DeviceIsOperatingAtSuperSpeedPlusOrHigher:1;
392
- ULONG DeviceIsSuperSpeedPlusCapableOrHigher:1;
393
- ULONG ReservedMBZ:28;
394
- };
395
- } USB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS, *PUSB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS;
396
-
397
- typedef struct _USB_NODE_CONNECTION_INFORMATION_EX_V2 {
398
- ULONG ConnectionIndex;
399
- ULONG Length;
400
- USB_PROTOCOLS SupportedUsbProtocols;
401
- USB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS Flags;
402
- } USB_NODE_CONNECTION_INFORMATION_EX_V2, *PUSB_NODE_CONNECTION_INFORMATION_EX_V2;
403
-
404
- #include <poppack.h>
405
-
406
- #if defined(_MSC_VER)
407
- // Restore original warnings
408
- #pragma warning(pop)
409
- #endif
410
-
411
- /* winusb.dll interface */
412
-
413
- /* pipe policies */
414
- #define SHORT_PACKET_TERMINATE 0x01
415
- #define AUTO_CLEAR_STALL 0x02
416
- #define PIPE_TRANSFER_TIMEOUT 0x03
417
- #define IGNORE_SHORT_PACKETS 0x04
418
- #define ALLOW_PARTIAL_READS 0x05
419
- #define AUTO_FLUSH 0x06
420
- #define RAW_IO 0x07
421
- #define MAXIMUM_TRANSFER_SIZE 0x08
422
- /* libusbK */
423
- #define ISO_ALWAYS_START_ASAP 0x21
424
-
425
- typedef struct _USBD_ISO_PACKET_DESCRIPTOR {
426
- ULONG Offset;
427
- ULONG Length;
428
- USBD_STATUS Status;
429
- } USBD_ISO_PACKET_DESCRIPTOR, *PUSBD_ISO_PACKET_DESCRIPTOR;
430
-
431
- typedef enum _USBD_PIPE_TYPE {
432
- UsbdPipeTypeControl,
433
- UsbdPipeTypeIsochronous,
434
- UsbdPipeTypeBulk,
435
- UsbdPipeTypeInterrupt
436
- } USBD_PIPE_TYPE;
437
-
438
- typedef struct {
439
- USBD_PIPE_TYPE PipeType;
440
- UCHAR PipeId;
441
- USHORT MaximumPacketSize;
442
- UCHAR Interval;
443
- ULONG MaximumBytesPerInterval;
444
- } WINUSB_PIPE_INFORMATION_EX, *PWINUSB_PIPE_INFORMATION_EX;
445
-
446
- #include <pshpack1.h>
447
-
448
- typedef struct _WINUSB_SETUP_PACKET {
449
- UCHAR RequestType;
450
- UCHAR Request;
451
- USHORT Value;
452
- USHORT Index;
453
- USHORT Length;
454
- } WINUSB_SETUP_PACKET, *PWINUSB_SETUP_PACKET;
455
-
456
- #include <poppack.h>
457
-
458
- typedef PVOID WINUSB_INTERFACE_HANDLE, *PWINUSB_INTERFACE_HANDLE;
459
- typedef PVOID WINUSB_ISOCH_BUFFER_HANDLE, *PWINUSB_ISOCH_BUFFER_HANDLE;
460
-
461
- typedef BOOL (WINAPI *WinUsb_AbortPipe_t)(
462
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
463
- UCHAR PipeID
464
- );
465
- typedef BOOL (WINAPI *WinUsb_ControlTransfer_t)(
466
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
467
- WINUSB_SETUP_PACKET SetupPacket,
468
- PUCHAR Buffer,
469
- ULONG BufferLength,
470
- PULONG LengthTransferred,
471
- LPOVERLAPPED Overlapped
472
- );
473
- typedef BOOL (WINAPI *WinUsb_FlushPipe_t)(
474
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
475
- UCHAR PipeID
476
- );
477
- typedef BOOL (WINAPI *WinUsb_Free_t)(
478
- WINUSB_INTERFACE_HANDLE InterfaceHandle
479
- );
480
- typedef BOOL (WINAPI *WinUsb_GetAssociatedInterface_t)(
481
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
482
- UCHAR AssociatedInterfaceIndex,
483
- PWINUSB_INTERFACE_HANDLE AssociatedInterfaceHandle
484
- );
485
- typedef BOOL (WINAPI *WinUsb_Initialize_t)(
486
- HANDLE DeviceHandle,
487
- PWINUSB_INTERFACE_HANDLE InterfaceHandle
488
- );
489
- typedef BOOL (WINAPI *WinUsb_QueryPipeEx_t)(
490
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
491
- UCHAR AlternateInterfaceHandle,
492
- UCHAR PipeIndex,
493
- PWINUSB_PIPE_INFORMATION_EX PipeInformationEx
494
- );
495
- typedef BOOL (WINAPI *WinUsb_ReadIsochPipeAsap_t)(
496
- PWINUSB_ISOCH_BUFFER_HANDLE BufferHandle,
497
- ULONG Offset,
498
- ULONG Length,
499
- BOOL ContinueStream,
500
- ULONG NumberOfPackets,
501
- PUSBD_ISO_PACKET_DESCRIPTOR IsoPacketDescriptors,
502
- LPOVERLAPPED Overlapped
503
- );
504
- typedef BOOL (WINAPI *WinUsb_ReadPipe_t)(
505
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
506
- UCHAR PipeID,
507
- PUCHAR Buffer,
508
- ULONG BufferLength,
509
- PULONG LengthTransferred,
510
- LPOVERLAPPED Overlapped
511
- );
512
- typedef BOOL (WINAPI *WinUsb_RegisterIsochBuffer_t)(
513
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
514
- UCHAR PipeID,
515
- PVOID Buffer,
516
- ULONG BufferLength,
517
- PWINUSB_ISOCH_BUFFER_HANDLE BufferHandle
518
- );
519
- typedef BOOL (WINAPI *WinUsb_ResetPipe_t)(
520
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
521
- UCHAR PipeID
522
- );
523
- typedef BOOL (WINAPI *WinUsb_SetCurrentAlternateSetting_t)(
524
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
525
- UCHAR AlternateSetting
526
- );
527
- typedef BOOL (WINAPI *WinUsb_SetPipePolicy_t)(
528
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
529
- UCHAR PipeID,
530
- ULONG PolicyType,
531
- ULONG ValueLength,
532
- PVOID Value
533
- );
534
- typedef BOOL (WINAPI *WinUsb_GetPipePolicy_t)(
535
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
536
- UCHAR PipeID,
537
- ULONG PolicyType,
538
- PULONG ValueLength,
539
- PVOID Value
540
- );
541
- typedef BOOL (WINAPI *WinUsb_UnregisterIsochBuffer_t)(
542
- WINUSB_ISOCH_BUFFER_HANDLE BufferHandle
543
- );
544
- typedef BOOL (WINAPI *WinUsb_WriteIsochPipeAsap_t)(
545
- WINUSB_ISOCH_BUFFER_HANDLE BufferHandle,
546
- ULONG Offset,
547
- ULONG Length,
548
- BOOL ContinueStream,
549
- LPOVERLAPPED Overlapped
550
- );
551
- typedef BOOL (WINAPI *WinUsb_WritePipe_t)(
552
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
553
- UCHAR PipeID,
554
- PUCHAR Buffer,
555
- ULONG BufferLength,
556
- PULONG LengthTransferred,
557
- LPOVERLAPPED Overlapped
558
- );
559
-
560
- /* /!\ These must match the ones from the official libusbk.h */
561
- typedef enum _KUSB_FNID {
562
- KUSB_FNID_Init,
563
- KUSB_FNID_Free,
564
- KUSB_FNID_ClaimInterface,
565
- KUSB_FNID_ReleaseInterface,
566
- KUSB_FNID_SetAltInterface,
567
- KUSB_FNID_GetAltInterface,
568
- KUSB_FNID_GetDescriptor,
569
- KUSB_FNID_ControlTransfer,
570
- KUSB_FNID_SetPowerPolicy,
571
- KUSB_FNID_GetPowerPolicy,
572
- KUSB_FNID_SetConfiguration,
573
- KUSB_FNID_GetConfiguration,
574
- KUSB_FNID_ResetDevice,
575
- KUSB_FNID_Initialize,
576
- KUSB_FNID_SelectInterface,
577
- KUSB_FNID_GetAssociatedInterface,
578
- KUSB_FNID_Clone,
579
- KUSB_FNID_QueryInterfaceSettings,
580
- KUSB_FNID_QueryDeviceInformation,
581
- KUSB_FNID_SetCurrentAlternateSetting,
582
- KUSB_FNID_GetCurrentAlternateSetting,
583
- KUSB_FNID_QueryPipe,
584
- KUSB_FNID_SetPipePolicy,
585
- KUSB_FNID_GetPipePolicy,
586
- KUSB_FNID_ReadPipe,
587
- KUSB_FNID_WritePipe,
588
- KUSB_FNID_ResetPipe,
589
- KUSB_FNID_AbortPipe,
590
- KUSB_FNID_FlushPipe,
591
- KUSB_FNID_IsoReadPipe,
592
- KUSB_FNID_IsoWritePipe,
593
- KUSB_FNID_GetCurrentFrameNumber,
594
- KUSB_FNID_GetOverlappedResult,
595
- KUSB_FNID_GetProperty,
596
- KUSB_FNID_COUNT,
597
- } KUSB_FNID;
598
-
599
- typedef struct _KLIB_VERSION {
600
- INT Major;
601
- INT Minor;
602
- INT Micro;
603
- INT Nano;
604
- } KLIB_VERSION, *PKLIB_VERSION;
605
-
606
- typedef BOOL (WINAPI *LibK_GetProcAddress_t)(
607
- PVOID ProcAddress,
608
- INT DriverID,
609
- INT FunctionID
610
- );
611
-
612
- typedef VOID (WINAPI *LibK_GetVersion_t)(
613
- PKLIB_VERSION Version
614
- );
615
-
616
- typedef BOOL (WINAPI *LibK_ResetDevice_t)(
617
- WINUSB_INTERFACE_HANDLE InterfaceHandle
618
- );
619
-
620
- //KISO_PACKET is equivalent of libusb_iso_packet_descriptor except uses absolute "offset" field instead of sequential Lengths
621
- typedef struct _KISO_PACKET {
622
- UINT offset;
623
- USHORT actual_length; //changed from libusbk_shared.h "Length" for clarity
624
- USHORT status;
625
- } KISO_PACKET, *PKISO_PACKET;
626
-
627
- typedef enum _KISO_FLAG {
628
- KISO_FLAG_NONE = 0,
629
- KISO_FLAG_SET_START_FRAME = 0x00000001,
630
- } KISO_FLAG;
631
-
632
- //KISO_CONTEXT is the conceptual equivalent of libusb_transfer except is isochronous-specific and must match libusbk's version
633
- typedef struct _KISO_CONTEXT {
634
- KISO_FLAG Flags;
635
- UINT StartFrame;
636
- SHORT ErrorCount;
637
- SHORT NumberOfPackets;
638
- UINT UrbHdrStatus;
639
- KISO_PACKET IsoPackets[0];
640
- } KISO_CONTEXT, *PKISO_CONTEXT;
641
-
642
- typedef BOOL(WINAPI *LibK_IsoReadPipe_t)(
643
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
644
- UCHAR PipeID,
645
- PUCHAR Buffer,
646
- ULONG BufferLength,
647
- LPOVERLAPPED Overlapped,
648
- PKISO_CONTEXT IsoContext
649
- );
650
-
651
- typedef BOOL(WINAPI *LibK_IsoWritePipe_t)(
652
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
653
- UCHAR PipeID,
654
- PUCHAR Buffer,
655
- ULONG BufferLength,
656
- LPOVERLAPPED Overlapped,
657
- PKISO_CONTEXT IsoContext
658
- );
659
-
660
- struct winusb_interface {
661
- HMODULE hDll;
662
- WinUsb_AbortPipe_t AbortPipe;
663
- WinUsb_ControlTransfer_t ControlTransfer;
664
- WinUsb_FlushPipe_t FlushPipe;
665
- WinUsb_Free_t Free;
666
- WinUsb_GetAssociatedInterface_t GetAssociatedInterface;
667
- WinUsb_Initialize_t Initialize;
668
- WinUsb_ReadPipe_t ReadPipe;
669
- WinUsb_ResetPipe_t ResetPipe;
670
- WinUsb_SetCurrentAlternateSetting_t SetCurrentAlternateSetting;
671
- WinUsb_SetPipePolicy_t SetPipePolicy;
672
- WinUsb_GetPipePolicy_t GetPipePolicy;
673
- WinUsb_WritePipe_t WritePipe;
674
- union {
675
- struct {
676
- // Isochoronous functions for libusbK sub api:
677
- LibK_IsoReadPipe_t IsoReadPipe;
678
- LibK_IsoWritePipe_t IsoWritePipe;
679
- // Reset device function for libusbK sub api:
680
- LibK_ResetDevice_t ResetDevice;
681
- };
682
- struct {
683
- // Isochronous functions for WinUSB sub api:
684
- WinUsb_QueryPipeEx_t QueryPipeEx;
685
- WinUsb_ReadIsochPipeAsap_t ReadIsochPipeAsap;
686
- WinUsb_RegisterIsochBuffer_t RegisterIsochBuffer;
687
- WinUsb_UnregisterIsochBuffer_t UnregisterIsochBuffer;
688
- WinUsb_WriteIsochPipeAsap_t WriteIsochPipeAsap;
689
- };
690
- };
691
- };
692
-
693
- /* hid.dll interface */
694
-
695
- #define HIDP_STATUS_SUCCESS 0x110000
696
- typedef void * PHIDP_PREPARSED_DATA;
697
-
698
- #include <pshpack1.h>
699
-
700
- typedef struct _HIDD_ATTIRBUTES {
701
- ULONG Size;
702
- USHORT VendorID;
703
- USHORT ProductID;
704
- USHORT VersionNumber;
705
- } HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
706
-
707
- #include <poppack.h>
708
-
709
- typedef USHORT USAGE;
710
- typedef struct _HIDP_CAPS {
711
- USAGE Usage;
712
- USAGE UsagePage;
713
- USHORT InputReportByteLength;
714
- USHORT OutputReportByteLength;
715
- USHORT FeatureReportByteLength;
716
- USHORT Reserved[17];
717
- USHORT NumberLinkCollectionNodes;
718
- USHORT NumberInputButtonCaps;
719
- USHORT NumberInputValueCaps;
720
- USHORT NumberInputDataIndices;
721
- USHORT NumberOutputButtonCaps;
722
- USHORT NumberOutputValueCaps;
723
- USHORT NumberOutputDataIndices;
724
- USHORT NumberFeatureButtonCaps;
725
- USHORT NumberFeatureValueCaps;
726
- USHORT NumberFeatureDataIndices;
727
- } HIDP_CAPS, *PHIDP_CAPS;
728
-
729
- typedef enum _HIDP_REPORT_TYPE {
730
- HidP_Input,
731
- HidP_Output,
732
- HidP_Feature
733
- } HIDP_REPORT_TYPE;
734
-
735
- typedef struct _HIDP_VALUE_CAPS {
736
- USAGE UsagePage;
737
- UCHAR ReportID;
738
- BOOLEAN IsAlias;
739
- USHORT BitField;
740
- USHORT LinkCollection;
741
- USAGE LinkUsage;
742
- USAGE LinkUsagePage;
743
- BOOLEAN IsRange;
744
- BOOLEAN IsStringRange;
745
- BOOLEAN IsDesignatorRange;
746
- BOOLEAN IsAbsolute;
747
- BOOLEAN HasNull;
748
- UCHAR Reserved;
749
- USHORT BitSize;
750
- USHORT ReportCount;
751
- USHORT Reserved2[5];
752
- ULONG UnitsExp;
753
- ULONG Units;
754
- LONG LogicalMin, LogicalMax;
755
- LONG PhysicalMin, PhysicalMax;
756
- union {
757
- struct {
758
- USAGE UsageMin, UsageMax;
759
- USHORT StringMin, StringMax;
760
- USHORT DesignatorMin, DesignatorMax;
761
- USHORT DataIndexMin, DataIndexMax;
762
- } Range;
763
- struct {
764
- USAGE Usage, Reserved1;
765
- USHORT StringIndex, Reserved2;
766
- USHORT DesignatorIndex, Reserved3;
767
- USHORT DataIndex, Reserved4;
768
- } NotRange;
769
- } u;
770
- } HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS;
771
-
772
- DLL_DECLARE_HANDLE(hid);
773
- DLL_DECLARE_FUNC(WINAPI, VOID, HidD_GetHidGuid, (LPGUID));
774
- DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetAttributes, (HANDLE, PHIDD_ATTRIBUTES));
775
- DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetPreparsedData, (HANDLE, PHIDP_PREPARSED_DATA *));
776
- DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_FreePreparsedData, (PHIDP_PREPARSED_DATA));
777
- DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetManufacturerString, (HANDLE, PVOID, ULONG));
778
- DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetProductString, (HANDLE, PVOID, ULONG));
779
- DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetSerialNumberString, (HANDLE, PVOID, ULONG));
780
- DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetIndexedString, (HANDLE, ULONG, PVOID, ULONG));
781
- DLL_DECLARE_FUNC(WINAPI, LONG, HidP_GetCaps, (PHIDP_PREPARSED_DATA, PHIDP_CAPS));
782
- DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_SetNumInputBuffers, (HANDLE, ULONG));
783
- DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetPhysicalDescriptor, (HANDLE, PVOID, ULONG));
784
- DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_FlushQueue, (HANDLE));
785
- DLL_DECLARE_FUNC(WINAPI, BOOL, HidP_GetValueCaps, (HIDP_REPORT_TYPE, PHIDP_VALUE_CAPS, PULONG, PHIDP_PREPARSED_DATA));
786
-
787
- #endif