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-30 07:01:55 +00:00
|
|
|
#include <stdio.h>
|
2015-04-19 22:52:45 +00:00
|
|
|
|
2015-04-29 10:24:39 +00:00
|
|
|
namespace boo
|
|
|
|
{
|
|
|
|
|
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-30 07:01:55 +00:00
|
|
|
virtual void deviceError(const char* error) {fprintf(stderr, "%s\n", error);}
|
2015-04-24 00:24:15 +00:00
|
|
|
|
|
|
|
/* Low-Level API */
|
2015-04-30 23:17:46 +00:00
|
|
|
bool sendUSBInterruptTransfer(uint8_t pipe, const uint8_t* data, size_t length);
|
|
|
|
size_t receiveUSBInterruptTransfer(uint8_t pipe, uint8_t* data, size_t length);
|
2015-04-30 07:01:55 +00:00
|
|
|
virtual void initialCycle() {}
|
|
|
|
virtual void transferCycle() {}
|
|
|
|
virtual void finalCycle() {}
|
2015-04-24 00:24:15 +00:00
|
|
|
|
|
|
|
/* High-Level API */
|
2015-04-30 23:17:46 +00:00
|
|
|
bool sendHIDReport(const uint8_t* data, size_t length);
|
2015-04-30 07:01:55 +00:00
|
|
|
virtual size_t receiveReport(uint8_t* data, size_t length) {return 0;}
|
2015-04-24 00:24:15 +00:00
|
|
|
|
2015-04-19 22:52:45 +00:00
|
|
|
};
|
|
|
|
|
2015-04-29 10:24:39 +00:00
|
|
|
}
|
|
|
|
|
2015-04-19 22:52:45 +00:00
|
|
|
#endif // CDEVICEBASE
|