OpenNI 1.5.2
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 //---------------------------------------------------------------------------
64 typedef struct XnUSBStringDescriptor
65 {
66  XnUInt8 nID;
67  const XnChar* strString;
69 
71 {
72  XnUSBInterfaceDescriptor descriptor;
73  XnUSBEndpointDescriptor** aEndpoints;
75 
77 {
78  XnUSBConfigDescriptor descriptor;
81 
83 {
84  XnUSBDeviceDescriptor descriptor;
87  XnUInt8 nStrings;
89 
90 struct XnUSBDevice;
91 typedef struct XnUSBDevice XnUSBDevice;
92 
93 typedef void (*XnUSBDeviceNewControlRequestCallback)(XnUSBDevice* pDevice, void* pCookie);
94 
95 //---------------------------------------------------------------------------
96 // API
97 //---------------------------------------------------------------------------
98 XN_C_API XnStatus XN_C_DECL xnUSBDeviceInit(const XnUSBDeviceDescriptorHolder* pDeviceDescriptor, XnUInt32 nControlMessageMaxSize, XnUSBDevice** ppDevice);
99 XN_C_API void XN_C_DECL xnUSBDeviceShutdown(XnUSBDevice* pDevice);
100 XN_C_API XnBool XN_C_DECL xnUSBDeviceIsControlRequestPending(XnUSBDevice* pDevice);
101 
102 //pnRequestSize is max size on input, actual size on output
103 XN_C_API XnStatus XN_C_DECL xnUSBDeviceReceiveControlRequest(XnUSBDevice* pDevice, XnUChar* pBuffer, XnUInt32* pnRequestSize);
104 XN_C_API XnStatus XN_C_DECL xnUSBDeviceSendControlReply(XnUSBDevice* pDevice, const XnUChar* pBuffer, XnUInt32 nReplySize);
106 XN_C_API XnStatus XN_C_DECL xnUSBDeviceWriteEndpoint(XnUSBDevice* pDevice, XnUInt8 nAddress, const XnUChar* pData, XnUInt32 nDataSize);
107 
108 #endif
const XnChar * strString
Definition: XnUSBDevice.h:67
struct XnUSBDeviceDescriptorHolder XnUSBDeviceDescriptorHolder
XnUInt8 nID
Definition: XnUSBDevice.h:66
XnUSBEndpointDescriptor ** aEndpoints
Definition: XnUSBDevice.h:73
XN_C_API void XN_C_DECL xnUSBDeviceShutdown(XnUSBDevice *pDevice)
XnUSBInterfaceDescriptorHolder ** aInterfaces
Definition: XnUSBDevice.h:79
XnUInt8 nStrings
Definition: XnUSBDevice.h:87
XN_C_API XnBool XN_C_DECL xnUSBDeviceIsControlRequestPending(XnUSBDevice *pDevice)
XnUInt32 XnStatus
Definition: XnStatus.h:34
Definition: XnUSBDevice.h:82
XnUSBStringDescriptor * aStrings
Definition: XnUSBDevice.h:86
XnUSBDeviceDescriptor descriptor
Definition: XnUSBDevice.h:84
struct XnUSBDevice XnUSBDevice
Definition: XnUSBDevice.h:91
XN_C_API XnStatus XN_C_DECL xnUSBDeviceInit(const XnUSBDeviceDescriptorHolder *pDeviceDescriptor, XnUInt32 nControlMessageMaxSize, XnUSBDevice **ppDevice)
Definition: XnUSBDevice.h:70
XN_C_API XnStatus XN_C_DECL xnUSBDeviceWriteEndpoint(XnUSBDevice *pDevice, XnUInt8 nAddress, const XnUChar *pData, XnUInt32 nDataSize)
#define XN_C_API
Definition: XnPlatform.h:114
struct XnUSBInterfaceDescriptorHolder XnUSBInterfaceDescriptorHolder
XN_C_API XnStatus XN_C_DECL xnUSBDeviceSetNewControlRequestCallback(XnUSBDevice *pDevice, XnUSBDeviceNewControlRequestCallback pFunc, void *pCookie)
XnUSBConfigDescriptor descriptor
Definition: XnUSBDevice.h:78
void(* XnUSBDeviceNewControlRequestCallback)(XnUSBDevice *pDevice, void *pCookie)
Definition: XnUSBDevice.h:93
XnUSBConfigDescriptorHolder ** aConfigurations
Definition: XnUSBDevice.h:85
XnUSBInterfaceDescriptor descriptor
Definition: XnUSBDevice.h:72
XN_C_API XnStatus XN_C_DECL xnUSBDeviceSendControlReply(XnUSBDevice *pDevice, const XnUChar *pBuffer, XnUInt32 nReplySize)
Definition: XnUSBDevice.h:76
Definition: XnUSBDevice.h:64
XN_C_API XnStatus XN_C_DECL xnUSBDeviceReceiveControlRequest(XnUSBDevice *pDevice, XnUChar *pBuffer, XnUInt32 *pnRequestSize)
struct XnUSBConfigDescriptorHolder XnUSBConfigDescriptorHolder
struct XnUSBStringDescriptor XnUSBStringDescriptor