OpenNI 1.3.2

XnUSBDevice.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 *                                                                           *
00003 *  OpenNI 1.1 Alpha                                                         *
00004 *  Copyright (C) 2011 PrimeSense Ltd.                                       *
00005 *                                                                           *
00006 *  This file is part of OpenNI.                                             *
00007 *                                                                           *
00008 *  OpenNI is free software: you can redistribute it and/or modify           *
00009 *  it under the terms of the GNU Lesser General Public License as published *
00010 *  by the Free Software Foundation, either version 3 of the License, or     *
00011 *  (at your option) any later version.                                      *
00012 *                                                                           *
00013 *  OpenNI is distributed in the hope that it will be useful,                *
00014 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00015 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             *
00016 *  GNU Lesser General Public License for more details.                      *
00017 *                                                                           *
00018 *  You should have received a copy of the GNU Lesser General Public License *
00019 *  along with OpenNI. If not, see <http://www.gnu.org/licenses/>.           *
00020 *                                                                           *
00021 ****************************************************************************/
00022 #ifndef _XN_USB_DEVICE_H_
00023 #define _XN_USB_DEVICE_H_
00024 
00025 //---------------------------------------------------------------------------
00026 // Includes
00027 //---------------------------------------------------------------------------
00028 #include "XnPlatform.h"
00029 #include "XnStatus.h"
00030 
00031 #if (XN_PLATFORM == XN_PLATFORM_WIN32)
00032     #include <usb100.h>
00033     typedef struct USB_ENDPOINT_DESCRIPTOR XnUSBEndpointDescriptor;
00034     typedef struct USB_INTERFACE_DESCRIPTOR XnUSBInterfaceDescriptor;
00035     typedef struct USB_CONFIGURATION_DESCRIPTOR XnUSBConfigDescriptor;
00036     typedef struct USB_DEVICE_DESCRIPTOR XnUSBDeviceDescriptor;
00037 #elif (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM)
00038     #include <linux/usb/ch9.h>
00039     typedef struct usb_endpoint_descriptor XnUSBEndpointDescriptor;
00040     typedef struct usb_interface_descriptor XnUSBInterfaceDescriptor;
00041     typedef struct usb_config_descriptor XnUSBConfigDescriptor;
00042     typedef struct usb_device_descriptor XnUSBDeviceDescriptor;
00043 #else
00044     #error "Unsupported Platform!"
00045 #endif
00046 
00047 //---------------------------------------------------------------------------
00048 // Structures & Enums
00049 //---------------------------------------------------------------------------
00050 typedef struct XnUSBStringDescriptor
00051 {
00052     XnUInt8 nID;
00053     const XnChar* strString;
00054 } XnUSBStringDescriptor;
00055 
00056 typedef struct XnUSBInterfaceDescriptorHolder
00057 {
00058     XnUSBInterfaceDescriptor descriptor;
00059     XnUSBEndpointDescriptor** aEndpoints;   
00060 } XnUSBInterfaceDescriptorHolder;
00061 
00062 typedef struct XnUSBConfigDescriptorHolder
00063 {
00064     XnUSBConfigDescriptor descriptor;
00065     XnUSBInterfaceDescriptorHolder** aInterfaces;
00066 } XnUSBConfigDescriptorHolder;
00067 
00068 typedef struct XnUSBDeviceDescriptorHolder
00069 {
00070     XnUSBDeviceDescriptor descriptor;
00071     XnUSBConfigDescriptorHolder** aConfigurations;
00072     XnUSBStringDescriptor* aStrings;
00073     XnUInt8 nStrings;
00074 } XnUSBDeviceDescriptorHolder;
00075 
00076 struct XnUSBDevice;
00077 typedef struct XnUSBDevice XnUSBDevice;
00078 
00079 typedef void (*XnUSBDeviceNewControlRequestCallback)(XnUSBDevice* pDevice, void* pCookie);
00080 
00081 //---------------------------------------------------------------------------
00082 // API
00083 //---------------------------------------------------------------------------
00084 XN_C_API XnStatus XN_C_DECL xnUSBDeviceInit(const XnUSBDeviceDescriptorHolder* pDeviceDescriptor, XnUInt32 nControlMessageMaxSize, XnUSBDevice** ppDevice);
00085 XN_C_API void XN_C_DECL xnUSBDeviceShutdown(XnUSBDevice* pDevice);
00086 XN_C_API XnBool XN_C_DECL xnUSBDeviceIsControlRequestPending(XnUSBDevice* pDevice);
00087 XN_C_API XnStatus XN_C_DECL xnUSBDeviceReceiveControlRequest(XnUSBDevice* pDevice, XnUChar* pBuffer, XnUInt32* pnRequestSize);
00088 XN_C_API XnStatus XN_C_DECL xnUSBDeviceSendControlReply(XnUSBDevice* pDevice, const XnUChar* pBuffer, XnUInt32 nReplySize);
00089 XN_C_API XnStatus XN_C_DECL xnUSBDeviceSetNewControlRequestCallback(XnUSBDevice* pDevice, XnUSBDeviceNewControlRequestCallback pFunc, void* pCookie);
00090 XN_C_API XnStatus XN_C_DECL xnUSBDeviceWriteEndpoint(XnUSBDevice* pDevice, XnUInt8 nAddress, XnUChar* pData, XnUInt32 nDataSize);
00091 
00092 #endif