//------------------------------------------------------------------------------ // USBDeviceManager.h // // SILAB, Phys. Inst Bonn, HK // // Handle multiple USB devices associated to slbusb.sys device driver // // History: // 31.01.03 BLUETRAK version!!! // 03.10.01 HK created // 22.02.02 PF see .cpp file //------------------------------------------------------------------------------ #ifndef USBDeviceManagerH #define USBDeviceManagerH #include #include #include "SiUSBDevice.h" const int MAX_USB_DEV_NUMBER = 8; // number supported by .sys driver /* typedef enum { // these different configurations EZUSB, // are distinguished by the USB_CONTROLLER_U, USB_CONTROLLER, // ProductID USB_RFDONGLE_U, USB_RFDONGLE, USB_TRACKER_U, USB_TRACKER, USB_BLUETRAK_U = 0x0050, USB_BLUETRAK = 0x0051, USB_MUXBOARD = 0x0071, USB_BLUEREF_U, USB_BLUEREF } SLB_USB_DEVICE_TYPE_NAME; */ typedef struct _SLB_USB_DEVICE_TYPE // Used in constant array 'DeviceTypeList' { unsigned short VendorID; unsigned short ProductID; // SLB_USB_DEVICE_TYPE_NAME DeviceTypeName; char * FirmwareFilename; } SLB_USB_DEVICE_TYPE; typedef struct _USB_DEVICE_LIST_ITEM { bool DevicePresent; TUSBDevice * Device; //SLB_USB_DEVICE_TYPE_NAME DeviceTypeName; } USB_DEVICE_LIST_ITEM; class TUSBDevice; class TUSBDeviceManager { public: TUSBDeviceManager(); ~TUSBDeviceManager(); bool HandleDeviceChange(void); #ifdef CF__LINUX bool HandleDeviceChange2(int dev); #endif int DevToIndex(TUSBDevice *dev); int DevToId(TUSBDevice *dev); bool IsBusy(); int GetNumberofDevices(); int GetMaxNumberofDevices(); void ForceRefresh(); void SetAddCallBack(void (*addfunc) (TUSBDevice*, void*), void *cnt); void SetRemoveCallBack(void (*remfunc) (TUSBDevice*, void*), void *cnt); // void* GetDevice(SLB_USB_DEVICE_TYPE_NAME Name); void* GetDevice(int id = -1); void* GetDevice(int id, int DevClass); USB_DEVICE_LIST_ITEM DeviceList[MAX_USB_DEV_NUMBER]; std::vector devInfoStrings; private: bool AddDeviceToList (int index); bool RemoveDeviceFromList (int index); int UpdateDevStringList (); bool busy; void * DeviceContext; void (* onDevicePlugged) (TUSBDevice* dev, void *ptr); void (* onDeviceUnplugged) (TUSBDevice* dev, void *ptr); }; #endif