If I go to /dev/input/by-path
I can see my input peripherals.
I've got one keyboard and one mouse, and on my platform the output is:
pci-0000:05:00.0-usb-0:1.2:1.0-event-kbd
pci-0000:05:00.0-usb-0:1.1:1.0-event-mouse
pci-0000:05:00.0-usb-0:1.1:1.0-mouse
pci-0000:05:00.0-usb-0:1.1:1.1-event-kbd
- Why are there two entries per device?
- What's the purpose of each entry?
As a side note, only one works under open(<path_to_device>, O_RDONLY)
to listen to input (for the keyboard, it's the usb-0:1.2:1.0
one).
(I'm running Ubuntu; in case it matters!)
Best Answer
Mu. There are not two entries per device. Yes,
*-event-mouse
and*-mouse
are paired, they share the samepci-0000:05:00.0-usb-0:1.1:1.0
identifier which suggests they are the same device. On the other hand your*-event-kbd
are different devices.If you run
ls -l /dev/input/by-path
, the output might be (example):As you can see, there are
event*
andmouse*
devices. This document explains the difference:event*
mouse*
If you do
sudo cat pci-0000:05:00.0-usb-0:1.1:1.0-event-mouse
and (in a separate console)sudo cat pci-0000:05:00.0-usb-0:1.1:1.0-mouse
, you will see they both read from your mouse, yet the byte streams are different.You have already identified
pci-0000:05:00.0-usb-0:1.2:1.0-event-kbd
as your keyboard. I think the remaining device (pci-0000:05:00.0-usb-0:1.1:1.1-event-kbd
) is something else. You shouldls -l
as above to find out which event it corresponds to, and thenMy webcam has no physical buttons but I suspect the same driver supports webcams that do have some (e.g. a snapshot button). In your case the remaining device is probably not a regular keyboard either.