diff -r 1b423d877938 -r 7d34342ac6e9 MiniDisplay/HidDevice.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MiniDisplay/HidDevice.h Tue May 27 19:50:28 2014 +0200 @@ -0,0 +1,69 @@ +// +// +// + +#ifndef HID_DEVICE_H +#define HID_DEVICE_H + +#include "HidReport.h" +#include "hidapi.h" + +const int KMaxHidStringChar=256; + +/** +TODO: move to another header +*/ +class HidDevice + { +public: + HidDevice(); + int Open(const char* aPath); + int Open(unsigned short aVendorId, unsigned short aProductId, const wchar_t* aSerialNumber); + void Close(); + bool IsOpen(); + // + int SetNonBlocking(int aNonBlocking); + //Read + template + int Read(HidReport& aInputReport); + //Write + template + int Write(const HidReport& aOutputReport); + // + const wchar_t* Error(); + // + wchar_t* Vendor(); + wchar_t* Product(); + wchar_t* SerialNumber(); + +private: + void FetchStrings(); + +private: + ///Our USB HID device + hid_device* iHidDevice; + // + wchar_t iVendor[KMaxHidStringChar]; + wchar_t iProduct[KMaxHidStringChar]; + wchar_t iSerialNumber[KMaxHidStringChar]; + }; + + +/** +*/ +template +int HidDevice::Write(const HidReport& aOutputReport) + { + return hid_write(iHidDevice,aOutputReport.Buffer(),S); + } + +/** +*/ +template +int HidDevice::Read(HidReport& aInputReport) + { + return hid_read(iHidDevice,aInputReport.Buffer(),S); + } + + +#endif \ No newline at end of file