来自HID设备的GetRawInputDeviceInfo

时间:2019-03-01 14:27:29

标签: windows msdn hid

我对此代码有疑问:

case WM_INPUT:
    translate(wParam, lParam);

void FrameNotifier::translate(WPARAM wParam, LPARAM lParam)
{
    stringstream os;

    UINT rawDatasSize;
    GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &rawDatasSize, sizeof(RAWINPUTHEADER));

    std::vector<BYTE> buffer;
    buffer.resize(rawDatasSize);
    PRAWINPUT pRawInput = (PRAWINPUT)&(buffer[0]);
    GetRawInputData((HRAWINPUT)lParam, RID_INPUT, pRawInput, &rawDatasSize, sizeof(RAWINPUTHEADER));

    RID_DEVICE_INFO deviceInfo;
    deviceInfo.cbSize = sizeof(RID_DEVICE_INFO);
    UINT infoSize = deviceInfo.cbSize;
    UINT result = GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICEINFO, (LPVOID)&deviceInfo, &infoSize);
    DWORD err = GetLastError();
    if (pRawInput->header.dwType == RIM_TYPEHID)
    {
        unsigned long long  version = (unsigned long long)deviceInfo.hid.dwVersionNumber;
        unsigned long long  vid = (unsigned long long)deviceInfo.hid.dwVendorId;
        unsigned long long  pid = (unsigned long long)deviceInfo.hid.dwProductId;

        //unsigned long long    deviceId = (version << 32) | (vid << 16) | pid;

        os << "version: " << version << endl;
        os << "vid: " << vid << endl;
        os << "pid: " << pid << endl;
    }
    OutputDebugString(os.str().c_str());
}

结果是:

版本:1 vid:0 pid:0

为什么我没有vid和pid?

会为此设备启用功能吗? 谢谢。

0 个答案:

没有答案