Advertisement

Extracting data from /dev/input/event*

Started by June 11, 2007 09:36 AM
0 comments, last by let_bound 17 years, 5 months ago
Hi, I'm newbie in Linux. The data from the keyboard is stored into an input file like /dev/input/event0, right? Does event0 store only a byte per time? In true, I would like to get data from 2 keyboards... For example: If data from the keyboard A is stored into the /dev/input/event0 and the data from the keyboard B is stored into /dev/input/event1, I could read the event0 and event1 files to know what keys were pressed (and from which keyboard). Thanks in advance
Quote: Original post by adriano_usp
Hi,

I'm newbie in Linux.

The data from the keyboard is stored into an input file like /dev/input/event0, right?


/dev/input/event0 is the first event stream. I don't know if there is any guarantee that a keyboard will be mapped to a /dev/input/event? device. It's definitely not guaranteed to be attached to the first one, because, on this computer (emphasis mine):

$ ls /dev/input/by-idusb-045e_Microsoft_Natural_Keyboard_Pro-event-kbdusb-Sony_Computer_Entertainment_Inc._SCE_USB_MOUSE-event-mouseusb-Sony_Computer_Entertainment_Inc._SCE_USB_MOUSE-mouseusb-THRUSTMASTER_2_in_1_DT-event-joystick$ file /dev/input/by-id/usb-045e_Microsoft_Natural_Keyboard_Pro-event-kbd/dev/input/by-id/usb-045e_Microsoft_Natural_Keyboard_Pro-event-kbd: symboliclink to `../event1'


Back when I last checked, event streams were used only for USB devices, but I don't know if it has changed since then.


Quote: Does event0 store only a byte per time?


I don't know what you mean by that. It's a character device, so it doesn't read and write in blocks, if that's what you mean.


Quote:
In true, I would like to get data from 2 keyboards...

For example: If data from the keyboard A is stored into the /dev/input/event0 and the data from the keyboard B is stored into /dev/input/event1, I could read the event0 and event1 files to know what keys were pressed (and from which keyboard).


What's the question? If it is "how do I read from 2 keyboards", you've just answered your own question, assuming they're attached to the 1st and 2nd event streams.

This topic is closed to new replies.

Advertisement