#-------------------------------------------------
#
# Project created by QtCreator 2010-02-01T13:39:43
#
#-------------------------------------------------
QT -= gui
TARGET = hiddevice
TEMPLATE = lib
DEFINES += HIDDEVICE_LIBRARY
SOURCES += hiddevice.cpp
HEADERS += hiddevice.h\
hiddevice_global.h
LIBS += -L"../../mingw/lib" \
-lhid \
-L"../../mingw/lib" \
-lsetupapi
QMAKE_LFLAGS += -Xlinker -Bstatic
#-------------------------------------------------
#
# Project created by QtCreator 2010-02-01T13:39:43
#
#-------------------------------------------------
QT -= gui
TARGET = hiddevice
TEMPLATE = lib
DEFINES += HIDDEVICE_LIBRARY
SOURCES += hiddevice.cpp
HEADERS += hiddevice.h\
hiddevice_global.h
LIBS += -L"../../mingw/lib" \
-lhid \
-L"../../mingw/lib" \
-lsetupapi
QMAKE_LFLAGS += -Xlinker -Bstatic
To copy to clipboard, switch view to plain text mode
#ifndef HIDDEVICE_GLOBAL_H
#define HIDDEVICE_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(HIDDEVICE_LIBRARY)
# define HIDDEVICESHARED_EXPORT Q_DECL_EXPORT
#else
# define HIDDEVICESHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // HIDDEVICE_GLOBAL_H
#ifndef HIDDEVICE_GLOBAL_H
#define HIDDEVICE_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(HIDDEVICE_LIBRARY)
# define HIDDEVICESHARED_EXPORT Q_DECL_EXPORT
#else
# define HIDDEVICESHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // HIDDEVICE_GLOBAL_H
To copy to clipboard, switch view to plain text mode
#ifndef HIDDEVICE_H
#define HIDDEVICE_H
#include "hiddevice_global.h"
#include <qt_windows.h>
#include <dbt.h>
#include <stdlib.h>
extern "C" {
#include "../../mingw/include/ddk/hidsdi.h"
#include "../../mingw/include/setupapi.h"
}
#include <qDebug>
//#include <QThread>
#include <QMutex>
//if new version files for QT/MINGW need to remove any dependancy on #if _WIN32_WINNT >= 0x0500 to fix
//compile errors, should be in mingw/include/winuser.h, dbt.h, until we can figure out how to get it to build
//correctly~!
//Return Codes
#define HID_DEVICE_SUCCESS 0x00
#define HID_DEVICE_NOT_FOUND 0X01
#define HID_DEVICE_NOT_OPENED 0x02
#define HID_DEVICE_ALREADY_OPENED 0x03
#define HID_DEVICE_TRANSFER_TIMEOUT 0x04
#define HID_DEVICE_TRANSFER_FAILED 0x05
#define HID_DEVICE_CANNOT_GET_HID_INFO 0x06
#define HID_DEVICE_HANDLE_ERROR 0x07
#define HID_DEVICE_INVALID_BUFFER_SIZE 0x08
#define HID_DEVICE_SYSTEM_CODE 0x09
#define HID_DEVICE_UNKNOWN_ERROR 0xFF
//Max number of USB DEVICES allowed
#define MAX_USB_DEVICES 64
//Max Report Requests at a time
#define MAX_REPORT_REQUEST_XP 512
#define MAX_REPORT_REQUEST_2K 200
#define DEFAULT_REPORT_INPUT_BUFFERS 0
#define MAX_SERIAL_STRING_LENGTH 256
class HIDDEVICESHARED_EXPORT HIDDevice {
public:
HIDDevice();
void resetDeviceData();
DWORD getConnectedDeviceNum(WORD vid, WORD pid);
BYTE getSerialString(DWORD deviceIndex, WORD vid, WORD pid, LPSTR serialString, DWORD serialStringLength);
BYTE close();
bool isOpened();
BYTE Open(DWORD deviceIndex, WORD vid, WORD pid, WORD numInputBuffers);
bool getHidDevicePath(DWORD index, char* devicePath);
HANDLE openDeviceByVidPid(char* devicePath, WORD vid, WORD pid);
BYTE setReport_Feature(BYTE* buffer, DWORD bufferSize);
BYTE getReport_Feature(BYTE* buffer, DWORD bufferSize);
BYTE setReport_Interrupt(BYTE* buffer, DWORD bufferSize);
BYTE getReport_Interrupt(BYTE* buffer, DWORD bufferSize, WORD numReports, DWORD* bytesReturned);
// BYTE setReport_Control(BYTE* buffer, DWORD bufferSize); //not imp in qt/mingw...
// BYTE getReport_Control(BYTE* buffer, DWORD bufferSize); //not imp in qt/mingw...
WORD getInputReportBufferLength();
WORD getOutputReportBufferLength();
WORD getFeatureReportBufferLength();
WORD getMaxReportRequest();
bool flushBuffers();
void setTimeouts(UINT getReportTimeout, UINT setReportTimeout);
void getTimeouts(UINT* getReportTimeout, UINT* setReportTimeout);
virtual ~HIDDevice();
protected:
private:
HANDLE m_Handle;
bool m_DeviceOpened;
UINT m_GetReportTimeout;
UINT m_SetReportTimeout;
WORD m_InputReportBufferLength;
WORD m_OutputReportBufferLength;
WORD m_FeatureReportBufferLength;
WORD m_MaxReportRequest;
};
#define LOCK_MUTEX() mutex->lock();
#define UNLOCK_MUTEX() mutex->unlock();
#endif // HIDDEVICE_H
#ifndef HIDDEVICE_H
#define HIDDEVICE_H
#include "hiddevice_global.h"
#include <qt_windows.h>
#include <dbt.h>
#include <stdlib.h>
extern "C" {
#include "../../mingw/include/ddk/hidsdi.h"
#include "../../mingw/include/setupapi.h"
}
#include <qDebug>
//#include <QThread>
#include <QMutex>
//if new version files for QT/MINGW need to remove any dependancy on #if _WIN32_WINNT >= 0x0500 to fix
//compile errors, should be in mingw/include/winuser.h, dbt.h, until we can figure out how to get it to build
//correctly~!
//Return Codes
#define HID_DEVICE_SUCCESS 0x00
#define HID_DEVICE_NOT_FOUND 0X01
#define HID_DEVICE_NOT_OPENED 0x02
#define HID_DEVICE_ALREADY_OPENED 0x03
#define HID_DEVICE_TRANSFER_TIMEOUT 0x04
#define HID_DEVICE_TRANSFER_FAILED 0x05
#define HID_DEVICE_CANNOT_GET_HID_INFO 0x06
#define HID_DEVICE_HANDLE_ERROR 0x07
#define HID_DEVICE_INVALID_BUFFER_SIZE 0x08
#define HID_DEVICE_SYSTEM_CODE 0x09
#define HID_DEVICE_UNKNOWN_ERROR 0xFF
//Max number of USB DEVICES allowed
#define MAX_USB_DEVICES 64
//Max Report Requests at a time
#define MAX_REPORT_REQUEST_XP 512
#define MAX_REPORT_REQUEST_2K 200
#define DEFAULT_REPORT_INPUT_BUFFERS 0
#define MAX_SERIAL_STRING_LENGTH 256
class HIDDEVICESHARED_EXPORT HIDDevice {
public:
HIDDevice();
void resetDeviceData();
DWORD getConnectedDeviceNum(WORD vid, WORD pid);
BYTE getSerialString(DWORD deviceIndex, WORD vid, WORD pid, LPSTR serialString, DWORD serialStringLength);
BYTE close();
bool isOpened();
BYTE Open(DWORD deviceIndex, WORD vid, WORD pid, WORD numInputBuffers);
bool getHidDevicePath(DWORD index, char* devicePath);
HANDLE openDeviceByVidPid(char* devicePath, WORD vid, WORD pid);
BYTE setReport_Feature(BYTE* buffer, DWORD bufferSize);
BYTE getReport_Feature(BYTE* buffer, DWORD bufferSize);
BYTE setReport_Interrupt(BYTE* buffer, DWORD bufferSize);
BYTE getReport_Interrupt(BYTE* buffer, DWORD bufferSize, WORD numReports, DWORD* bytesReturned);
// BYTE setReport_Control(BYTE* buffer, DWORD bufferSize); //not imp in qt/mingw...
// BYTE getReport_Control(BYTE* buffer, DWORD bufferSize); //not imp in qt/mingw...
WORD getInputReportBufferLength();
WORD getOutputReportBufferLength();
WORD getFeatureReportBufferLength();
WORD getMaxReportRequest();
bool flushBuffers();
void setTimeouts(UINT getReportTimeout, UINT setReportTimeout);
void getTimeouts(UINT* getReportTimeout, UINT* setReportTimeout);
virtual ~HIDDevice();
protected:
QMutex* mutex;
private:
HANDLE m_Handle;
bool m_DeviceOpened;
UINT m_GetReportTimeout;
UINT m_SetReportTimeout;
WORD m_InputReportBufferLength;
WORD m_OutputReportBufferLength;
WORD m_FeatureReportBufferLength;
WORD m_MaxReportRequest;
};
#define LOCK_MUTEX() mutex->lock();
#define UNLOCK_MUTEX() mutex->unlock();
#endif // HIDDEVICE_H
To copy to clipboard, switch view to plain text mode
TARGET = WEM_ProgData
TEMPLATE = app
HEADERS += wemprogdata.h \
proginterface.h
SOURCES += wemprogdata.cpp \
main.cpp \
proginterface.cpp
INCLUDEPATH += e:/data/workingsvn/swSrcLib \
c:/data/swSrcLib
LIBS += -L"../../mingw/lib" \
-lhid \
-L"../../mingw/lib" \
-lsetupapi \
-L"../swSrcLib" \
-lhiddevice
TARGET = WEM_ProgData
TEMPLATE = app
HEADERS += wemprogdata.h \
proginterface.h
SOURCES += wemprogdata.cpp \
main.cpp \
proginterface.cpp
INCLUDEPATH += e:/data/workingsvn/swSrcLib \
c:/data/swSrcLib
LIBS += -L"../../mingw/lib" \
-lhid \
-L"../../mingw/lib" \
-lsetupapi \
-L"../swSrcLib" \
-lhiddevice
To copy to clipboard, switch view to plain text mode
If the implementation file is needed, please advise and I can upload!
Bookmarks