2015-04-19 22:52:45 +00:00
|
|
|
#ifndef CDEVICEBASE
|
|
|
|
#define CDEVICEBASE
|
|
|
|
|
2015-04-24 00:24:15 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
2015-04-19 22:52:45 +00:00
|
|
|
|
|
|
|
class CDeviceBase
|
|
|
|
{
|
2015-04-24 00:24:15 +00:00
|
|
|
friend class CDeviceToken;
|
|
|
|
friend class CHIDDeviceIOKit;
|
|
|
|
friend class CHIDDeviceUdev;
|
|
|
|
friend class CHIDDeviceWin32;
|
|
|
|
|
|
|
|
class CDeviceToken* m_token;
|
|
|
|
class IHIDDevice* m_hidDev;
|
2015-04-22 21:48:23 +00:00
|
|
|
void _deviceDisconnected();
|
2015-04-24 00:24:15 +00:00
|
|
|
|
2015-04-19 22:52:45 +00:00
|
|
|
public:
|
2015-04-24 00:24:15 +00:00
|
|
|
CDeviceBase(CDeviceToken* token);
|
2015-04-23 00:46:32 +00:00
|
|
|
virtual ~CDeviceBase();
|
2015-04-22 21:48:23 +00:00
|
|
|
void closeDevice();
|
2015-04-21 04:02:43 +00:00
|
|
|
virtual void deviceDisconnected()=0;
|
2015-04-24 00:24:15 +00:00
|
|
|
|
|
|
|
/* Low-Level API */
|
|
|
|
bool sendInterruptTransfer(uint8_t pipe, const uint8_t* data, size_t length);
|
|
|
|
size_t receiveInterruptTransfer(uint8_t pipe, uint8_t* data, size_t length);
|
|
|
|
virtual void transferCycle() {};
|
2015-04-26 08:25:44 +00:00
|
|
|
virtual void finalCycle() {};
|
2015-04-24 00:24:15 +00:00
|
|
|
|
|
|
|
/* High-Level API */
|
|
|
|
bool sendReport(const uint8_t* data, size_t length);
|
|
|
|
virtual size_t receiveReport(uint8_t* data, size_t length) {};
|
|
|
|
|
2015-04-19 22:52:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CDEVICEBASE
|