author | sl |
Thu, 22 May 2014 07:50:02 +0200 | |
changeset 14 | 4a5538e0ccbf |
child 15 | e5b84f315be7 |
permissions | -rw-r--r-- |
sl@14 | 1 |
// |
sl@14 | 2 |
// |
sl@14 | 3 |
// |
sl@14 | 4 |
|
sl@14 | 5 |
#ifndef HID_DEVICE_H |
sl@14 | 6 |
#define HID_DEVICE_H |
sl@14 | 7 |
|
sl@14 | 8 |
#include "HidReport.h" |
sl@14 | 9 |
#include "hidapi.h" |
sl@14 | 10 |
|
sl@14 | 11 |
|
sl@14 | 12 |
/** |
sl@14 | 13 |
TODO: move to another header |
sl@14 | 14 |
*/ |
sl@14 | 15 |
class HidDevice |
sl@14 | 16 |
{ |
sl@14 | 17 |
public: |
sl@14 | 18 |
int Open(const char* aPath); |
sl@14 | 19 |
int Open(unsigned short aVendorId, unsigned short aProductId, const wchar_t* aSerialNumber); |
sl@14 | 20 |
void Close(); |
sl@14 | 21 |
bool IsOpen(); |
sl@14 | 22 |
// |
sl@14 | 23 |
int SetNonBlocking(int aNonBlocking); |
sl@14 | 24 |
// |
sl@14 | 25 |
template<int S> |
sl@14 | 26 |
int Write(const HidReport<S>& aOutputReport); |
sl@14 | 27 |
// |
sl@14 | 28 |
const wchar_t* Error(); |
sl@14 | 29 |
|
sl@14 | 30 |
private: |
sl@14 | 31 |
///Our USB HID device |
sl@14 | 32 |
hid_device* iHidDevice; |
sl@14 | 33 |
}; |
sl@14 | 34 |
|
sl@14 | 35 |
|
sl@14 | 36 |
/** |
sl@14 | 37 |
*/ |
sl@14 | 38 |
template<int S> |
sl@14 | 39 |
int HidDevice::Write(const HidReport<S>& aOutputReport) |
sl@14 | 40 |
{ |
sl@14 | 41 |
return hid_write(iHidDevice,aOutputReport.Buffer(),S); |
sl@14 | 42 |
} |
sl@14 | 43 |
|
sl@14 | 44 |
|
sl@14 | 45 |
#endif |