如何确定输入来自哪个键盘 [英] How to determine from which keyboard the input comes

查看:195
本文介绍了如何确定输入来自哪个键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:

  • 我有一个USB RFID阅读器
  • 将其连接到笔记本计算机时,它可以作为新连接的USB键盘使用,例如无需安装任何驱动程序
  • 用RFID标签触摸阅读器时
  • 它进入我当前的窗口(例如终端/外壳)中的RFID编号(例如0009339384\n)-例如它甚至会发送\n.
  • 因此,它的工作方式就像我在笔记本的键盘上键入的数字一样
  • I have an usb-RFID reader
  • attaching it to notebook it works as an newly attached USB keyboard, e.g. without needing to install any drivers
  • when touching the reader with RFID tag
  • it enters into my current window (for example terminal/shell) the RFID number (like 0009339384\n) - e.g. it even sends the \n.
  • so, it works exactly as if I had typed the numbers in my notebook's keyboard

问题是:

    是否有可能直接读取RFID阅读器而无需某些内核级驱动程序,例如类似于cat /dev/keyboard1 ...
  • 换句话说,我如何确定字符来自哪个键盘"?
  • 使用OS X,但也很高兴知道Linux的解决方案.
  • is it possible read the RFID reader directly without some kernel-level drivers, e.g. something like cat /dev/keyboard1 ...
  • in other words, how can I determine from which "keyboard" the characters are coming?
  • using OS X, but would be nice to know the solution for Linux too.

此外,我想附加两名读者-因此,我绝对需要明确区分这两名读者.而且我想在bash(perl)脚本中使用rfid-reader,所以我肯定是在寻找一种无需编译某些驱动程序"的解决方案...有可能吗?

Moreover, I want attach two readers - so I definitely need to clearly differentiate between the two readers. And I want use the rfid-reader in a bash (perl) script, so I'm definitely looking for a solution without compiling some "drivers"... It is possible?

OS X将其标识为:

The OS X identifies it as:

SYC ID&IC USB Reader:

  Product ID:   0x0035
  Vendor ID:    0xffff
  Version:  1.00
  Serial Number:    08FF20140315
  Speed:    Up to 1.5 Mb/sec
  Manufacturer: Sycreader RFID Technology Co., Ltd
  Location ID:  0x14100000 / 18
  Current Available (mA):   500
  Current Required (mA):    100
  Extra Operating Current (mA): 0

编辑好吧,看起来可以在Linux中完成-刚刚找到

EDIT Okay, looks like in Linux it can be done - just found

  • this https://unix.stackexchange.com/questions/72483/how-to-distinguish-input-from-different-keyboards
  • also Accessing multiple keyboards input by C++ (or python) in linux

对于OS X-在UNIX上完全相同:

For OS X - exact duplicate on unix: https://unix.stackexchange.com/questions/228413/route-keyboard-through-only-dev-ttys000-on-mac-os-x - unfortunately, closed without any answer :(

推荐答案

好的,所以-在Linux中很容易解决.就像问题中的编辑一样-这里已经有很多类似的问题.

Ok, so - easily solvable in Linux. As in edits in the question - here are already many similar questions like this.

解决方案是:读取特定的/dev/input/eventN设备.

The solution is: reading the particular /dev/input/eventN device(s).

就我而言,我使用 Linux :: Input perl模块.完美运行.

In my case, me using the Linux::Input perl module. Works perfectly.

在这里添加代码毫无意义,该软件包随附 evtest.pl -这样任何人都可以轻松检查其工作原理.

It is pointless adding code here, the package comes with the evtest.pl - so anyone could easily check how it works.

仍然需要解决一个问题-例如即使在读取设备并很好地从rfid读取器获取所有事件(一个数字4个事件)时,rfid代码仍然会插入到活动窗口中,就像它来自键盘一样. (这将是另一个问题).

Still need solve one issue - e.g. even when reading the device and nicely getting all events from the rfid reader (4 events for one number), the rfid-code still is inserted into the active window, like it coming from a keyboard. (This will be an another question).

对于OS X,我还没有一个简单的解决方案,但是现在专注于Linux变体. :)

For OS X i haven't an easy solution yet, but now focusing for the Linux variant. :)

这篇关于如何确定输入来自哪个键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆