我可以指定我的 C++ 的 HID 吗?程序监听

发布于 2024-12-05 02:08:32 字数 151 浏览 6 评论 0原文

我正在尝试创建一个从 HID 读取键盘输入的应用程序。我试图实现这一目标的操作系统是 Windows 7。我会以什么方式指定我的程序只需要侦听一个 HID 设备(我有一个普通键盘和一个 RFID 读取器作为我的两个设备)如果我只想听一个 HID 并忽略其他击键(从键盘),请告诉我最佳路线

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 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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

失眠症患者 2024-12-12 02:08:32

您是否使用 RegisterRawInputDevices() 注册了 HID 输入?因为在这种情况下,您需要告诉 Windows 您需要哪些设备的“原始”输入。

[编辑]
粗略草图:

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);

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);
惟欲睡 2024-12-12 02:08:32

您可能应该处理 WM_INPUT 消息并检查 lParam 输入结构中的 hDevice。请参阅 http://msdn.microsoft.com/ en-us/library/ms645590%28v=VS.85%29.aspx

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文