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