123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #ifndef DSI_LIBUSB_LIBRARY_HPP
- #define DSI_LIBUSB_LIBRARY_HPP
- #include "types.h"
- #include "usb.h"
- #include <memory>
- #include <windows.h>
- struct LibusbError
- {
- enum Enum
- {
- NONE,
- NO_LIBRARY,
- NO_FUNCTION
- };
- private: LibusbError();
- };
- class LibusbLibrary
- {
- public:
-
- static BOOL Load(std::auto_ptr<const LibusbLibrary>& clAutoLibrary_);
-
-
-
- LibusbLibrary();
- virtual ~LibusbLibrary() throw();
-
- typedef int (*ClaimInterface_t)(void*, int);
- typedef usb_bus* (*GetBusses_t)(void);
- typedef int (*ClearHalt_t)(usb_dev_handle*, unsigned int);
- typedef int (*GetStringSimple_t)(usb_dev_handle*,int,char*,size_t);
- typedef int (*Close_t)(usb_dev_handle*);
- typedef int (*Reset_t)(usb_dev_handle*);
- typedef void (*Init_t)(void);
- typedef int (*FindBusses_t)(void);
- typedef int (*FindDevices_t)(void);
- typedef usb_dev_handle* (*Open_t)(struct usb_device*);
- typedef int (*ReleaseInterface_t)(usb_dev_handle*, int);
- typedef int (*InterruptWrite_t)(usb_dev_handle*, int, char*, int, int);
- typedef int (*BulkRead_t)(usb_dev_handle*, int, char*, int, int);
- typedef struct usb_device* (*Device_t)(usb_dev_handle*);
- typedef int (*SetConfiguration_t)(usb_dev_handle*, int);
- typedef void (*SetDebug_t)(int);
-
- typedef int (*BulkSetupAsync_t)(usb_dev_handle *dev, void **context, unsigned char ep);
- typedef int (*SubmitAsync_t)(void *context, char *bytes, int size);
- typedef int (*ReapAsyncNocancel_t)(void *context, int timeout);
- typedef int (*CancelAsync_t)(void *context);
- typedef int (*FreeAsync_t)(void ** context);
- ClaimInterface_t ClaimInterface;
- GetBusses_t GetBusses;
- ClearHalt_t ClearHalt;
- GetStringSimple_t GetStringSimple;
- Close_t Close;
- Reset_t Reset;
- Init_t Init;
- FindBusses_t FindBusses;
- FindDevices_t FindDevices;
- Open_t Open;
- ReleaseInterface_t ReleaseInterface;
- InterruptWrite_t InterruptWrite;
- BulkRead_t BulkRead;
- Device_t Device;
- SetConfiguration_t SetConfiguration;
- SetDebug_t SetDebug;
-
- BulkSetupAsync_t BulkSetupAsync;
- SubmitAsync_t SubmitAsync;
- ReapAsyncNocancel_t ReapAsyncNocancel;
- CancelAsync_t CancelAsync;
- FreeAsync_t FreeAsync;
- private:
- LibusbError::Enum LoadFunctions();
- void FreeFunctions();
- static std::auto_ptr<LibusbLibrary> clAutoInstance;
-
-
-
- HMODULE hLibHandle;
- static BOOL bStaticSet;
-
- };
- #endif
|