How to work with input devices#
In our reference distribution simplecore-distro
we are using libinput
for handling input from devices like
touchscreens
mice
keyboards
GPIO based input devices
by default each device found at runtime will form a /dev/input/eventX
(X is a natural number).
The mapping of device to the eventX
entry can be found by running on the device
$ /usr/libexec/libinput/libinput-list-devices
Device: Power Button
Kernel: /dev/input/event0
Group: 2
Seat: seat0, default
Capabilities: keyboard
Tap-to-click: n/a
Tap-and-drag: n/a
Tap drag lock: n/a
Left-handed: n/a
Nat.scrolling: n/a
Middle emulation: n/a
Calibration: n/a
Scroll methods: none
Click methods: none
Disable-w-typing: n/a
Accel profiles: n/a
Rotation: n/a
Device: i2c_designware
Kernel: /dev/input/event13
Group: 5
Seat: seat0, default
Capabilities: keyboard pointer
Tap-to-click: n/a
Tap-and-drag: n/a
Tap drag lock: n/a
Left-handed: n/a
Nat.scrolling: disabled
Middle emulation: n/a
Calibration: n/a
Scroll methods: none
Click methods: none
Disable-w-typing: n/a
Accel profiles: n/a
Rotation: n/a
in this example the i2c_designware device would be connected to /dev/input/event13
.
Debugging libinput events#
In case you want to debug the events published by the device, you can use one of the following tools:
libinput-record#
This tool allows you to record the events posted by an input device to console or a file.
$ /usr/libexec/libinput/libinput-record <event device>
so for above’s example
$ /usr/libexec/libinput/libinput-record /dev/input/event13
libinput-debug-events#
A slightly different tool from libinput allows you to have all events logged to console
$ /usr/libexec/libinput/libinput-debug-events <event device>
evtest as an alternative#
As an alternative you can use evtest to debug events posted to libinput
$ evtest
then just follow the on-screen instructions.
Setting input device classification#
libinput makes a few assumptions on what type of device. Choices are
mouse
keyboard
touchpad
touchscreen
tablet
It could happen that the automatic detection misclassifies a device. Read the following chapters to override the automatic choices by libinput.
Getting device classification#
The device type is added by udev and libinput and can be checked by running
$ udevadm info -n <event device>
for our above’s example that would look like
$ udevadm info -n /dev/input/event13
N: input/event13
L: 0
S: input/by-path/pci-0000:00:15.1-platform-i2c_designware.1-event-mouse
E: DEVPATH=/devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-2/0018:0488:1024.0001/input/input16/event13
E: DEVNAME=/dev/input/event13
E: MAJOR=13
E: MINOR=77
E: SUBSYSTEM=input
E: USEC_INITIALIZED=10229073
E: ID_INPUT=1
E: ID_INPUT_TOUCHPAD=1
E: ID_INPUT_WIDTH_MM=110
E: ID_INPUT_HEIGHT_MM=63
E: ID_SERIAL=noserial
E: ID_PATH=pci-0000:00:15.1-platform-i2c_designware.1
E: ID_PATH_TAG=pci-0000_00_15_1-platform-i2c_designware_1
of importance are here the ID_INPUT_*
tags.
Overriding the defaults#
To override the defaults you would need to add a custom udev rule.
Create a file /etc/udev/rules.d/00-my-rules.conf
ACTION=="add|change", KERNEL=="event[0-9]*", \
DEVPATH=="/devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-2/0018:0488:1024.0001/input/input16/event13", \
ENV{ID_INPUT_TABLET}="", \
ENV{ID_INPUT_TOUCHPAD}="1", \
ENV{ID_INPUT_TOUCHSCREEN}="0", \
ENV{ID_INPUT_MOUSE}="", \
ENV{EVDEV_UDEV_TAG_TABLET_PAD}=""
Every ENV{ID_INPUT_*}=""
operation unsets a previously set classification.
Every ENV{ID_INPUT_*}="1"
sets a classification flags.
So in this example we force a classification as a touchpad.
Further information on classification types can be found here.