InputConfiguration

Revision 2 as of 2009-12-17 10:42:57

Clear message

Structure

Unless xorg.conf has manual configuration, X.org uses udev for detecting input devices, and udev properties for configuring them. This is what happens in detail:

  1. A hardware input device is present at boot, or gets hotplugged.
  2. The kernel detects this, and creates a new "input" device (e. g. /sys/class/input/input3 and an "event" interface for it (/sys/class/input/event3 and a device node /dev/input/event3 which you can use to talk to the input device, see /usr/include/linux/input.h).

  3. udev picks up the "add" event and the new device. /lib/udev/rules.d/60-persistent-input.rules calls /lib/udev/input_id on it, which detects the class of the device (mouse, touchpad, etc.) and attaches some properties to it:

     $ /lib/udev/input_id /class/input/event4
     ID_INPUT=1
     ID_INPUT_KEY=1
     ID_INPUT_KEYBOARD=1
    
     $ /lib/udev/input_id /class/input/event14
     ID_INPUT=1
     ID_INPUT_MOUSE=1
     ID_INPUT_TOUCHPAD=1
  4. udev applies additional rules shipped by the X.org packages (/lib/udev/rules.d/*xorg*), which assign an X11 driver and device specific properties like keyboard layout or touchpad quirks:

     P: /devices/platform/i8042/serio0/input/input4/event4
     E: DEVNAME=/dev/input/event4
     E: ID_INPUT=1
     E: ID_INPUT_KEY=1
     E: ID_INPUT_KEYBOARD=1
     E: XKBMODEL=pc105
     E: XKBLAYOUT=de
     E: XKBVARIANT=nodeadkeys
     E: x11_driver=evdev
    
     P: /devices/platform/i8042/serio1/input/input14/event14
     N: input/event14
     E: DEVNAME=/dev/input/event14
     E: ID_INPUT=1
     E: ID_INPUT_MOUSE=1
     E: ID_INPUT_TOUCHPAD=1
     E: x11_driver=synaptics
     E: x11_options.JumpyCursorThreshold=20
  5. X.org picks up the add event or detects existing devices at startup, and adds it to its configuration:
     (II) config/udev: Adding input device "AT Translated Set 2 keyboard" (/dev/input/event4)
     (**) "AT Translated Set 2 keyboard": always reports core events
     (**) "AT Translated Set 2 keyboard": Device: "/dev/input/event4"
     (II) "AT Translated Set 2 keyboard": Found keys
     (II) "AT Translated Set 2 keyboard": Configuring as keyboard
     (II) XINPUT: Adding extended input device ""AT Translated Set 2 keyoard"" (type: KEYBOARD)
     (**) Option "xkb_rules" "evdev"
     (**) Option "xkb_model" "pc105"
     (**) Option "xkb_layout" "de"
     (**) Option "xkb_variant" "nodeadkeys"

Udev rules

Device classification

As shown above, udev itself already classifies the input devices with input_id. Existing flags are:

  • ID_INPUT

    All input devices have this flag.

    ID_INPUT_MOUSE

    Touchscreens and tables have this flag as well, since by the type of events they can produce they act as a mouse.

    ID_INPUT_TABLET

    ID_INPUT_TOUCHSCREEN

    ID_INPUT_JOYSTICK

    ID_INPUT_KEY

    Keyboards have this, but also things like lid switches or joystick which have just a few buttons

    ID_INPUT_KEYBOARD

Driver assignment

Most input devices