View Single Post
Old 02-02-2023, 08:07 PM   #48
elinkser
Addict
elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.
 
Posts: 242
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
SETTING UP STOCK TOUCHSCREEN DRIVER (libinput):

Browsing through "dmesg | less" for information on the touchscreen in the Kobo Clara HD, we find:

Focaltech V3.3 20201229
1448x1072
cyttsp5_i2c_adapter touch

More info from "cat /proc/bus/input/devices":

Bus=0000 Vendor=0000 Product=0000 Version=0000
Name="cyttsp5_mt"
Handler=event1
Sysfs=/devices/platform/soc/2100000.aips-bus/21a4000.i2c/i2c-1/1-oo24/input/input1


***ALL CHANGES WILL BE DONE USING TELNET FROM THE DESKTOP IN CASE WE LOSE INPUT ON THE KOBO***

We will try the libinput driver instead of evdev.
So we edit /etc/X11/xorg.conf to have the touchscreen section look like this:


#Section "InputClass"
Section "InputDevice"
Identifier "Touchscreen"
# Driver "evdev"
Driver "libinput"
Option "Device" "/dev/input/event1"
EndSection


We also add the driver and config tools, and reboot X:
apk add xf86-input-libinput
apk add libinput-tools


Here is the output from "less /var/log/Xorg.0.log":

[ 127.751] (II) Using input driver 'libinput' for 'Touchscreen'
[ 127.751] (**) Touchscreen: always reports core events
[ 127.751] (**) Option "Device" "/dev/input/event1"
[ 129.993] (EE) libinput bug: udev device never initialized (/dev/input/event1)
[ 129.993] (EE) client bug: Invalid path /dev/input/event1
[ 129.993] (EE) libinput: Touchscreen: Failed to create a device for /dev/input/event1
[ 129.994] (EE) PreInit returned 2 for "Touchscreen"


So the libinput driver was not loaded.
The output of "DISPLAY=:0 libinput debug-events" gives:

Expected device added events on startup but got none. Maybe you don't have the right permissions?


The error message is complaining about udev, which is not installed! So let's install it.
(Note that our Alpine Linux uses a non-systemd version of udev.)

apk add eudev
apk add eudev-hwids
udevd -d
udevadm trigger


Now the output of "DISPLAY=:0 libinput debug-events" gives:

event1 - cyttsp5_mt: libinput bug: missing tablet capabilities: btn-stylus resolution. Ignoring this device.
-event0 DEVICE_ADDED gpio-keys seat0 default group1 cap:k



This error message is apparently because we didn't define these parameters:
EVDEV_ABS_00 (x-resolution/x-width = 1448/121 = 12)
EVDEV_ABS_01 (y-resolution/y-width = 1072/90 = 12)
(Using info we got from dmesg and by measuring the display.)

So we edit the hwdb file ("nano /etc/udev/hwdb.d/60-evdev.hwdb") to add the following entry:

evdev:input:b0000v0000p0000*
ID_INPUT=1
ID_INPUT_TOUCHSCREEN=1
EVDEV_ABS_00=::12
EVDEV_ABS_01=::12




To update the binary file on-disk, run:
udevadm hwdb --update

Then, to trigger a reload of all properties on your device, run:
udevadm trigger /sys/class/input/event1


The output of "DISPLAY=:0 libinput debug-events" gives:

-event0 DEVICE_ADDED gpio-keys seat0 default group1 cap:k
-event1 DEVICE_ADDED cyttsp5_mt seat0 default group2 cap:t ntouches 0 calib


The command "DISPLAY=:0 libinput list-devices" shows our touchscreen:

Device: cyttsp5_mt
Kernel: /dev/input/event1
Group: 2
Seat: seat0, default
Capabilities: touch
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: identity matrix
Scroll methods: none
Click methods: none
Disable-w-typing: n/a
Disable-w-trackpointing: n/a
Accel profiles: n/a
Rotation: n/a


The command "udevadm info /sys/class/input/event1" gives:


P: /devices/platform/soc/2100000.aips-bus/21a4000.i2c/i2c-1/1-0024/input/input1/event1
N: input/event1
S: input/by-path/platform-21a4000.i2c-event
E: DEVLINKS=/dev/input/by-path/platform-21a4000.i2c-event
E: DEVNAME=/dev/input/event1
E: DEVPATH=/devices/platform/soc/2100000.aips-bus/21a4000.i2c/i2c-1/1-0024/input/input1/event1
E: EVDEV_ABS_00=::12
E: EVDEV_ABS_01=::12
E: ID_INPUT=1
E: ID_INPUT_TOUCHSCREEN=1
E: ID_PATH=platform-21a4000.i2c
E: ID_PATH_TAG=platform-21a4000_i2c
E: LIBINPUT_DEVICE_GROUP=0/0/0:1-0024
E: MAJOR=13
E: MINOR=65
E: SUBSYSTEM=input
E: USEC_INITIALIZED=81411211




***NOW THE REAL TEST IS TO DEACTIVATE OUR OLD PYTHON INPUT DRIVER< AND REBOOT WITH ONLY LIBINPUT***

First comment out the lines in /xorg-chroot.sh:

#evtest --grab /dev/input/event1 > evtest-log &
#sleep 1
#while true; do python3 /home/xorg-kobo-touch.py ; done &
#sleep 1

And insert at the top:

udevd -d
sleep 2
udevadm trigger
sleep 2


***POWEROFF AND REBOOT X, WITH TELNET CONNECTION TO DESKTOP***


Run "ps ax" and you should see that udevd is running, but the python3 xorg-kobo-touch.py and evtest programs are not!
Enter the same command on the Kobo instead of via telnet, and it should still work.

It doesn't appear to give much of an improvement in typing speed but there are some benefits:
e.g. click and drag allows moving windows, highlighting text, sliding scrollbars.


We can also check capabilities with xinput ("apk add xinput" if not done previously):

To get your device name, execute "DISPLAY=:0 xinput list" (or just "xinput list" from the Kobo):

⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Touchscreen id=6 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]


To get the properties for device 6, "DISPLAY=:0 xinput list-props 6":

Device Enabled (115): 1
Coordinate Transformation Matrix (116): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix (232): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix Default (233): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Send Events Modes Available (234): 1, 0
libinput Send Events Mode Enabled (235): 0, 0
libinput Send Events Mode Enabled Default (236): 0, 0
Device Node (237): "/dev/input/event1"
Device Product ID (238): 0, 0


Unfortunately, nothing that interesting. So for now, let's back everything up:

cp /etc/X11/xorg.conf /shared/
cp /xorg-chroot.sh /shared/
cp /etc/udev/hwdb.d/60-evdev.hwdb /shared/
cp /var/log/Xorg.0.log /shared/


*NOW WE WILL TRY REMOVING /etc/X11/xorg.conf COMPLETELY TO SEE IF IT IS EVEN NEEDED!

OK, So the libinput driver works fine for the touchscreen with NO xorg.conf!

*NOW WE WILL REBOOT AND TRY THE USB KEYBOARD WITHOUT xorg.conf

OK, not only does the USB keyboard work (and can be plugged in after system is running, provided USB host mode is enabled), but the arrow keys work without extra configuring (as I described in the comment preceding this one). I guess adding the udev database did the trick.

For the curious, the Xorg.0.log gives:

[ 61.561] (II) config/udev: Adding input device cyttsp5_mt (/dev/input/event1)
[ 61.561] (**) cyttsp5_mt: Applying InputClass "evdev touchscreen catchall"
[ 61.561] (**) cyttsp5_mt: Applying InputClass "libinput touchscreen catchall"
[ 61.561] (II) Using input driver 'libinput' for 'cyttsp5_mt'
[ 61.561] (**) cyttsp5_mt: always reports core events
[ 61.561] (**) Option "Device" "/dev/input/event1"
[ 61.565] (II) event1 - cyttsp5_mt: is tagged by udev as: Touchscreen Tablet
[ 61.567] (II) event1 - cyttsp5_mt: device is a touch device
[ 61.568] (II) event1 - cyttsp5_mt: device removed
[ 61.620] (**) Option "config_info" "udev:/sys/devices/platform/soc/2100000.aips-bus/21a4000.i2c/i2c-1/1-0024/input/input1/event1"
[ 61.620] (II) XINPUT: Adding extended input device "cyttsp5_mt" (type: TOUCHSCREEN, id 9)
[ 61.622] (**) Option "AccelerationScheme" "none"
[ 61.622] (**) cyttsp5_mt: (accel) selected scheme none/0
[ 61.623] (**) cyttsp5_mt: (accel) acceleration factor: 2.000
[ 61.623] (**) cyttsp5_mt: (accel) acceleration threshold: 4
[ 61.639] (II) event1 - cyttsp5_mt: is tagged by udev as: Touchscreen Tablet
[ 61.642] (II) event1 - cyttsp5_mt: device is a touch device
[ 61.766] (**) HP HP Wireless Mini Keyboard: Applying InputClass "evdev keyboard catchall"
[ 61.766] (**) HP HP Wireless Mini Keyboard: Applying InputClass "libinput keyboard catchall"
[ 61.766] (II) Using input driver 'libinput' for 'HP HP Wireless Mini Keyboard'
[ 61.766] (**) HP HP Wireless Mini Keyboard: always reports core events
[ 61.766] (**) Option "Device" "/dev/input/event2"
[ 61.766] (II) libinput: HP HP Wireless Mini Keyboard: is a virtual subdevice
[ 61.767] (**) Option "config_info" "udev:/sys/devices/platform/soc/2100000.aips-bus/2184000.usb/ci_hdrc.0/usb1/1-1/1-1:1.0/0003:03F0:A107.0001/input/input2/event2"

Last edited by elinkser; 02-09-2023 at 08:49 AM. Reason: hot pluggable USB
elinkser is offline   Reply With Quote