5.1. Finding the real devices

We will need this information later on, to be able to assign a given keyboard/mouse to a given X-server/Display.

To find the PHYS ID's (the addresses) or the name(quite oft it differs from the one labeled on the device) of your input devices you have to read the file /proc/bus/input/devices.

Here is what I have:

[svetljo@svetljo How-To]# cat /proc/bus/input/devices 
I: Bus=0011 Vendor=0002 Product=0002 Version=0034
N: Name="PS2++ Logitech Wheel Mouse"
P: Phys=isa0060/serio1/input0
H: Handlers=mouse0 ts0 
B: EV=7 
B: KEY=f0000 0 0 0 0 0 0 0 0 
B: REL=103 

I: Bus=0011 Vendor=0001 Product=0002 Version=ab02
N: Name="AT Set 2 keyboard"
P: Phys=isa0060/serio0/input0
H: Handlers=kbd 
B: EV=120003 
B: KEY=4 2000000 8061f9 fbc9d621 efdfffdf ffefffff ffffffff fffffffe 
B: LED=7 

I: Bus=0003 Vendor=046d Product=c303 Version=0700
N: Name="Logitech    USB Keyboard"
P: Phys=usb-00:10.1-1.1/input0
H: Handlers=kbd 
B: EV=120003 
B: KEY=10000 7f ffe00000 7ff ffbeffdf ffffffff ffffffff fffffffe 
B: LED=7 

I: Bus=0003 Vendor=046d Product=c303 Version=0700
N: Name="Logitech    USB Keyboard"
P: Phys=usb-00:10.1-1.1/input1
H: Handlers=kbd 
B: EV=100003 
B: KEY=1078 1800d100 1e0000 0 0 0 

I: Bus=0003 Vendor=05fe Product=0011 Version=0000
N: Name="Cypress Sem. PS2/USB Browser Combo Mouse"
P: Phys=usb-00:10.1-1.2/input0
H: Handlers=mouse1 ts1 
B: EV=7 
B: KEY=1f0000 0 0 0 0 0 0 0 0 
B: REL=103 

NoteNote
 

  • /proc/bus/input/devices will provide the needed information for all devices except USB multimedia/office keyboards.

  • For such USB multimedia/office keyboards you will have to gather additional information, for example with the help of lsusb.

  • Under Ruby-2.6 for usb devices it will look like "usb-0000:00:10.x" not "usb-00:10.x"

So my USB keyboard has two interfaces (see bInterfaceNumber); the first one is the real keyboard (bInterfaceProtocol 1 Keyboard), the second (bInterfaceProtocol 0 None) - the additional keys. Hence the real USB keyboard is:

.....
N: Name="Logitech    USB Keyboard"
P: Phys=usb-00:10.1-1.1/input0
H: Handlers=kbd 
.....

The "P: Phys=" field (the physical descriptor/address) consorts of:

  1. Bus type: "usb"

  2. PCI function of the USB controller: "00:10.1 " ( for Ruby-2.6 "0000:00:10.1")

  3. USB device id: "1.1"

  4. The string: "/input"

  5. Interface number: "0"