简体   繁体   English

如何使用C ++在Mac OS上获取键盘设备ID和鼠标设备ID

[英]How to get keyboard device id and mouse devicei id on mac os using c++

I'm trying to get the device Id for all mouse and keyboard devices plugged in to a computer. 我正在尝试将所有鼠标和键盘设备的设备ID插入计算机。 I know I probably have to use the IO Kit library but have been unable to find much information, I found this ( How to create a program to list all the USB devices in a Mac? ) but if gives the id for all the usb devices which is not quite what I want. 我知道我可能必须使用IO Kit库,但一直找不到很多信息,我发现了这一点( 如何创建一个程序来列出Mac中所有USB设备? ),但是如果给出了所有USB设备的ID这不是我想要的。

不要以为这是最佳解决方案,但是您可以通过以下方式获得给定类型的所有ID的列表:

std::string = std::system("lsusb | grep Keyboard | awk '{print $6}'")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM