boo/lib/inputdev/DeviceBase.cpp

74 lines
1.4 KiB
C++
Raw Normal View History

2015-08-18 22:43:30 +00:00
#include "boo/inputdev/DeviceBase.hpp"
#include "boo/inputdev/DeviceToken.hpp"
#include "IHIDDevice.hpp"
#include <cstdarg>
2015-04-29 10:24:39 +00:00
namespace boo
{
2015-08-18 19:40:26 +00:00
DeviceBase::DeviceBase(DeviceToken* token)
2015-04-24 00:24:15 +00:00
: m_token(token), m_hidDev(NULL)
{
}
2015-08-18 19:40:26 +00:00
DeviceBase::~DeviceBase()
{
delete m_hidDev;
}
2015-08-18 19:40:26 +00:00
void DeviceBase::_deviceDisconnected()
{
2015-04-22 21:48:23 +00:00
deviceDisconnected();
m_token = NULL;
if (m_hidDev)
{
m_hidDev->_deviceDisconnected();
delete m_hidDev;
m_hidDev = NULL;
}
}
2015-08-18 19:40:26 +00:00
void DeviceBase::closeDevice()
2015-04-22 21:48:23 +00:00
{
if (m_token)
m_token->_deviceClose();
}
void DeviceBase::deviceError(const char* error, ...)
{
va_list vl;
va_start(vl, error);
vfprintf(stderr, error, vl);
va_end(vl);
}
2015-08-18 19:40:26 +00:00
bool DeviceBase::sendUSBInterruptTransfer(const uint8_t* data, size_t length)
2015-04-24 00:24:15 +00:00
{
if (m_hidDev)
2015-05-10 07:02:18 +00:00
return m_hidDev->_sendUSBInterruptTransfer(data, length);
2015-04-24 00:24:15 +00:00
return false;
}
2015-08-18 19:40:26 +00:00
size_t DeviceBase::receiveUSBInterruptTransfer(uint8_t* data, size_t length)
2015-04-24 00:24:15 +00:00
{
if (m_hidDev)
2015-05-10 07:02:18 +00:00
return m_hidDev->_receiveUSBInterruptTransfer(data, length);
2015-04-24 00:24:15 +00:00
return false;
}
bool DeviceBase::sendHIDReport(const uint8_t* data, size_t length, uint16_t message)
{
if (m_hidDev)
return m_hidDev->_sendHIDReport(data, length, message);
return false;
}
size_t DeviceBase::receiveReport(uint8_t* data, size_t length, uint16_t message)
2015-04-24 00:24:15 +00:00
{
if (m_hidDev)
return m_hidDev->_recieveReport(data, length, message);
2015-04-24 00:24:15 +00:00
return false;
}
2015-04-29 10:24:39 +00:00
}