views:

3286

answers:

5

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.

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.

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?

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

* For those not in the know, the Microsoft Natural Keyboard registers as both a regular keyboard and a generic HID device. Without some application (such as the bundled application) knowing how to interpret the HID input, the regular keys will work but the favorite keys and the special function keys are useless.


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

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?

A: 

I use for my binding/shorcuts a combination of compiz, easystroke and xmacro.

For your needs, I think the missing piece is xbindkeys. I have found this link for you that maybe helps you to set this up:

http://linux-trackball.dreamhosters.com/

I wonder anyway whether there is a way to distinguish between several mouse devices.

bitozoid
I already know about xbindkeys etc. but the problem is X does NOT recognize my pedal presses so xbindkeys as of now is useless. Even the author of the link you gave have some buttons on his trackball that are still not working. My question is about how to get those not working keys working, not on how to make use of the keys that already work. Sorry the for confusion.
polyglot
A: 

You should investigate lircd. It interprets input from remote controls. Some supported remotes apparently present themselves as generic hid devices, so you may be able to get your device to talk to lircd.

joeforker
A: 

Does the device show up in /dev/input? if it does, use the "evdev" X driver to hook it up just like you would do for a keyboard or mouse.

Alexey Feldgendler
+3  A: 

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.

This explains it and gives a little tutorial: Using uinput driver in Linux- 2.6.x to send user input.

Adam Goode
Can you elaborate a little bit more? How does one listen to /dev/usb/hiddev0 programatically (the article you linked only talks about uinput)? The resulting program (that listens on hiddev and send keyboard/mouse events through uinput) would have to run as a daemon, I assume?
polyglot
Yes, I assume from your question that you already know how to read hiddev0. You will probably be writing a daemon. Start by writing a program that continually reads hiddev0 and prints out presses. Then you can modify it to emit new events via uinput. This will basically re-inject these events back into the kernel, but as keyboard or mouse events (of your choosing). No changes to X will be necessary.
Adam Goode
A: 

Hi, I realize this is a rather old post, but on the off chance you are still listening to it, I would very much appreciate the source code for the AutoHotKey script if you could post it. Thanks, Jeff

Jeff