Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What I want to do: Get the USB HID IDs when I press the keys of my truly ergonomic keyboard to be able to reprogram the firmware of the keyboard.

I know there is this list from microsoft with a lot of USB HID IDs.

But it would be easier to find the ID of a key by just typing it and seeing it displayed in a program. Especially for some media keys, which I don’t find in that list from microsoft.

Does such a program exist? Could be a command line program. Linux preferred, but Windows would be an option.

PS: I have seen, that this question on stackoverflow has an interesting answer. But I can’t find /dev/usb/hiddev0 on my system (Fedora 17).

Update

In this question the answer from @Andy Ross helped me to at least get some output, when pressing a key. I did

xxd -c 144 /dev/input/by-path/pci-0000:00:1a.0-usb-0:1.1:1.0-event-kbd

But it is still not really readable. And not always the same, when I press the same key.

Update2

In this question a python script is linked, that reads the input device and should print it. But on this computer at work I have no rights to access the device with this python script.

share|improve this question
    
Describe your specific application which will allow users to provide better solutions that specifically meets your needs. –  mdpc Feb 14 '13 at 1:46
    
@mdpc There is nothing more to say. I want to easily get the USB HID ID numbers of my keyboard without having to search in the linked list from microsoft. Maybe this question is better on stackoverflow? superuser seems more for users, not for hackers. can someone move this question? –  erik Feb 14 '13 at 1:53
    
Hi erik. I don't think it's absolutely necessary to move your question to Stack Overflow, as we Super Users surely also do some hacking here and there :) If you'd really like to have it moved, leave me a comment. –  slhck Feb 14 '13 at 11:59

2 Answers 2

up vote 2 down vote accepted

The answer is:

su -c "while true; do od --read-bytes=144 --width=144 -x /dev/input/event3 | awk 'NF > 1 { print \$12 }'; done"

Explanition

With the tree command I have found this

$ tree /dev/input/by-path
/dev/input/by-path/
├── pci-0000:00:1a.0-usb-0:1.1:1.0-event-kbd -> ../event3
├── pci-0000:00:1a.0-usb-0:1.1:1.1-event -> ../event4
├── pci-0000:00:1d.2-usb-0:1:1.0-event-mouse -> ../event2
└── pci-0000:00:1d.2-usb-0:1:1.0-mouse -> ../mouse0

Ok, so /dev/input/event3 is my keyboard.

The od command dumps files in octal and other formats.

  • With the -x option it dumps hexadecimal.
  • And with the --width=144 option it dumps only one line per keypress (one line is 144 Bytes long).
  • Option --read-bytes=144 quits od after 144 Bytes.

The awk command prints the 12th field out of the whole line. That only, if the number of fields NF is greater then 1, because every second line is just a line break.

The while true loop around the whole thing is because if I type some letter keys it breaks. I get no more results, only 0000. But the od command quits reading after 144 Bytes (one key press). After that it is restarted. There is surely a better fix for that, but this is a good workaround.

Example output (I pressed a few times Return, RightCtrl and Backspace, which gives me the correct numbers when comparing to this document from microsoft (PDF) or this text file document)

0028
0028
0028
00e4
00e4
00e4
002a
002a
002a
share|improve this answer

xev in Linux will help you.

Good Luck.

share|improve this answer
2  
No, I want the USB HID ID numbers. Not the X keycodes. xev only prints X keycodes. –  erik Feb 14 '13 at 1:00
    
Oh, sorry. Maybe use dmesg|grep hid? –  Sloan Feb 14 '13 at 11:01
    
No, sorry. dmesg does not give you an event for every key press. But that is what I want to have. –  erik Feb 14 '13 at 11:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.