OpenNI 1.5.7
XnUSBDevice.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * *
3 * OpenNI 1.x Alpha *
4 * Copyright (C) 2012 PrimeSense Ltd. *
5 * *
6 * This file is part of OpenNI. *
7 * *
8 * Licensed under the Apache License, Version 2.0 (the "License"); *
9 * you may not use this file except in compliance with the License. *
10 * You may obtain a copy of the License at *
11 * *
12 * http://www.apache.org/licenses/LICENSE-2.0 *
13 * *
14 * Unless required by applicable law or agreed to in writing, software *
15 * distributed under the License is distributed on an "AS IS" BASIS, *
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
17 * See the License for the specific language governing permissions and *
18 * limitations under the License. *
19 * *
20 *****************************************************************************/
21 #ifndef _XN_USB_DEVICE_H_
22 #define _XN_USB_DEVICE_H_
23 
24 //---------------------------------------------------------------------------
25 // Includes
26 //---------------------------------------------------------------------------
27 #include "XnPlatform.h"
28 #include "XnStatus.h"
29 
30 #if (XN_PLATFORM == XN_PLATFORM_WIN32)
31 
32  #include <Win32/usb100.h>
33  typedef USB_ENDPOINT_DESCRIPTOR XnUSBEndpointDescriptor;
34  typedef USB_INTERFACE_DESCRIPTOR XnUSBInterfaceDescriptor;
35  typedef USB_CONFIGURATION_DESCRIPTOR XnUSBConfigDescriptor;
36  typedef USB_DEVICE_DESCRIPTOR XnUSBDeviceDescriptor;
37 
38  #define USB_DT_CONFIG_SIZE 0
39  #define USB_DT_CONFIG 0
40  #define USB_CONFIG_ATT_ONE 0
41  #define USB_DT_ENDPOINT_SIZE 0
42  #define USB_DT_ENDPOINT 0
43  #define USB_ENDPOINT_XFER_BULK 0
44  #define USB_DT_INTERFACE_SIZE 0
45  #define USB_DT_INTERFACE 0
46  #define USB_CLASS_VENDOR_SPEC 0
47  #define USB_DT_DEVICE_SIZE 0
48  #define USB_DT_DEVICE 0
49 
50 #elif (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM)
51  #include <linux/usb/ch9.h>
52  typedef struct usb_endpoint_descriptor XnUSBEndpointDescriptor;
53  typedef struct usb_interface_descriptor XnUSBInterfaceDescriptor;
54  typedef struct usb_config_descriptor XnUSBConfigDescriptor;
55  typedef struct usb_device_descriptor XnUSBDeviceDescriptor;
56 #else
57  #error "Unsupported Platform!"
58 #endif
59 
60 //---------------------------------------------------------------------------
61 // Structures & Enums
62 //---------------------------------------------------------------------------
64 {
69 
70 typedef struct XnUSBStringDescriptor
71 {
72  XnUInt8 nID;
73  const XnChar* strString;
75 
77 {
78  XnUSBInterfaceDescriptor descriptor;
79  XnUSBEndpointDescriptor** aEndpoints;
81 
83 {
84  XnUSBConfigDescriptor descriptor;
87 
89 {
90  XnUSBDeviceDescriptor descriptor;
93  XnUInt8 nStrings;
95 
96 struct XnUSBDevice;
97 typedef struct XnUSBDevice XnUSBDevice;
98 
99 typedef void (*XnUSBDeviceNewControlRequestCallback)(XnUSBDevice* pDevice, void* pCookie);
100 typedef void (*XnUSBDeviceConnectivityChangedCallback)(XnUSBDevice* pDevice, XnUSBDeviceConnectionState state, void* pCookie);
101 
102 //---------------------------------------------------------------------------
103 // API
104 //---------------------------------------------------------------------------
105 XN_C_API XnStatus XN_C_DECL xnUSBDeviceInit(const XnUSBDeviceDescriptorHolder* pDeviceDescriptor, XnUInt32 nControlMessageMaxSize, XnUSBDevice** ppDevice);
106 XN_C_API void XN_C_DECL xnUSBDeviceShutdown(XnUSBDevice* pDevice);
107 XN_C_API XnBool XN_C_DECL xnUSBDeviceIsControlRequestPending(XnUSBDevice* pDevice);
108 
109 //pnRequestSize is max size on input, actual size on output
110 XN_C_API XnStatus XN_C_DECL xnUSBDeviceReceiveControlRequest(XnUSBDevice* pDevice, XnUChar* pBuffer, XnUInt32* pnRequestSize);
111 XN_C_API XnStatus XN_C_DECL xnUSBDeviceSendControlReply(XnUSBDevice* pDevice, const XnUChar* pBuffer, XnUInt32 nReplySize);
114 XN_C_API XnStatus XN_C_DECL xnUSBDeviceWriteEndpoint(XnUSBDevice* pDevice, XnUInt8 nAddress, const XnUChar* pData, XnUInt32 nDataSize);
115 XN_C_API XnStatus XN_C_DECL xnUSBDeviceResetEndpoint(XnUSBDevice* pDevice, XnUInt8 nAddress);
116 
117 #endif
void(* XnUSBDeviceConnectivityChangedCallback)(XnUSBDevice *pDevice, XnUSBDeviceConnectionState state, void *pCookie)
Definition: XnUSBDevice.h:100
const XnChar * strString
Definition: XnUSBDevice.h:73
Definition: XnUSBDevice.h:66
struct XnUSBDeviceDescriptorHolder XnUSBDeviceDescriptorHolder
XnUInt8 nID
Definition: XnUSBDevice.h:72
XnUSBEndpointDescriptor ** aEndpoints
Definition: XnUSBDevice.h:79
XN_C_API void XN_C_DECL xnUSBDeviceShutdown(XnUSBDevice *pDevice)
XnUSBInterfaceDescriptorHolder ** aInterfaces
Definition: XnUSBDevice.h:85
XnUInt8 nStrings
Definition: XnUSBDevice.h:93
XN_C_API XnBool XN_C_DECL xnUSBDeviceIsControlRequestPending(XnUSBDevice *pDevice)
XnUInt32 XnStatus
Definition: XnStatus.h:33
Definition: XnUSBDevice.h:88
XnUSBStringDescriptor * aStrings
Definition: XnUSBDevice.h:92
XnUSBDeviceDescriptor descriptor
Definition: XnUSBDevice.h:90
struct XnUSBDevice XnUSBDevice
Definition: XnUSBDevice.h:97
XN_C_API XnStatus XN_C_DECL xnUSBDeviceInit(const XnUSBDeviceDescriptorHolder *pDeviceDescriptor, XnUInt32 nControlMessageMaxSize, XnUSBDevice **ppDevice)
Definition: XnUSBDevice.h:76
XN_C_API XnStatus XN_C_DECL xnUSBDeviceWriteEndpoint(XnUSBDevice *pDevice, XnUInt8 nAddress, const XnUChar *pData, XnUInt32 nDataSize)
XN_C_API XnStatus XN_C_DECL xnUSBDeviceResetEndpoint(XnUSBDevice *pDevice, XnUInt8 nAddress)
#define XN_C_API
Definition: XnPlatform.h:121
XN_C_API XnStatus XN_C_DECL xnUSBDeviceSetConnectivityChangedCallback(XnUSBDevice *pDevice, XnUSBDeviceConnectivityChangedCallback pFunc, void *pCookie)
struct XnUSBInterfaceDescriptorHolder XnUSBInterfaceDescriptorHolder
Definition: XnUSBDevice.h:65
XN_C_API XnStatus XN_C_DECL xnUSBDeviceSetNewControlRequestCallback(XnUSBDevice *pDevice, XnUSBDeviceNewControlRequestCallback pFunc, void *pCookie)
XnUSBConfigDescriptor descriptor
Definition: XnUSBDevice.h:84
void(* XnUSBDeviceNewControlRequestCallback)(XnUSBDevice *pDevice, void *pCookie)
Definition: XnUSBDevice.h:99
XnUSBConfigDescriptorHolder ** aConfigurations
Definition: XnUSBDevice.h:91
XnUSBInterfaceDescriptor descriptor
Definition: XnUSBDevice.h:78
XN_C_API XnStatus XN_C_DECL xnUSBDeviceSendControlReply(XnUSBDevice *pDevice, const XnUChar *pBuffer, XnUInt32 nReplySize)
Definition: XnUSBDevice.h:82
Definition: XnUSBDevice.h:70
Definition: XnUSBDevice.h:67
XnUSBDeviceConnectionState
Definition: XnUSBDevice.h:63
XN_C_API XnStatus XN_C_DECL xnUSBDeviceReceiveControlRequest(XnUSBDevice *pDevice, XnUChar *pBuffer, XnUInt32 *pnRequestSize)
struct XnUSBConfigDescriptorHolder XnUSBConfigDescriptorHolder
struct XnUSBStringDescriptor XnUSBStringDescriptor