Jump to content
  • Advertisement
Sign in to follow this  

Extracting data from /dev/input/event*

This topic is 3996 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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-id
usb-045e_Microsoft_Natural_Keyboard_Pro-event-kbd
usb-Sony_Computer_Entertainment_Inc._SCE_USB_MOUSE-event-mouse
usb-Sony_Computer_Entertainment_Inc._SCE_USB_MOUSE-mouse
usb-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: symbolic
link 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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!