123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #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;
- }
|