sl@0: // sl@0: // sl@0: // sl@0: sl@0: #ifndef HID_DEVICE_H sl@0: #define HID_DEVICE_H sl@0: sl@0: #include "HidReport.h" sl@0: #include "hidapi.h" sl@0: sl@0: const int KMaxHidStringChar=256; sl@0: sl@0: /** sl@0: TODO: move to another header sl@0: */ sl@0: class HidDevice sl@0: { sl@0: public: sl@0: HidDevice(); sl@7: virtual ~HidDevice(); sl@7: // sl@0: int Open(const char* aPath); sl@0: int Open(unsigned short aVendorId, unsigned short aProductId, const wchar_t* aSerialNumber); sl@0: void Close(); sl@0: bool IsOpen(); sl@0: // sl@0: int SetNonBlocking(int aNonBlocking); sl@0: //Read sl@0: template sl@0: int Read(HidReport& aInputReport); sl@0: //Write sl@0: template sl@0: int Write(const HidReport& aOutputReport); sl@0: // sl@0: const wchar_t* Error(); sl@0: // sl@0: wchar_t* Vendor(); sl@0: wchar_t* Product(); sl@0: wchar_t* SerialNumber(); sl@0: sl@0: private: sl@0: void FetchStrings(); sl@0: sl@0: private: sl@0: ///Our USB HID device sl@0: hid_device* iHidDevice; sl@0: // sl@0: wchar_t iVendor[KMaxHidStringChar]; sl@0: wchar_t iProduct[KMaxHidStringChar]; sl@0: wchar_t iSerialNumber[KMaxHidStringChar]; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: */ sl@0: template sl@0: int HidDevice::Write(const HidReport& aOutputReport) sl@0: { sl@0: return hid_write(iHidDevice,aOutputReport.Buffer(),S); sl@0: } sl@0: sl@0: /** sl@0: */ sl@0: template sl@0: int HidDevice::Read(HidReport& aInputReport) sl@0: { sl@0: return hid_read(iHidDevice,aInputReport.Buffer(),S); sl@0: } sl@0: sl@0: sl@0: #endif