XnUSBDevice.h
Go to the documentation of this file.
/****************************************************************************
* *
* OpenNI 1.x Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of OpenNI. *
* *
* OpenNI is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* OpenNI is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
* *
****************************************************************************/
#ifndef _XN_USB_DEVICE_H_
#define _XN_USB_DEVICE_H_
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include "XnPlatform.h"
#include "XnStatus.h"
#if (XN_PLATFORM == XN_PLATFORM_WIN32)
#include <Win32/usb100.h>
typedef USB_ENDPOINT_DESCRIPTOR XnUSBEndpointDescriptor;
typedef USB_INTERFACE_DESCRIPTOR XnUSBInterfaceDescriptor;
typedef USB_CONFIGURATION_DESCRIPTOR XnUSBConfigDescriptor;
typedef USB_DEVICE_DESCRIPTOR XnUSBDeviceDescriptor;
#define USB_DT_CONFIG_SIZE 0
#define USB_DT_CONFIG 0
#define USB_CONFIG_ATT_ONE 0
#define USB_DT_ENDPOINT_SIZE 0
#define USB_DT_ENDPOINT 0
#define USB_ENDPOINT_XFER_BULK 0
#define USB_DT_INTERFACE_SIZE 0
#define USB_DT_INTERFACE 0
#define USB_CLASS_VENDOR_SPEC 0
#define USB_DT_DEVICE_SIZE 0
#define USB_DT_DEVICE 0
#elif (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM || XN_PLATFORM == XN_PLATFORM_LINUX_AARCH64 || XN_PLATFORM == XN_PLATFORM_LINUX_POWERPC || XN_PLATFORM == XN_PLATFORM_LINUX_MIPS || XN_PLATFORM == XN_PLATFORM_LINUX_RISCV64 || XN_PLATFORM == XN_PLATFORM_LINUX_LOONGARCH64)
#include <linux/usb/ch9.h>
typedef struct usb_endpoint_descriptor XnUSBEndpointDescriptor;
typedef struct usb_interface_descriptor XnUSBInterfaceDescriptor;
typedef struct usb_config_descriptor XnUSBConfigDescriptor;
typedef struct usb_device_descriptor XnUSBDeviceDescriptor;
#else
#error "Unsupported Platform!"
#endif
//---------------------------------------------------------------------------
// Structures & Enums
//---------------------------------------------------------------------------
typedef enum XnUSBDeviceConnectionState
{
XN_USB_DEVICE_DISCONNECTED,
XN_USB_DEVICE_CONNECTED,
XN_USB_DEVICE_SUSPENDED,
} XnUSBDeviceConnectionState;
typedef struct XnUSBStringDescriptor
{
XnUInt8 nID;
const XnChar* strString;
} XnUSBStringDescriptor;
typedef struct XnUSBInterfaceDescriptorHolder
{
XnUSBInterfaceDescriptor descriptor;
XnUSBEndpointDescriptor** aEndpoints;
} XnUSBInterfaceDescriptorHolder;
typedef struct XnUSBConfigDescriptorHolder
{
XnUSBConfigDescriptor descriptor;
XnUSBInterfaceDescriptorHolder** aInterfaces;
} XnUSBConfigDescriptorHolder;
typedef struct XnUSBDeviceDescriptorHolder
{
XnUSBDeviceDescriptor descriptor;
XnUSBConfigDescriptorHolder** aConfigurations;
XnUSBStringDescriptor* aStrings;
XnUInt8 nStrings;
} XnUSBDeviceDescriptorHolder;
struct XnUSBDevice;
typedef struct XnUSBDevice XnUSBDevice;
typedef void (*XnUSBDeviceNewControlRequestCallback)(XnUSBDevice* pDevice, void* pCookie);
typedef void (*XnUSBDeviceConnectivityChangedCallback)(XnUSBDevice* pDevice, XnUSBDeviceConnectionState state, void* pCookie);
//---------------------------------------------------------------------------
// API
//---------------------------------------------------------------------------
XN_C_API XnStatus XN_C_DECL xnUSBDeviceInit(const XnUSBDeviceDescriptorHolder* pDeviceDescriptor, XnUInt32 nControlMessageMaxSize, XnUSBDevice** ppDevice);
XN_C_API void XN_C_DECL xnUSBDeviceShutdown(XnUSBDevice* pDevice);
XN_C_API XnBool XN_C_DECL xnUSBDeviceIsControlRequestPending(XnUSBDevice* pDevice);
//pnRequestSize is max size on input, actual size on output
XN_C_API XnStatus XN_C_DECL xnUSBDeviceReceiveControlRequest(XnUSBDevice* pDevice, XnUChar* pBuffer, XnUInt32* pnRequestSize);
XN_C_API XnStatus XN_C_DECL xnUSBDeviceSendControlReply(XnUSBDevice* pDevice, const XnUChar* pBuffer, XnUInt32 nReplySize);
XN_C_API XnStatus XN_C_DECL xnUSBDeviceSetNewControlRequestCallback(XnUSBDevice* pDevice, XnUSBDeviceNewControlRequestCallback pFunc, void* pCookie);
XN_C_API XnStatus XN_C_DECL xnUSBDeviceSetConnectivityChangedCallback(XnUSBDevice* pDevice, XnUSBDeviceConnectivityChangedCallback pFunc, void* pCookie);
XN_C_API XnStatus XN_C_DECL xnUSBDeviceWriteEndpoint(XnUSBDevice* pDevice, XnUInt8 nAddress, const XnUChar* pData, XnUInt32 nDataSize);
#endif
XnPlatform.h
XN_C_API
#define XN_C_API
Definition XnPlatform.h:132
XnStatus.h
XnStatus
XnUInt32 XnStatus
Definition XnStatus.h:34
xnUSBDeviceWriteEndpoint
XN_C_API XnStatus XN_C_DECL xnUSBDeviceWriteEndpoint(XnUSBDevice *pDevice, XnUInt8 nAddress, const XnUChar *pData, XnUInt32 nDataSize)
xnUSBDeviceReceiveControlRequest
XN_C_API XnStatus XN_C_DECL xnUSBDeviceReceiveControlRequest(XnUSBDevice *pDevice, XnUChar *pBuffer, XnUInt32 *pnRequestSize)
XnUSBDeviceDescriptor
USB_DEVICE_DESCRIPTOR XnUSBDeviceDescriptor
Definition XnUSBDevice.h:37
xnUSBDeviceShutdown
XN_C_API void XN_C_DECL xnUSBDeviceShutdown(XnUSBDevice *pDevice)
xnUSBDeviceSetNewControlRequestCallback
XN_C_API XnStatus XN_C_DECL xnUSBDeviceSetNewControlRequestCallback(XnUSBDevice *pDevice, XnUSBDeviceNewControlRequestCallback pFunc, void *pCookie)
XnUSBDeviceConnectivityChangedCallback
void(* XnUSBDeviceConnectivityChangedCallback)(XnUSBDevice *pDevice, XnUSBDeviceConnectionState state, void *pCookie)
Definition XnUSBDevice.h:101
XnUSBDeviceNewControlRequestCallback
void(* XnUSBDeviceNewControlRequestCallback)(XnUSBDevice *pDevice, void *pCookie)
Definition XnUSBDevice.h:100
xnUSBDeviceInit
XN_C_API XnStatus XN_C_DECL xnUSBDeviceInit(const XnUSBDeviceDescriptorHolder *pDeviceDescriptor, XnUInt32 nControlMessageMaxSize, XnUSBDevice **ppDevice)
XnUSBDevice
struct XnUSBDevice XnUSBDevice
Definition XnUSBDevice.h:98
XnUSBEndpointDescriptor
USB_ENDPOINT_DESCRIPTOR XnUSBEndpointDescriptor
Definition XnUSBDevice.h:34
XnUSBConfigDescriptor
USB_CONFIGURATION_DESCRIPTOR XnUSBConfigDescriptor
Definition XnUSBDevice.h:36
XnUSBDeviceConnectionState
XnUSBDeviceConnectionState
Definition XnUSBDevice.h:65
XN_USB_DEVICE_CONNECTED
@ XN_USB_DEVICE_CONNECTED
Definition XnUSBDevice.h:67
XN_USB_DEVICE_DISCONNECTED
@ XN_USB_DEVICE_DISCONNECTED
Definition XnUSBDevice.h:66
XN_USB_DEVICE_SUSPENDED
@ XN_USB_DEVICE_SUSPENDED
Definition XnUSBDevice.h:68
xnUSBDeviceSendControlReply
XN_C_API XnStatus XN_C_DECL xnUSBDeviceSendControlReply(XnUSBDevice *pDevice, const XnUChar *pBuffer, XnUInt32 nReplySize)
XnUSBInterfaceDescriptor
USB_INTERFACE_DESCRIPTOR XnUSBInterfaceDescriptor
Definition XnUSBDevice.h:35
xnUSBDeviceSetConnectivityChangedCallback
XN_C_API XnStatus XN_C_DECL xnUSBDeviceSetConnectivityChangedCallback(XnUSBDevice *pDevice, XnUSBDeviceConnectivityChangedCallback pFunc, void *pCookie)
xnUSBDeviceIsControlRequestPending
XN_C_API XnBool XN_C_DECL xnUSBDeviceIsControlRequestPending(XnUSBDevice *pDevice)
XnUSBConfigDescriptorHolder
Definition XnUSBDevice.h:84
XnUSBConfigDescriptorHolder::descriptor
XnUSBConfigDescriptor descriptor
Definition XnUSBDevice.h:85
XnUSBConfigDescriptorHolder::aInterfaces
XnUSBInterfaceDescriptorHolder ** aInterfaces
Definition XnUSBDevice.h:86
XnUSBDeviceDescriptorHolder
Definition XnUSBDevice.h:90
XnUSBDeviceDescriptorHolder::nStrings
XnUInt8 nStrings
Definition XnUSBDevice.h:94
XnUSBDeviceDescriptorHolder::aStrings
XnUSBStringDescriptor * aStrings
Definition XnUSBDevice.h:93
XnUSBDeviceDescriptorHolder::descriptor
XnUSBDeviceDescriptor descriptor
Definition XnUSBDevice.h:91
XnUSBDeviceDescriptorHolder::aConfigurations
XnUSBConfigDescriptorHolder ** aConfigurations
Definition XnUSBDevice.h:92
XnUSBInterfaceDescriptorHolder
Definition XnUSBDevice.h:78
XnUSBInterfaceDescriptorHolder::descriptor
XnUSBInterfaceDescriptor descriptor
Definition XnUSBDevice.h:79
XnUSBInterfaceDescriptorHolder::aEndpoints
XnUSBEndpointDescriptor ** aEndpoints
Definition XnUSBDevice.h:80
XnUSBStringDescriptor
Definition XnUSBDevice.h:72
XnUSBStringDescriptor::nID
XnUInt8 nID
Definition XnUSBDevice.h:73
XnUSBStringDescriptor::strString
const XnChar * strString
Definition XnUSBDevice.h:74