# 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 @@
+
+
+
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
-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
-void HidReport::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 Write(const HidReport& aOutputReport);
- //
- const wchar_t* Error();
-
-
-
-private:
- ///Our USB HID device
- hid_device* iHidDevice;
- };
-
-
-/**
-*/
-template
-int HidDevice::Write(const HidReport& 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 Write(const HidReport& aOutputReport);
+ //
+ const wchar_t* Error();
+
+private:
+ ///Our USB HID device
+ hid_device* iHidDevice;
+ };
+
+
+/**
+*/
+template
+int HidDevice::Write(const HidReport& 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
+
+/**
+Define an HID report.
+Can be used as input and output.
+*/
+template
+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
+void HidReport::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);
+ }