Plippo / twofing

Daemon for two finger gestures
http://www.plippo.de/p/twofing
27 stars 15 forks source link

Calibration scale 1, only usable in top left corner? #5

Closed Patronics closed 2 years ago

Patronics commented 3 years ago

Attempting to set this up with a raspberry pi touchscreen, It seems to transfer all input to the top left corner while twofing is running (but works fine otherwise). Before finding this repo, I did attempt to follow the instructions here, if that might have messed it up?

If it'd be easier, is there any way to manually scale the motion as needed?

twofing, the two-fingered daemon
Version 0.1.5.20200913

Input device name: "raspberrypi-ts"
XInput device id is 6.
XInput device id for calibration is 6.
Start calibration
No calibration data found, use default values.
No valid axis inversion data found, assuming no inversion.
No valid axes swap data found, assuming no swap.
Calibration: MinX: 0; MaxX: 65535; MinY: 0; MaxY: 65535
Invert X Axis: No
Invert Y Axis: No
Swap Axes: No
Calibration Matrix:     1.000000    0.000000    0.000000
                        0.000000    1.000000    0.000000
Grab Result: 0
Reading input from device ... (interrupt to exit)
Plippo commented 3 years ago

You can try to calibrate the screen before starting twofing. As you see in the output, the axes are by default calibrated to a range of 0..65535. You can try to reduce these numbers until they fit. To e.g. change them to 20000, you can call:

xinput set-int-prop 6 "Evdev Axis Calibration" 32 0 20000 0 20000

6 is your device id (as seen in the output above), 32 is a fixed value (size of an integer) and after that come the calibration values (MinX MaxX MinY MaxY). I hope it works!

Plippo commented 3 years ago

@Patronics Did it work for you, can I mark the bug as closed?

Patronics commented 3 years ago

Sorry, I actually haven't had a chance to test it yet, I've been busy with other projects. I can try to spare some time to test it tomorrow, see if this solution works for me

Plippo commented 3 years ago

Don't worry, there's no need to hurry. I was just wondering.

dschugha commented 3 years ago

My cursor is jumping to the top left corner too. I am using:

Raspberry Pi 4B https://www.conrad.de/de/p/raspberry-pi-rb-lcd-7-display-modul-17-8-cm-7-zoll-800-x-480-pixel-passend-fuer-raspberry-pi-1388955.html uname -a Linux raspberrypi 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l GNU/Linux

calibration with xinput set-int-prop 6 "Evdev Axis Calibration" 32 0 20000 0 20000 doesn´t help.

For me it seems that the configuration

Section "InputClass" Identifier "calibration" ...

is not in place and not used. When starting in debug mode with twofing --debug /dev/input/event0 twofing uses "default values".

Whereever I put the configuration I cannot see that anything is used. I do have following X11 configuration files

ls -ln /usr/share/X11/xorg.conf.d/ insgesamt 12 -rw-r--r-- 1 0 0 1099 Aug 23 2018 10-evdev.conf -rw-r--r-- 1 0 0 1350 Jan 15 15:03 10-quirks.conf -rw-r--r-- 1 0 0 1429 Mär 31 2019 40-libinput.conf

Think it would help finding the correct configuration file for calibration.

Plippo commented 3 years ago

Can you post the complete output of twofing --debug /dev/input/event0? Maybe 6 is not the correct xinput id for your devide.

dschugha commented 3 years ago

pi@raspberrypi:~/twofing $ xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ raspberrypi-ts id=6 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] -------------------------------------------------------------------- pi@raspberrypi:~/twofing $ twofing --debug /dev/input/event0 twofing, the two-fingered daemon Version 0.1.5.20200913

Input device name: "raspberrypi-ts" XInput device id is 6. XInput device id for calibration is 6. Start calibration No calibration data found, use default values. No valid axis inversion data found, assuming no inversion. No valid axes swap data found, assuming no swap. Calibration: MinX: 0; MaxX: 65535; MinY: 0; MaxY: 65535 Invert X Axis: No Invert Y Axis: No Swap Axes: No Calibration Matrix: 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 Grab Result: 0 Reading input from device ... (interrupt to exit)

Plippo commented 3 years ago

ID seems right. Strange that xinput set-int-prop 6 "Evdev Axis Calibration" 32 0 20000 0 20000 does not work. It should at least change the twofing output so that the Calibration line would read "Calibration: MinX: 0; MaxX: 20000; MinY: 0; MaxY: 20000"

dschugha commented 3 years ago

Sorry, didn´t realize that I have to execute xinput set-int-pro before, so this is complete output

pi@raspberrypi:~ $ xinput set-int-prop 6 "Evdev Axis Calibration" 32 0 20000 0 20000 pi@raspberrypi:~ $ twofing --debug /dev/input/event0 twofing, the two-fingered daemon Version 0.1.5.20200913

Input device name: "raspberrypi-ts" XInput device id is 6. XInput device id for calibration is 6. Start calibration No valid axis inversion data found, assuming no inversion. No valid axes swap data found, assuming no swap. Calibration: MinX: 0; MaxX: 20000; MinY: 0; MaxY: 20000 Invert X Axis: No Invert Y Axis: No Swap Axes: No Calibration Matrix: 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 Grab Result: 0 Reading input from device ... (interrupt to exit)

dschugha commented 3 years ago

I made an other test

pi@raspberrypi:~ $ sudo su root@raspberrypi:/home/pi# DISPLAY=:0.0 xinput_calibrator Calibrating EVDEV driver for "raspberrypi-ts" id=6 current calibration values (from XInput): min_x=0, max_x=20000 and min_y=0, max_y=20000

Doing dynamic recalibration: Setting calibration data: 90, 20971, 455, 19983 --> Making the calibration permanent <-- copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's) Section "InputClass" Identifier "calibration" MatchProduct "raspberrypi-ts" Option "Calibration" "90 20971 455 19983" Option "SwapAxes" "0" EndSection

When I do put his in /usr/share/X11/xorg.conf.d/99-calibration.conf Raspberry fails to start "startx"

Plippo commented 3 years ago

So it seems that twofing picks up your calibration, which is good. If it works correctly after you set the calibration values using xinput you can then try to make it permanent using xorg.conf or xorg.conf.d, as you tried. I can't really say why startx doesn't work after you have created the configuration file, maybe there is some error in the file. Maybe you find some information in the output of startx or in the log file /var/log/Xorg.0.log (notice the capital X).

dschugha commented 3 years ago

xorg.conf.d is a directory /usr/share/X11/xorg.conf.d/. Does it matter in which configfile I do put the configuration?

Plippo commented 3 years ago

Yes xorg.conf.d is a directory. Just add any file to that directory. The file name doesn't really matter as long as it ends with ".conf". All ".conf" files in this directory are processed in alphabetical order.

dschugha commented 3 years ago

This is very impotant for me to know! So I made some new tests. After: sudo apt-get install xserver-xorg-input-evdev there is a new config file /usr/share/X11/xorg.conf.d/10-evdev.conf I did reboot and everything is OK. Now I did create /usr/share/X11/xorg.conf.d/20-twofing.conf and startx had not been possible any more after reboot. Did delete 20-twofing.conf and everything was OK with startx after reboot. So I don´t understand really what is so dangerous by this calibration entries and what to test next.

Plippo commented 3 years ago

If there is an error in the config file and X cannot parse it, it won't start. I don't know what the error is as I'm no wizard, but I have written you the path to the log file before. When X doesn't start, you can look into the log file or you can try to call startx on the command line to see if there is any output.

dschugha commented 3 years ago

I am new with Raspberry Pi so I am happy about every tip I can get. If X ist started by system there is logfile /var/log/Xorg.0.log. If Raspberry Pi starts and is not able to start X I am in CLI as user pi. If startx then the logfile /home/pi/.local/share/xorg/Xorg.0.log is used. This was confusing for me.

Think I found now a usefull log. There are every time after starting twofing and touch screen entries: [ 474.640] (EE) BUG: triggered 'if (!iclients)' [ 474.640] (EE) BUG: ../../../../Xi/exevents.c:1329 in RetrieveTouchDeliveryData() [ 474.640] (EE) [ 474.640] (EE) Backtrace: [ 474.640] (EE)

Please see complete log: Xorg.0.log

Plippo commented 3 years ago

Well, this looks like a bug in the driver. There's no parsing error to be found but it just crashes. If the config file makes problems, you can always use xinput to set the calibration. With your values this would be xinput set-int-prop 6 "Evdev Axis Calibration" 32 90 20971 455 19983 But this has to be performed after every boot. Maybe you can create a script for it that is then executed after every boot. But to be honest, that is something that has nothing to do with twofing, so maybe you find better help in a Raspberry Pi forum. As I don't own a Raspberry Pi I'm not really an expert in this area.

dschugha commented 3 years ago

Now it twofing works for me. I did make a silly mistake in config file. In your documentation is written MatchProduct "{{ put your device name here, get it with xinput list }}" and made MatchProduct "{{ raspberrypi-ts }}" Unfortunatly X-Windows didn´t show me a clear error message. After removing the { } twofing is working. At start it reflects the real size of my small display Input device name: "raspberrypi-ts" XInput device id is 6. XInput device id for calibration is 6. Start calibration No calibration data found, use default values. Calibration: MinX: 0; MaxX: 799; MinY: 0; MaxY: 479 ... Thank you very much for your help !!!

mgrouch commented 2 years ago

I use this script (run as root) to fix the issue (followed by reboot):


if [ -L /dev/twofingtouch ]
then
  MATCH_PRODUCT=$(udevadm info -a -n /dev/twofingtouch | grep "ATTRS{name}" | sed -e 's#.*=="##' -e 's#"$##')
  bash -c 'cat << EOF > /usr/share/X11/xorg.conf.d/90-touchinput.conf
Section "InputClass"
    Identifier "calibration"
    Driver "evdev"
    MatchProduct "'"${MATCH_PRODUCT}"'"
    MatchDevicePath "/dev/input/event*"
    Option "EmulateThirdButton" "1"
    Option "EmulateThirdButtonTimeout" "750"
    Option "EmulateThirdButtonMoveThreshold" "30"
EndSection
EOF'
fi
Plippo commented 2 years ago

I updated the readme file to reduce the confusion. Closing issue.