我有一個USB RFID掃描器瞎搞,並試圖與raw input讀取輸入,到目前爲止,我有這個原始輸入WINAPI在C中,無法獲得設備信息
#define _WIN32_WINNT 0x0601
#include <windows.h>
#include <stdio.h>
int main(void)
{
PRAWINPUTDEVICELIST pRawInputDeviceList;
PUINT puiNumDevices, pcbSize;
UINT cbSize = sizeof(RAWINPUTDEVICELIST);
char *pData[1000];
GetRawInputDeviceList(NULL, puiNumDevices, cbSize);
pRawInputDeviceList = malloc(cbSize * *puiNumDevices);
GetRawInputDeviceList(pRawInputDeviceList, puiNumDevices, cbSize);
// gives a correct RIM_TYPE for all devices 0-7 (GetRawInputDeviceList returns 8 devices for me)
printf("%I32u\n", pRawInputDeviceList[0].dwType);
GetRawInputDeviceInfo(pRawInputDeviceList[1].hDevice, RIDI_DEVICENAME, pData, pcbSize);
// gives a huge number (garbage?), should be the length of the name
printf("%u\n", pcbSize);
// "E" in my case
printf("%s\n", pData);
// error 87, apparently ERROR_INVALID_PARAMETER
printf("%I32u\n", GetLastError());
return 0;
}