This commit is contained in:
Glenn Maynard
2003-07-14 06:24:30 +00:00
parent 647c96ecac
commit da6685a3a4
2 changed files with 162 additions and 81 deletions
+30 -8
View File
@@ -1,20 +1,42 @@
#ifndef WIN32_USB_H
#define WIN32_USB_H
class USBDevice
#include <vector>
/* The API for Windows device I/O is obscenely horrible, so encapsulate it. */
class WindowsFileIO
{
public:
USBDevice();
~USBDevice();
int GetPadEvent();
bool Open(int VID, int PID, int num);
bool IsOpen();
WindowsFileIO();
~WindowsFileIO();
bool Open(CString path, int blocksize);
bool IsOpen() const;
/* Returns the amount of data read. */
/* If nonblocking is true, this will */
/* Nonblocking read. size must always be the same. Returns the number of bytes
* read, or 0. */
int read(void *p);
static int read_several(const vector<WindowsFileIO *> &sources, void *p, int &actual, float timeout);
private:
HANDLE h;
OVERLAPPED ov;
long buf;
bool pending;
char *buf;
int blocksize;
void queue_read();
int finish_read(void *p);
};
class USBDevice
{
public:
int GetPadEvent();
bool Open(int VID, int PID, int blocksize, int num);
bool IsOpen() const;
WindowsFileIO io;
};
#endif