# HG changeset patch
# User sl
# Date 1400737802 -7200
# Node ID 4a5538e0ccbfffda0cd2bc2fa1ff79606ffedc5a
# Parent  69f1fcfdf6a51dcbea487e19da943640f1e73701
Moving base HID classes into separate files.

diff -r 69f1fcfdf6a5 -r 4a5538e0ccbf FutabaVfd.vcxproj
--- a/FutabaVfd.vcxproj	Thu May 22 07:30:05 2014 +0200
+++ b/FutabaVfd.vcxproj	Thu May 22 07:50:02 2014 +0200
@@ -105,12 +105,15 @@
   <ItemGroup>
     <ClCompile Include="..\hidapi\windows\hid.c" />
     <ClCompile Include="src\FutabaVfd.cpp" />
+    <ClCompile Include="src\HidDevice.cpp" />
     <ClCompile Include="src\Main.cpp" />
     <ClCompile Include="src\test.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\hidapi\hidapi\hidapi.h" />
     <ClInclude Include="inc\FutabaVfd.h" />
+    <ClInclude Include="inc\HidDevice.h" />
+    <ClInclude Include="inc\HidReport.h" />
     <ClInclude Include="inc\MainWindow.h" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff -r 69f1fcfdf6a5 -r 4a5538e0ccbf inc/FutabaVfd.h
--- a/inc/FutabaVfd.h	Thu May 22 07:30:05 2014 +0200
+++ b/inc/FutabaVfd.h	Thu May 22 07:50:02 2014 +0200
@@ -4,6 +4,7 @@
 #define FUTABA_VFD_H
 
 #include "hidapi.h"
+#include "HidDevice.h"
 
 //This was computed from our number of pixels as follow 256x64/8/64 = 32 + 1 = 33
 //+1 was added for our header
@@ -21,61 +22,6 @@
 
 //typedef struct hid_device_info HidDeviceInfo;
 
-/**
-TODO: move to another header
-*/
-template <int S>
-class HidReport
-	{
-public:
-	HidReport(){Reset();};
-	void Reset();
-	inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];}
-	const unsigned char* Buffer() const {return iBuffer;};
-	unsigned char* Buffer() {return iBuffer;};
-protected:
-	unsigned char iBuffer[S];
-	};
-
-template <int S>
-void HidReport<S>::Reset()
-    {
-    memset(iBuffer,0,sizeof(iBuffer));
-    }
-
-/**
-TODO: move to another header
-*/
-class HidDevice
-	{
-public:
-	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);
-	//
-	template<int S>
-	int Write(const HidReport<S>& aOutputReport);
-	//
-	const wchar_t* Error();
-
-
-
-private:
-	///Our USB HID device
-	hid_device* iHidDevice;
-	};
-
-
-/**
-*/
-template<int S>
-int HidDevice::Write(const HidReport<S>& aOutputReport)
-	{
-	return hid_write(iHidDevice,aOutputReport.Buffer(),S);
-	}
 
 
 /**
diff -r 69f1fcfdf6a5 -r 4a5538e0ccbf inc/HidDevice.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/HidDevice.h	Thu May 22 07:50:02 2014 +0200
@@ -0,0 +1,45 @@
+//
+//
+//
+
+#ifndef HID_DEVICE_H
+#define HID_DEVICE_H
+
+#include "HidReport.h"
+#include "hidapi.h"
+
+
+/**
+TODO: move to another header
+*/
+class HidDevice
+    {
+public:
+    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);
+    //
+    template<int S>
+    int Write(const HidReport<S>& aOutputReport);
+    //
+    const wchar_t* Error();
+
+private:
+    ///Our USB HID device
+    hid_device* iHidDevice;
+    };
+
+
+/**
+*/
+template<int S>
+int HidDevice::Write(const HidReport<S>& aOutputReport)
+    {
+    return hid_write(iHidDevice,aOutputReport.Buffer(),S);
+    }
+
+
+#endif
\ No newline at end of file
diff -r 69f1fcfdf6a5 -r 4a5538e0ccbf inc/HidReport.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/HidReport.h	Thu May 22 07:50:02 2014 +0200
@@ -0,0 +1,30 @@
+#ifndef HID_REPORT_H
+#define HID_REPORT_H
+
+#include <string.h>
+
+/**
+Define an HID report.
+Can be used as input and output.
+*/
+template <int S>
+class HidReport
+    {
+public:
+    HidReport(){Reset();};
+    void Reset();
+    inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];}
+    const unsigned char* Buffer() const {return iBuffer;};
+    unsigned char* Buffer() {return iBuffer;};
+protected:
+    unsigned char iBuffer[S];
+    };
+
+template <int S>
+void HidReport<S>::Reset()
+    {
+    memset(iBuffer,0,sizeof(iBuffer));
+    }
+
+
+#endif
\ No newline at end of file
diff -r 69f1fcfdf6a5 -r 4a5538e0ccbf src/FutabaVfd.cpp
--- a/src/FutabaVfd.cpp	Thu May 22 07:30:05 2014 +0200
+++ b/src/FutabaVfd.cpp	Thu May 22 07:50:02 2014 +0200
@@ -65,74 +65,6 @@
 */
 
 
-//
-// class HidDevice
-//
-
-/**
-*/
-int HidDevice::Open(const char* aPath)
-	{
-	Close();
-
-	iHidDevice =  hid_open_path(aPath);
-
-	if (!iHidDevice)
-		{
-		//Fail to connect our device
-		return 0;
-		}
-
-	return 1;
-	}
-
-/**
-See hidapi documentation.
-*/
-int HidDevice::Open(unsigned short aVendorId, unsigned short aProductId, const wchar_t* aSerialNumber)
-	{
-	iHidDevice = hid_open(aVendorId, aProductId, aSerialNumber);
-
-	if (!iHidDevice)
-		{
-		//Fail to connect our device
-		return 0;
-		}
-
-	return 1;
-	}
-
-/**
-*/
-void HidDevice::Close()
-	{
-	hid_close(iHidDevice);
-	iHidDevice=NULL;
-	}
-
-/**
-*/
-bool HidDevice::IsOpen()
-    {
-    return iHidDevice!=NULL;
-    }
-
-
-/**
-*/
-const wchar_t* HidDevice::Error()
-	{
-	return hid_error(iHidDevice);
-	}
-
-/**
-*/
-int HidDevice::SetNonBlocking(int aNonBlocking)
-	{
-	//Success we are now connected to our HID device
-	//Set read operation as non blocking
-	return hid_set_nonblocking(iHidDevice, aNonBlocking);
-	}
 
 
 //
diff -r 69f1fcfdf6a5 -r 4a5538e0ccbf src/HidDevice.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/HidDevice.cpp	Thu May 22 07:50:02 2014 +0200
@@ -0,0 +1,76 @@
+//
+//
+//
+
+#include "HidDevice.h"
+
+
+
+//
+// class HidDevice
+//
+
+/**
+*/
+int HidDevice::Open(const char* aPath)
+	{
+	Close();
+
+	iHidDevice =  hid_open_path(aPath);
+
+	if (!iHidDevice)
+		{
+		//Fail to connect our device
+		return 0;
+		}
+
+	return 1;
+	}
+
+/**
+See hidapi documentation.
+*/
+int HidDevice::Open(unsigned short aVendorId, unsigned short aProductId, const wchar_t* aSerialNumber)
+	{
+	iHidDevice = hid_open(aVendorId, aProductId, aSerialNumber);
+
+	if (!iHidDevice)
+		{
+		//Fail to connect our device
+		return 0;
+		}
+
+	return 1;
+	}
+
+/**
+*/
+void HidDevice::Close()
+	{
+	hid_close(iHidDevice);
+	iHidDevice=NULL;
+	}
+
+/**
+*/
+bool HidDevice::IsOpen()
+    {
+    return iHidDevice!=NULL;
+    }
+
+
+/**
+*/
+const wchar_t* HidDevice::Error()
+	{
+	return hid_error(iHidDevice);
+	}
+
+/**
+*/
+int HidDevice::SetNonBlocking(int aNonBlocking)
+	{
+	//Success we are now connected to our HID device
+	//Set read operation as non blocking
+	return hid_set_nonblocking(iHidDevice, aNonBlocking);
+	}