How to configure input
======================
:toc:
Cyril Brulebois <kibi@debian.org>


General considerations
----------------------

Foreword
~~~~~~~~

The Debian wiki also contains an
http://wiki.debian.org/XStrikeForce/InputHotplugGuide[input hotplug guide]
which contains some context around X’s input subsystem. The present
document is meant to be an executive summary, and might miss some
bits. (*FIXME:* Merge those bits.)


Rules of thumb
~~~~~~~~~~~~~~

In this documentation, only the last part of the driver’s name will be
mentioned, all of them are under the `xserver-xorg-input-*` namespace.

 * On Linux, `evdev` is used for both keyboard and mouse
   input.
 * On Linux as well, `synaptics` can be used to benefit from extra
   features; it takes precedence over `evdev` automatically if both
   are installed.
 * On GNU/kFreeBSD and GNU/Hurd, `kbd` handles the keyboard and
   `mouse` handles mice, unsurprisingly.


Configuration snippets
~~~~~~~~~~~~~~~~~~~~~~

X can now be run without `xorg.conf`, but sometimes one has to
configure a few settings for this or that driver. Starting with
`squeeze`, that can be done by adding a file under
`/etc/X11/xorg.conf.d`, with a `.conf` suffix, as documented in the
`xorg.conf` manpage.

Some packages ship a default configuration file under
`/usr/share/X11/xorg.conf.d` with general rules to match appropriate
hardware. The files under `/etc/X11/xorg.conf.d` take precedence, as
documented in the `xorg.conf` manpage.

It’s probably mostly useful in the `synaptics` case, in case one wants
to change default settings on a system-wide fashion. See the _Pointer
configuration_ section below for an example.


<<<
Basic keyboard configuration
----------------------------

The `keyboard-configuration` package ships `/etc/default/keyboard`
which can be used to set the following `xkb` items: model, layout,
variant, and options. Here’s an example:

----
XKBMODEL="pc105"
XKBLAYOUT="fr"
XKBVARIANT="oss"
XKBOPTIONS="compose:menu,terminate:ctrl_alt_bksp"
----

Quick words about the options:

 * They are comma-separated.
 * The list of options and a short description for each can be found
   in the `/usr/share/X11/xkb/rules/base.lst` file (shipped by the
   `xkb-data` package).
 * First option: `compose:menu`. This sets the `menu` key as the
   Compose key. More information about it can be found in the
   `Compose` manpage.
 * Second option: `terminate:ctrl_alt_bksp`. By default, the X server
   is no longer killed through `Ctrl+Alt+Backspace`. This option
   restores the old behaviour.

Two ways to change the configuration:

 * `dpkg-reconfigure keyboard-configuration` is going to ask questions
   through debconf prompts.
 * Manually editing `/etc/default/keyboard` also works.

How does it propagate to X?

 * When HAL is used (that is: on GNU/kFreeBSD and GNU/Hurd), one has
   to restart it: `invoke-rc.d hal restart`
 * When udev is used (on GNU/Linux, starting with `squeeze`), one has
   to tell udev to reload input-related configuration:
   `udevadm trigger --subsystem-match=input --action=change`
   (that can be found in ++keyboard-configuration++’s `README.Debian`
   file). Properties attached to the input devices are then updated,
   and X uses those properties when it starts, as can be seen by
   searching for `xkb_` in the X log. Please note that trying
   `invoke-rc.d udev restart` changes nothing, one has to use
   `udevadm`. Properties can be inspected through:
   `/sbin/udevadm info --export-db`


<<<
Pointer configuration
---------------------

evdev configuration
~~~~~~~~~~~~~~~~~~~

Available options are documented in the `evdev` manpage. Let’s check
what a configuration snippet (mentioned in _General considerations_)
would look like. Here is a fictional `/etc/X11/xorg.conf.d/42-evdev.conf`:

----
Section "InputClass"
    Identifier "evdev pointer tweaked catchall"
    MatchIsPointer "on"
    Driver "evdev"
    Option "Emulate3Buttons" True"
    Option "SwapAxes" "True"
EndSection
----

Line by line walkthrough:

 * To avoid specifying any device under `/dev/input` (`event$N` might
   change, remember it’s about hotplug support!), we use an
   `InputClass`.
 * We need an identifier, the actual name doesn’t matter.
 * We match everything that looks like a touchpad. Meaning no generic
   pointer, keyboard, or tablet.
 * We specify the driver we want to use for the matched device(s).
 * Finally the options we want to set. Here we enable the 3rd button
   emulation (clicking left and right buttons at the same time then no
   longer acts as if the middle button was clicked). Then we swap x
   and y axes, just for the fun of it.


synaptics configuration
~~~~~~~~~~~~~~~~~~~~~~~

The `synaptics` driver comes with two tools. The more interesting one
is `synclient`, which can be used to list available options and
current settings: `synclient -l`. The documentation for each option
can be found in the `synaptics` manpage.

`synclient` can also be used to set options. A common example is
enabling tapping (upstream kept it disabled by default, Debian won’t
deviate, no need to file bugs): `synclient TapButton1=1`; one can also
disable the touchpad temporarily: `synclient TouchpadOff=1` to
disable it, `synclient TouchpadOff=0` to enable it again.

Let’s check what a configuration snippet (mentioned in _General
considerations_) would look like. Here is a fictional
`/etc/X11/xorg.conf.d/42-synaptics.conf`:

----
Section "InputClass"
    Identifier "touchpad tweaked catchall"
    MatchIsTouchpad "on"
    Driver "synaptics"
    Option "TapButton1" "1"
    Option "HorizEdgeScroll" "1"
EndSection
----

Line by line walkthrough:

 * To avoid specifying any device under `/dev/input` (`event$N` might
   change, remember it’s about hotplug support!), we use an
   `InputClass`.
 * We need an identifier, the actual name doesn’t matter.
 * We match everything that looks like a touchpad. Meaning no generic
   pointer, keyboard, or tablet.
 * We specify the driver we want to use for the matched device(s).
 * Finally the options we want to set. We enable tapping for the first
   button. And we enable horizontal scrolling (by default, only
   vertical scrolling is enabled).

Settings can also be changed by various settings managers, like
Gnome’s or KDE’s. An example of a graphical user interface making it
possible to set options in a clicky way: `gpointing-device-settings`.

There’s a palm detection setting but that relies on hardware/firmware
support for the touchpad. The other tool shipped with the `synaptics`
driver is `syndaemon`, which makes it trivial to disable the touchpad
temporarily, when the keyboard is being used. Here’s an example:
`syndaemon -d -i 0.5` makes `syndaemon` start in background (`-d` for
daemon mode), waiting 0.5 second before enabling the touchpad again
after the last keypress. Warning: it becomes quite difficult to use
things like `Ctrl+click` in a browser, or `Alt+drag` to move
windows.
