#include "stdafx.h" #include "Hid_Cmd.h" #include "AutoFunc.h" void InitKeyNode(KEY_CMD *pKey) { memset(pKey, 0, sizeof(KEY_CMD)); pKey->Len = 10; pKey->Cmd = 1; } void InitMouseNode(MOUSE_CMD *pMouse) { memset(pMouse, 0, sizeof(MOUSE_CMD)); pMouse->Len = 6; pMouse->Cmd = 0x11; } Hid_Cmd::Hid_Cmd() { } Hid_Cmd::~Hid_Cmd() { } bool Hid_Cmd::PostKeyCmd(KEY_CMD *pKey) { //user need fill the Func & key area return WriteToHid((char*)pKey, 10); } bool Hid_Cmd::PostMouseCmd(MOUSE_CMD *pMouse) { return WriteToHid((char*)pMouse, 6); } bool Hid_Cmd::GetLightStatus(LIGHT_FUNCTION_BIT *pVal) { char szCmd[2] = { 0x02, 0x21 }; if (WriteToHid(szCmd, 2)) { int ret = 0; do { char szRes[MAX_PATH] = { 0 }; ret = ReadFromHid(szRes, MAX_PATH); if (ret >= 3) { if ((szRes[0] == (char)0x03) && (szRes[1] == (char)0xA1)) { memcpy(pVal, &(szRes[2]), 1); return true; } } } while (ret > 0); } return false; } bool Hid_Cmd::TryReadErrResponse(char Res, DWORD timeout) { int ret = 0; return true; do { char szRes[MAX_PATH] = { 0 }; ret = ReadFromHid(szRes, MAX_PATH, timeout); if (ret >= 3) { if ((szRes[0] == 0x03) && (szRes[1] == 0xA4)) { Res = szRes[2]; return true; } } } while (ret > 0); return false; }