OpenNI 1.5.4
XnUSBDevice.h
Go to the documentation of this file.
1 /****************************************************************************
2 * *
3 * OpenNI 1.x Alpha *
4 * Copyright (C) 2011 PrimeSense Ltd. *
5 * *
6 * This file is part of OpenNI. *
7 * *
8 * OpenNI is free software: you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published *
10 * by the Free Software Foundation, either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * OpenNI 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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
20 * *
21 ****************************************************************************/
22 #ifndef _XN_USB_DEVICE_H_
23 #define _XN_USB_DEVICE_H_
24 
25 //---------------------------------------------------------------------------
26 // Includes
27 //---------------------------------------------------------------------------
28 #include "XnPlatform.h"
29 #include "XnStatus.h"
30 
31 #if (XN_PLATFORM == XN_PLATFORM_WIN32)
32 
33  #include <Win32/usb100.h>
34  typedef USB_ENDPOINT_DESCRIPTOR XnUSBEndpointDescriptor;
35  typedef USB_INTERFACE_DESCRIPTOR XnUSBInterfaceDescriptor;
36  typedef USB_CONFIGURATION_DESCRIPTOR XnUSBConfigDescriptor;
37  typedef USB_DEVICE_DESCRIPTOR XnUSBDeviceDescriptor;
38 
39  #define USB_DT_CONFIG_SIZE 0
40  #define USB_DT_CONFIG 0
41  #define USB_CONFIG_ATT_ONE 0
42  #define USB_DT_ENDPOINT_SIZE 0
43  #define USB_DT_ENDPOINT 0
44  #define USB_ENDPOINT_XFER_BULK 0
45  #define USB_DT_INTERFACE_SIZE 0
46  #define USB_DT_INTERFACE 0
47  #define USB_CLASS_VENDOR_SPEC 0
48  #define USB_DT_DEVICE_SIZE 0
49  #define USB_DT_DEVICE 0
50 
51 #elif (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM)
52  #include <linux/usb/ch9.h>
53  typedef struct usb_endpoint_descriptor XnUSBEndpointDescriptor;
54  typedef struct usb_interface_descriptor XnUSBInterfaceDescriptor;
55  typedef struct usb_config_descriptor XnUSBConfigDescriptor;
56  typedef struct usb_device_descriptor XnUSBDeviceDescriptor;
57 #else
58  #error "Unsupported Platform!"
59 #endif
60 
61 //---------------------------------------------------------------------------
62 // Structures & Enums
63 //---------------------------------------------------------------------------
65 {
70 
71 typedef struct XnUSBStringDescriptor
72 {
73  XnUInt8 nID;
74  const XnChar* strString;
76 
78 {
79  XnUSBInterfaceDescriptor descriptor;
80  XnUSBEndpointDescriptor** aEndpoints;
82 
84 {
85  XnUSBConfigDescriptor descriptor;
88 
90 {
91  XnUSBDeviceDescriptor descriptor;
94  XnUInt8 nStrings;
96 
97 struct XnUSBDevice;
98 typedef struct XnUSBDevice XnUSBDevice;
99 
100 typedef void (*XnUSBDeviceNewControlRequestCallback)(XnUSBDevice* pDevice, void* pCookie);
101 typedef void (*XnUSBDeviceConnectivityChangedCallback)(XnUSBDevice* pDevice, XnUSBDeviceConnectionState state, void* pCookie);
102 
103 //---------------------------------------------------------------------------
104 // API
105 //---------------------------------------------------------------------------
106 XN_C_API XnStatus XN_C_DECL xnUSBDeviceInit(const XnUSBDeviceDescriptorHolder* pDeviceDescriptor, XnUInt32 nControlMessageMaxSize, XnUSBDevice** ppDevice);
107 XN_C_API void XN_C_DECL xnUSBDeviceShutdown(XnUSBDevice* pDevice);
108 XN_C_API XnBool XN_C_DECL xnUSBDeviceIsControlRequestPending(XnUSBDevice* pDevice);
109 
110 //pnRequestSize is max size on input, actual size on output
111 XN_C_API XnStatus XN_C_DECL xnUSBDeviceReceiveControlRequest(XnUSBDevice* pDevice, XnUChar* pBuffer, XnUInt32* pnRequestSize);
112 XN_C_API XnStatus XN_C_DECL xnUSBDeviceSendControlReply(XnUSBDevice* pDevice, const XnUChar* pBuffer, XnUInt32 nReplySize);
115 XN_C_API XnStatus XN_C_DECL xnUSBDeviceWriteEndpoint(XnUSBDevice* pDevice, XnUInt8 nAddress, const XnUChar* pData, XnUInt32 nDataSize);
116 
117 #endif