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;
2015-05-03 06:40:20 +00:00
friend class CHIDDeviceWinUSB;
2015-04-24 00:24:15 +00:00
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 */
2015-05-10 07:02:18 +00:00
bool sendUSBInterruptTransfer(const uint8_t* data, size_t length);
size_t receiveUSBInterruptTransfer(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) {(void)data;(void)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