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