开发者

Can I specify which HID my C++ program listens to

开发者 https://www.devze.com 2023-04-05 15:32 出处:网络
I am trying to create an application that reads keyboard input from a HID. The OS I am trying to acheive this on is Windows 7. In what way would I specify to my program that it needs to listen to just

I am trying to create an application that reads keyboard input from a HID. The OS I am trying to acheive this on is Windows 7. In what way would I specify to my program that it needs to listen to just one HID device (I have a normal keyboard, and an RFID reader 开发者_C百科as my two devices) Could some one tell me the best route to take if I wanted to just listen to one HID and ignore other keystrokes (From the keyboard)


Did you register for HID input with RegisterRawInputDevices() ? Because in that case, you tell Windows for which devices you want "raw" input.

[edit] Rough sketch:

int count = 0;
GetRawInputDeviceList(0, &count, sizeof(RAWINPUTDEVICE);
std::vector<RAWINPUTDEVICE> devs(count);
GetRawInputDeviceList(&devs[0], &count, sizeof(RAWINPUTDEVICE);
// Select device(s) you want
RegisterRawInputDevices(&devs[0], &count, sizeof(RAWINPUTDEVICE);


You should probably handle the WM_INPUT message and check hDevice in the lParam input structure. See http://msdn.microsoft.com/en-us/library/ms645590%28v=VS.85%29.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号