cleanup
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user