boo/include/inputdev/CDeviceBase.hpp

45 lines
1.1 KiB
C++
Raw Normal View History

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>
#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);
virtual ~CDeviceBase();
2015-04-22 21:48:23 +00:00
void closeDevice();
virtual void deviceDisconnected()=0;
virtual void deviceError(const char* error) {fprintf(stderr, "%s\n", error);}
2015-04-24 00:24:15 +00:00
/* Low-Level API */
bool sendUSBInterruptTransfer(uint8_t pipe, const uint8_t* data, size_t length);
size_t receiveUSBInterruptTransfer(uint8_t pipe, uint8_t* data, size_t length);
virtual void initialCycle() {}
virtual void transferCycle() {}
virtual void finalCycle() {}
2015-04-24 00:24:15 +00:00
/* High-Level API */
bool sendHIDReport(const uint8_t* data, size_t length);
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