![]() |
OpenNI 1.5.7
|
00001 /***************************************************************************** 00002 * * 00003 * OpenNI 1.x Alpha * 00004 * Copyright (C) 2012 PrimeSense Ltd. * 00005 * * 00006 * This file is part of OpenNI. * 00007 * * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); * 00009 * you may not use this file except in compliance with the License. * 00010 * You may obtain a copy of the License at * 00011 * * 00012 * http://www.apache.org/licenses/LICENSE-2.0 * 00013 * * 00014 * Unless required by applicable law or agreed to in writing, software * 00015 * distributed under the License is distributed on an "AS IS" BASIS, * 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00017 * See the License for the specific language governing permissions and * 00018 * limitations under the License. * 00019 * * 00020 *****************************************************************************/ 00021 #ifndef _XN_USB_DEVICE_H_ 00022 #define _XN_USB_DEVICE_H_ 00023 00024 //--------------------------------------------------------------------------- 00025 // Includes 00026 //--------------------------------------------------------------------------- 00027 #include "XnPlatform.h" 00028 #include "XnStatus.h" 00029 00030 #if (XN_PLATFORM == XN_PLATFORM_WIN32) 00031 00032 #include <Win32/usb100.h> 00033 typedef USB_ENDPOINT_DESCRIPTOR XnUSBEndpointDescriptor; 00034 typedef USB_INTERFACE_DESCRIPTOR XnUSBInterfaceDescriptor; 00035 typedef USB_CONFIGURATION_DESCRIPTOR XnUSBConfigDescriptor; 00036 typedef USB_DEVICE_DESCRIPTOR XnUSBDeviceDescriptor; 00037 00038 #define USB_DT_CONFIG_SIZE 0 00039 #define USB_DT_CONFIG 0 00040 #define USB_CONFIG_ATT_ONE 0 00041 #define USB_DT_ENDPOINT_SIZE 0 00042 #define USB_DT_ENDPOINT 0 00043 #define USB_ENDPOINT_XFER_BULK 0 00044 #define USB_DT_INTERFACE_SIZE 0 00045 #define USB_DT_INTERFACE 0 00046 #define USB_CLASS_VENDOR_SPEC 0 00047 #define USB_DT_DEVICE_SIZE 0 00048 #define USB_DT_DEVICE 0 00049 00050 #elif (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM) 00051 #include <linux/usb/ch9.h> 00052 typedef struct usb_endpoint_descriptor XnUSBEndpointDescriptor; 00053 typedef struct usb_interface_descriptor XnUSBInterfaceDescriptor; 00054 typedef struct usb_config_descriptor XnUSBConfigDescriptor; 00055 typedef struct usb_device_descriptor XnUSBDeviceDescriptor; 00056 #else 00057 #error "Unsupported Platform!" 00058 #endif 00059 00060 //--------------------------------------------------------------------------- 00061 // Structures & Enums 00062 //--------------------------------------------------------------------------- 00063 typedef enum XnUSBDeviceConnectionState 00064 { 00065 XN_USB_DEVICE_DISCONNECTED, 00066 XN_USB_DEVICE_CONNECTED, 00067 XN_USB_DEVICE_SUSPENDED, 00068 } XnUSBDeviceConnectionState; 00069 00070 typedef struct XnUSBStringDescriptor 00071 { 00072 XnUInt8 nID; 00073 const XnChar* strString; 00074 } XnUSBStringDescriptor; 00075 00076 typedef struct XnUSBInterfaceDescriptorHolder 00077 { 00078 XnUSBInterfaceDescriptor descriptor; 00079 XnUSBEndpointDescriptor** aEndpoints; 00080 } XnUSBInterfaceDescriptorHolder; 00081 00082 typedef struct XnUSBConfigDescriptorHolder 00083 { 00084 XnUSBConfigDescriptor descriptor; 00085 XnUSBInterfaceDescriptorHolder** aInterfaces; 00086 } XnUSBConfigDescriptorHolder; 00087 00088 typedef struct XnUSBDeviceDescriptorHolder 00089 { 00090 XnUSBDeviceDescriptor descriptor; 00091 XnUSBConfigDescriptorHolder** aConfigurations; 00092 XnUSBStringDescriptor* aStrings; 00093 XnUInt8 nStrings; 00094 } XnUSBDeviceDescriptorHolder; 00095 00096 struct XnUSBDevice; 00097 typedef struct XnUSBDevice XnUSBDevice; 00098 00099 typedef void (*XnUSBDeviceNewControlRequestCallback)(XnUSBDevice* pDevice, void* pCookie); 00100 typedef void (*XnUSBDeviceConnectivityChangedCallback)(XnUSBDevice* pDevice, XnUSBDeviceConnectionState state, void* pCookie); 00101 00102 //--------------------------------------------------------------------------- 00103 // API 00104 //--------------------------------------------------------------------------- 00105 XN_C_API XnStatus XN_C_DECL xnUSBDeviceInit(const XnUSBDeviceDescriptorHolder* pDeviceDescriptor, XnUInt32 nControlMessageMaxSize, XnUSBDevice** ppDevice); 00106 XN_C_API void XN_C_DECL xnUSBDeviceShutdown(XnUSBDevice* pDevice); 00107 XN_C_API XnBool XN_C_DECL xnUSBDeviceIsControlRequestPending(XnUSBDevice* pDevice); 00108 00109 //pnRequestSize is max size on input, actual size on output 00110 XN_C_API XnStatus XN_C_DECL xnUSBDeviceReceiveControlRequest(XnUSBDevice* pDevice, XnUChar* pBuffer, XnUInt32* pnRequestSize); 00111 XN_C_API XnStatus XN_C_DECL xnUSBDeviceSendControlReply(XnUSBDevice* pDevice, const XnUChar* pBuffer, XnUInt32 nReplySize); 00112 XN_C_API XnStatus XN_C_DECL xnUSBDeviceSetNewControlRequestCallback(XnUSBDevice* pDevice, XnUSBDeviceNewControlRequestCallback pFunc, void* pCookie); 00113 XN_C_API XnStatus XN_C_DECL xnUSBDeviceSetConnectivityChangedCallback(XnUSBDevice* pDevice, XnUSBDeviceConnectivityChangedCallback pFunc, void* pCookie); 00114 XN_C_API XnStatus XN_C_DECL xnUSBDeviceWriteEndpoint(XnUSBDevice* pDevice, XnUInt8 nAddress, const XnUChar* pData, XnUInt32 nDataSize); 00115 XN_C_API XnStatus XN_C_DECL xnUSBDeviceResetEndpoint(XnUSBDevice* pDevice, XnUInt8 nAddress); 00116 00117 #endif