在 linux 中通过 C++(或 python)访问多个键盘输入 [英] Accessing multiple keyboards input by C++ (or python) in linux
问题描述
我想在我自己的应用程序中读取连接到计算机的(最多 4 个)键盘的输入.
I want to read the input of (up to 4) keyboards attached the a computer in my own application.
对于一个小型活动,我想将三个 USB 条形码扫描仪连接到笔记本电脑(有键盘)
For a small event I'd like to attach three USB barcode scanners to a laptop (having a keyboard)
默认情况下,条码扫描器就像键盘一样工作.如果它扫描条形码,它只需输入数字并按返回"键.这很棒,而且开箱即用.
By default, a barcode scanner simply work like a keyboard. If it scans a barcode it just enters the number and presses the "return" key. That's great and works out of the box.
对于我的应用程序,三个条形码扫描仪将同时工作,并且可能与默认应用程序发生冲突.也应该有意见在笔记本电脑键盘上手动输入条形码.
For my application three barcode scanner will work simultaneous and might get in conflict with a default application. Also there should be an opinion to enter the barcode manually on the laptops keyboard.
因此我需要使用我的自定义应用程序(C++ 或 python)读取四个键盘的输入并分别处理它们.
Therefore I need to read the input of the four keyboards with my custom application (C++ or python) and handle them separately.
我的特定环境是笔记本电脑上的 Ubuntu 11.04,连接了三个条形码扫描仪.该应用程序是用 C++ 或 python 编写的(取决于这个问题的答案).
My specific environment is Ubuntu 11.04 on a laptop having three barcode scanners attached. The application is written either in C++ or python (depending on the answers to this question).
提前感谢您的任何提示或回答
推荐答案
为什么不去设备节点
可能在这里找到cat/dev/input/by-path/yourDevice
maybe found here cat /dev/input/by-path/yourDevice
并在此处阅读代码
像他们一样 这里
(注意:原始链接已损坏,但可以在 web.archive.org)
(Note: original link is broken but content may be found on web.archive.org)
这篇关于在 linux 中通过 C++(或 python)访问多个键盘输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!