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:

  1. Why are there two entries per device?
  2. 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!)


Why are there two entries per device?

Mu. There are not two entries per device. Yes, *-event-mouse and *-mouse are paired, they share the same pci-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.

What's the purpose of each entry?

If you run ls -l /dev/input/by-path, the output might be (example):

pci-0000:05:00.0-usb-0:1.2:1.0-event-kbd -> ../event5
pci-0000:05:00.0-usb-0:1.1:1.0-event-mouse -> ../event6
pci-0000:05:00.0-usb-0:1.1:1.0-mouse -> ../mouse0
pci-0000:05:00.0-usb-0:1.1:1.1-event-kbd -> ../event13

As you can see, there are event* and mouse* devices. This document explains the difference:

  • event*

    evdev is the generic input event interface. It passes the events generated in the kernel straight to the program, with timestamps. The event codes are the same on all architectures and are hardware independent.

    This is the preferred interface for userspace to consume user input, and all clients are encouraged to use it.

  • mouse*

    mousedev is a hack to make legacy programs that use mouse input work. It takes events from either mice or digitizers/tablets and makes a PS/2-style (a la /dev/psaux) mouse device available to the userland.

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 should ls -l as above to find out which event it corresponds to, and then

$ # Example from my laptop
$ cat /sys/class/input/event13/device/name
Laptop_Integrated_Webcam_FHD: I

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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