xswinusb.h
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #ifndef XSWINUSB
66 #define XSWINUSB
67 
68 #include "xscontrollerconfig.h"
69 
70 #ifdef USE_WINUSB
71 
72 #include <windows.h>
73 #include <winusb.h>
74 
75 struct XsLibraryLoader;
76 
77 typedef BOOL __stdcall WinUSB_Initialize(HANDLE DeviceHandle, WINUSB_INTERFACE_HANDLE* InterfaceHandle);
78 typedef BOOL __stdcall WinUSB_Free(WINUSB_INTERFACE_HANDLE InterfaceHandle);
79 typedef BOOL __stdcall WinUSB_GetAssociatedInterface(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR AssociatedInterfaceIndex, WINUSB_INTERFACE_HANDLE* AssociatedInterfaceHandle);
80 typedef BOOL __stdcall WinUSB_GetDescriptor(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR DescriptorType, UCHAR Index, USHORT LanguageID, PUCHAR Buffer, ULONG BufferLength, PULONG LengthTransferred);
81 typedef BOOL __stdcall WinUSB_QueryInterfaceSettings(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR AltSettingIndex, PUSB_INTERFACE_DESCRIPTOR UsbAltInterfaceDescriptor);
82 typedef BOOL __stdcall WinUSB_QueryDeviceInformation(WINUSB_INTERFACE_HANDLE InterfaceHandle, ULONG InformationType, PULONG BufferLength, PVOID Buffer);
83 typedef BOOL __stdcall WinUSB_SetCurrentAlternateSetting(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR AltSettingNumber);
84 typedef BOOL __stdcall WinUSB_GetCurrentAlternateSetting(WINUSB_INTERFACE_HANDLE InterfaceHandle, PUCHAR AltSettingNumber);
85 typedef BOOL __stdcall WinUSB_QueryPipe(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR AltSettingNumber, UCHAR PipeIndex, PWINUSB_PIPE_INFORMATION PipeInformation);
86 typedef BOOL __stdcall WinUSB_SetPipePolicy(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID, ULONG PolicyType, ULONG ValueLength, PVOID Value);
87 typedef BOOL __stdcall WinUSB_GetPipePolicy(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID, ULONG PolicyType, PULONG ValueLength, PVOID Value);
88 typedef BOOL __stdcall WinUSB_ReadPipe(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID, PUCHAR Buffer, ULONG BufferLength, PULONG LengthTransferred, LPOVERLAPPED Overlapped);
89 typedef BOOL __stdcall WinUSB_WritePipe(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID, PUCHAR Buffer, ULONG BufferLength, PULONG LengthTransferred, LPOVERLAPPED Overlapped);
90 typedef BOOL __stdcall WinUSB_ControlTransfer(WINUSB_INTERFACE_HANDLE InterfaceHandle, WINUSB_SETUP_PACKET SetupPacket, PUCHAR Buffer, ULONG BufferLength, PULONG LengthTransferred, LPOVERLAPPED Overlapped);
91 typedef BOOL __stdcall WinUSB_ResetPipe(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID);
92 typedef BOOL __stdcall WinUSB_AbortPipe(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID);
93 typedef BOOL __stdcall WinUSB_FlushPipe(WINUSB_INTERFACE_HANDLE InterfaceHandle, UCHAR PipeID);
94 typedef BOOL __stdcall WinUSB_SetPowerPolicy(WINUSB_INTERFACE_HANDLE InterfaceHandle, ULONG PolicyType, ULONG ValueLength, PVOID Value);
95 typedef BOOL __stdcall WinUSB_GetPowerPolicy(WINUSB_INTERFACE_HANDLE InterfaceHandle, ULONG PolicyType, PULONG ValueLength, PVOID Value);
96 typedef BOOL __stdcall WinUSB_GetOverlappedResult(WINUSB_INTERFACE_HANDLE InterfaceHandle, LPOVERLAPPED Overlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait);
97 
98 class XsWinUsb
99 {
100 public:
101  XsWinUsb(void);
102  ~XsWinUsb(void);
103 
104  WinUSB_Initialize Initialize;
105  WinUSB_Free Free;
106  WinUSB_GetAssociatedInterface GetAssociatedInterface;
107  WinUSB_GetDescriptor GetDescriptor;
108  WinUSB_QueryInterfaceSettings QueryInterfaceSettings;
109  WinUSB_QueryDeviceInformation QueryDeviceInformation;
110  WinUSB_SetCurrentAlternateSetting SetCurrentAlternateSetting;
111  WinUSB_GetCurrentAlternateSetting GetCurrentAlternateSetting;
112  WinUSB_QueryPipe QueryPipe;
113  WinUSB_SetPipePolicy SetPipePolicy;
114  WinUSB_GetPipePolicy GetPipePolicy;
115  WinUSB_ReadPipe ReadPipe;
116  WinUSB_WritePipe WritePipe;
117  WinUSB_ControlTransfer ControlTransfer;
118  WinUSB_ResetPipe ResetPipe;
119  WinUSB_AbortPipe AbortPipe;
120  WinUSB_FlushPipe FlushPipe;
121  WinUSB_SetPowerPolicy SetPowerPolicy;
122  WinUSB_GetPowerPolicy GetPowerPolicy;
123  WinUSB_GetOverlappedResult GetOverlappedResult;
124 
125 private:
126 
127  typedef struct _WINUSB_API
128  {
129  WinUSB_Initialize(* Initialize);
130  WinUSB_Free(* Free);
131  WinUSB_GetAssociatedInterface(*GetAssociatedInterface);
132  WinUSB_GetDescriptor(* GetDescriptor);
133  WinUSB_QueryInterfaceSettings(* QueryInterfaceSettings);
134  WinUSB_QueryDeviceInformation(* QueryDeviceInformation);
135  WinUSB_SetCurrentAlternateSetting(* SetCurrentAlternateSetting);
136  WinUSB_GetCurrentAlternateSetting(* GetCurrentAlternateSetting);
137  WinUSB_QueryPipe(* QueryPipe);
138  WinUSB_SetPipePolicy(* SetPipePolicy);
139  WinUSB_GetPipePolicy(* GetPipePolicy);
140  WinUSB_ReadPipe(* ReadPipe);
141  WinUSB_WritePipe(* WritePipe);
142  WinUSB_ControlTransfer(* ControlTransfer);
143  WinUSB_ResetPipe(* ResetPipe);
144  WinUSB_AbortPipe(* AbortPipe);
145  WinUSB_FlushPipe(* FlushPipe);
146  WinUSB_SetPowerPolicy(* SetPowerPolicy);
147  WinUSB_GetPowerPolicy(* GetPowerPolicy);
148  WinUSB_GetOverlappedResult(*GetOverlappedResult);
149  } WINUSB_API;
150 
151  WINUSB_API m_winUsb;
152  XsLibraryLoader* m_libraryLoader;
153 
154  void initLibrary();
155 
156  XsWinUsb(XsWinUsb const&) = delete;
157  XsWinUsb const& operator=(XsWinUsb const&) = delete;
158 };
159 
160 #endif // USE_WINUSB
161 
162 #endif
XsLibraryLoader
The Xsens dynamic library loader base class.
Definition: xslibraryloader.h:93
BOOL
int BOOL
Definition: xstypedefs.h:141
xscontrollerconfig.h


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20