首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

USB HID设备读写代码实现c++(2)

USB HID设备读写代码实现c++(2)

typedef struct _HID_DEVICE {   
    PCHAR                DevicePath;
    HANDLE               HidDevice; // A file handle to the hid device.

    HIDP_CAPS            Caps; // The Capabilities of this hid device.
    HIDD_ATTRIBUTES      Attributes;

} HID_DEVICE, *PHID_DEVICE;

class MCDHid
{
public:

static MCDHid & getInstance(){
  static MCDHid mcdHid;
  return mcdHid;
}

MCDHid(MCDHid & mcdHid);
MCDHid & operator=(MCDHid &mcdHid);
    ~MCDHid();
    unsigned long openMCDHid();
    void closeMCDHid();
    void startComm(void * pParam);
   
    int writeToHid();
   
    int readFromHid();

    char * getHidDeviceName()
{
        return _hidDeviceName;
    }

bool findMCDHid();
HID_DEVICE* getHidDevice(){
  return & _hidDevice;
}

bool getUsbCommRunning(){
  return _fUsbCommRunning;
}

bool getOffHookSignal(){
  return _offHookSignal;
}

unsigned long getDataWaitProcess(){
  return _dataWaitProcess;
}

void setUsbCommRunning(bool usbCommRunning)
{
  _fUsbCommRunning = usbCommRunning;
}

unsigned char _inputReportBuffer[9];
unsigned char _outputReportBuffer[2];

private:
MCDHid();
void copy(MCDHid & mcdHid);
    char *_hidDeviceName;
HANDLE _hEventObject;
OVERLAPPED _hIDOverlapped;
HID_DEVICE _hidDevice;

bool _fUsbCommRunning;

bool _offHookSignal;
unsigned long _dataWaitProcess;
unsigned long _inputReportByteLength;
unsigned long _outputReportByteLength;
};

#endif // MCDHID_H_INCLUDED
继承事业,薪火相传
返回列表