如何在Linux上捕获原始HID输入? [英] How to capture raw HID input on linux?

查看:402
本文介绍了如何在Linux上捕获原始HID输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要完成的工作的简短版本:我有一个脚踏板(INFINITY-IN-USB-1,如果您有兴趣的话),它已实现为通用HID设备,希望它充当Linux上的control和alt键.我正在寻找X级别的东西,即不仅仅是单个程序.

Short version of what I want to accomplish: I have a foot pedal (INFINITY-IN-USB-1, if that's of any interest) that is implemented as a generic HID device, and I would like it to be behave as control and alt keys on linux. I'm looking for something on the level on X, i.e. not just individual programs.

更长的版本:通过使用dll RegisterRawInputDevices和GetRawInputData并在隐藏的窗口中侦听输入,我可以在Windows XP中使用此设置.所有操作都可以通过非常简单的 Autohotkey 脚本完成(如果有兴趣的话可以在此处发布).关键是,不需要任何额外的驱动程序等.只需要本机Windows dll.

Longer version: I have this setup working in Windows XP by calling dll RegisterRawInputDevices and GetRawInputData and listening to the input in a hidden windows. All is accomplished with a fairly straightforward Autohotkey script (can post here if anyone is interested). The point is, there is no need for any extra driver, etc.; only the native Windows dll's are needed.

我希望此设置可在linux上运行(更具体地说是Ubuntu下的Gnome,但我偶尔会使用其他发行版/窗口管理器,因此赞赏X级别的解决方案).此脚踏板不会将自己注册为键盘甚至操纵杆,而是将其注册为带有UsagePage 12,用法3的HID设备.我注意到,最新的Ubuntu可以检测并使用Microsoft Natural Keyboard上的收藏键,该键也注册为HID设备*.我在Windows上使用的按键与使用脚踏板的方法相同(即,没有附带的软件).因此,我认为这踏板功能也可以在linux上运行,但是问题是如何实现的?

I want this setup to work on linux (more specifically Gnome under Ubuntu, but I do occasionally use other distro/window manager, so solution on the level of X is appreciated). This foot pedal does not register itself as keyboard or even joystick, but as a HID device with UsagePage 12, Usage 3. I notice that the latest Ubuntu can detect and use the favorite keys on the Microsoft Natural Keyboard, which also register as HID device*. I make use of those keys on Windows using the same method as I use the foot pedal (i.e. without the bundled software). So I assume that this pedal thing can work on linux as well, but the question is how?

[我对Linux下层的知识是陌生的,因此请在适当的地方慷慨地提供指向简介或教程的链接.]

[I'm new to the lower-level stuff on Linux, so please be generous with links to introduction or tutorial whenever applicable.]

*对于那些不知道的人,Microsoft Natural Keyboard将其注册为常规键盘和通用HID设备.如果某些应用程序(例如捆绑的应用程序)不知道如何解释HID输入,则常规键将起作用,但是收藏夹键和特殊功能键无效.

为澄清起见,Linux没有将踏板踩压机作为输入.它可以识别USB设备,但是xev不提供踏板踩踏的输出.我见过有人成功使用WINE下的踏板来制作转录软件的报道,但是该踏板必须以Windows方式工作并且不能提供我想要的东西(这使踏板在所有本机linux应用程序中都像键盘一样).我不知道是否有一些低级的Linux键盘驱动程序 需要吗?

To clarify, linux is NOT seeing the pedal presses as input. It does recognize the USB device, but xev gives no output for pedal presses. I have seen reports of people succesefully using the pedal under WINE for transcription software, but that must work in a Windows way and does not give what I want (which is making the pedal look like a keyboard to all native linux apps). I wonder whether some low level linux keyboard driver is needed?

更多信息:如果我在终端机上发布

Here's some more information: If I issue this in the terminal

cat /dev/usb/hiddev0

(dev/usb/hiddev0是我的踏板),我得到与踏板踩踏相对应的原始代码.那是一个开始.我知道这些原始代码的含义:二进制中的0001、0010、0100分别对应于每个踏板,踏板踩踏的组合发送这些二进制数的组合,并释放仍在踩下的任何踏板的踏板触发输入(如果有的话)踏板抬起,发送了0000.)

(dev/usb/hiddev0 is my pedal), I get raw codes corresponding to my pedal presses. That's a start. I know what those raw code means: in binary, 0001, 0010, 0100 corresponds to each pedal, respectively, and combination of pedal presses sends combination of those binary number, and releases of pedal trigger input of whatever pedal still being pressed (if all pedal is up, 0000 is sent).

如何让X收听dev/usb/hiddev0并将原始代码转换为特殊的键码,以便我可以使用xmodmap或其他方式映射它们?

How to I get X to listen to dev/usb/hiddev0 and translate the raw codes into maybe a special keycode so that I can map them with xmodmap or something?

推荐答案

您需要uinput.您将监听/dev/usb/hiddev0,然后创建要在/dev/input/uinput上发送的新事件.

You'll want uinput. You'll listen on your /dev/usb/hiddev0 and then create new events that you'll send out on /dev/input/uinput.

对此进行了解释,并提供了一些教程: 在Linux- 2.6中使用uinput驱动程序. x以发送用户输入 {这是EInfochips的仪表板"出版物2007年1月发行,在

This explains it and gives a little tutorial: Using uinput driver in Linux- 2.6.x to send user input {This is the EInfochips' "Dashboard" publication issue January 2007 "Tip of the Month" article mentioned on this archived page}.

这篇关于如何在Linux上捕获原始HID输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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