Page 1 of 2

touchscreen inversion stopped working PIXEL

Posted: Thu Jan 19, 2017 5:18 am
by madbutter
I updated my RPi-based kiosk project to use the latest Jessie/Pixel distro. I am using a rotated (vertical) RPi touchscreen and the rotation looks correct but the touch functionality is no longer inverted as it was before the upgrade. In other words the display is correctly rotated visually and the mouse works properly but the touch is not "inverted".
This was handled in the previous version of Jesse in a shell script executed on startup with these lines:
xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 0 1
xinput --set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1
I tried to run the line in terminal (tty0) and it says:
property 'Evdev Axis Inversion' doesn't exist, you need to specify its type and format
I also notice that the same error pops up in a console window when I boot up, when the shell script is executed.
Can anyone help me?
Also the Pixel interface seems sluggish, I have to hold the mouse down for a few extra beats to get it to trigger - like when I try to open a terminal window from the top menu bar or shutdown with the mouse

Re: touchscreen inversion stopped working PIXEL

Posted: Thu Jan 19, 2017 6:28 am
by DidaJI
I have the same problem...

Re: touchscreen inversion stopped working PIXEL

Posted: Thu Jan 19, 2017 11:19 am
by dom
How are you rotating the display? (i.e. have you added a line to config.txt?)

Re: touchscreen inversion stopped working PIXEL

Posted: Thu Jan 19, 2017 12:31 pm
by DidaJI
Yes,
in config.txt I have: display_rotate=3 (rotate display)
and after boot I run script with:
xinput set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1
xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 0
(rotate touchscreen).
Until yesterday everything worked, OK, after system upgrade rotate touchscreen stopped working.
Rotate display is OK, rotate touchscreen not.

Re: touchscreen inversion stopped working PIXEL

Posted: Thu Jan 19, 2017 3:01 pm
by dom
I don't have an LCD display with me - can test tomorrow.

What does

Code: Select all

xinput list
xinput list-props 'FT5406 memory based driver'
report?

Re: touchscreen inversion stopped working PIXEL

Posted: Thu Jan 19, 2017 3:21 pm
by DidaJI
xinput list write:
⎜ ↳ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ FT5406 memory based driver id=7 [slave pointer (2)]
⎜ ↳ USB Mouse id=8 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ CHICONY USB Keyboard id=6 [slave keyboard (3)]

xinput list-props 'FT5406 memory based driver' write:
Device Enabled (114): 1
Coordinate Transformation Matrix (115): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix (252): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix Default (253): 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
libinput Horizontal Scroll Enabled (239): 0

Re: touchscreen inversion stopped working PIXEL

Posted: Thu Jan 19, 2017 3:23 pm
by DidaJI
But xinput set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1 write:
property 'Evdev Axes Swap' doesn't exist, you need to specify its type and format

Re: touchscreen inversion stopped working PIXEL

Posted: Thu Jan 19, 2017 3:27 pm
by DidaJI
On the kernel version 4.4.38 is everything okay but on the version 4.4.43 it writes this one error.

Re: touchscreen inversion stopped working PIXEL

Posted: Fri Jan 20, 2017 7:29 am
by madbutter
Just to be clear: the display is visually rotated by putting

Code: Select all

display_rotate=1
into /boot/config.txt

The xinput commands I (we) put in: /etc/xdg/lxsession/LXDE-pi/autostart

Code: Select all

xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 0 1
xinput --set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1
are to remap the touchscreen input.

-madbutter

Re: touchscreen inversion stopped working PIXEL

Posted: Fri Jan 20, 2017 4:34 pm
by dom
DidaJI wrote:On the kernel version 4.4.38 is everything okay but on the version 4.4.43 it writes this one error.
I've tested with latest apt-get kernel (Linux domnfs 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux) which worked.
I've tested after rpi-update (Linux domnfs 4.4.43-v7+ #948 SMP Sun Jan 15 22:20:07 GMT 2017 armv7l GNU/Linux) and that is also working.

Are you saying this doesn't work for you?
i.e. does reverting to 4.4.38 kernel work and updating to 4.4.43 kernel fails?

Re: touchscreen inversion stopped working PIXEL

Posted: Fri Jan 20, 2017 5:51 pm
by dom
Okay I have reproduced. Seems it is an apt-get upgrade of one the X packages has switched form using evdev to libinput.
While this can be reverted, this is how Debian Stretch works so it is probably best to adjust to the new world.

I think you want to use the tranformation matrix to swap the coordinates around. I think this is what you want:

Code: Select all

xinput --set-prop 'FT5406 memory based driver' 'Coordinate Transformation Matrix'  0 1 0 -1 0 1 0 0 1
See: https://wiki.ubuntu.com/X/InputCoordinateTransformation

Re: touchscreen inversion stopped working PIXEL

Posted: Sat Jan 21, 2017 9:49 am
by madbutter
Didn't seem to work for me. I tried it in a terminal and it just sits there with a > until I Ctrl-C out (and there is no change to the touch orientation). If I hit return it just puts a > on a new line. I then put it in the shell script that contained the old command (and commented out the old Evdev commands) and re-started and that did not work either. In the terminal I can run
xinput list
and see
'FT5406 memory based driver'
in the list and I can
xinput list-props 'FT5406 memory based driver' | grep "Coordinate Transformation Matrix"
and see the identity matrix I just can't seem to set it with --set-prop

Re: touchscreen inversion stopped working PIXEL

Posted: Sat Jan 21, 2017 10:19 am
by rpdom
madbutter wrote:Didn't seem to work for me. I tried it in a terminal and it just sits there with a > until I Ctrl-C out
That means that you haven't typed the command correctly. There is a missing quote mark or something. The command line is still waiting for you to type in the matching end quote.
Here's an example of what happens when you miss a quote mark.

Code: Select all

[email protected] ~ $ echo 'hello
> what?
> Oh, I missed the endquote
> here it is'
hello
what?
Oh, I missed the endquote
here it is
[email protected] ~ $ 
So make sure you type all four ' marks in that command.

Re: touchscreen inversion stopped working PIXEL

Posted: Sun Jan 22, 2017 9:52 am
by DidaJI
This one command:
"xinput --set-prop 'FT5406 memory based driver' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1" switch x-axis and y-axis for me.
Axis already so move right, but I need still switch direction left<>right and up<>down.

Re: touchscreen inversion stopped working PIXEL

Posted: Sun Jan 22, 2017 5:03 pm
by dom
DidaJI wrote:This one command:
"xinput --set-prop 'FT5406 memory based driver' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1" switch x-axis and y-axis for me.
Axis already so move right, but I need still switch direction left<>right and up<>down.
That command is a right rotate. If you want a left rotate then try:

Code: Select all

xinput --set-prop 'FT5406 memory based driver' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1

Re: touchscreen inversion stopped working PIXEL

Posted: Sun Jan 22, 2017 5:47 pm
by DidaJI
Bingo, thank you very much Dom! Now everything works fine...

Re: touchscreen inversion stopped working PIXEL

Posted: Sun Jan 22, 2017 9:35 pm
by gulliverrr
Worked for me for slightly altered as I have ADS7846. My 2 cents:
1. If you are via SSH,

Code: Select all

xinput list
does not work. Run it like that instead

Code: Select all

DISPLAY=:0.0 xinput list
2. If the above command reports "ADS7846" instead of "FT5406" run this command

Code: Select all

DISPLAY=:0.0 xinput --set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1
or
DISPLAY=:0.0 xinput --set-prop 'ADS7846 Touchscreen' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
depending on the way you need it rotated.
The above change is gone though after restart. Is there a way to make it permanent or do I need to run it as a script on boot?
Thanks!

Re: touchscreen inversion stopped working PIXEL

Posted: Mon Jan 23, 2017 1:00 pm
by dom
gulliverrr wrote:The above change is gone though after restart. Is there a way to make it permanent or do I need to run it as a script on boot?
@madbutter reported adding to /etc/xdg/lxsession/LXDE-pi/autostart

Re: touchscreen inversion stopped working PIXEL

Posted: Tue Jan 24, 2017 11:18 am
by madbutter
Just wanted to confirm that this is working for me, once I got the typos out, and that it is started automatically when I boot the Pi.
To sum up the whole procedure to have R-Pi touchscreen startup in in portrait mode:

1. In /boot/config.txt type in and save:
display_rotate=1

2. In /etc/xdg/lxsession/LXDE-pi/autostart type in and save:
xinput --set-prop 'FT5406 memory based driver' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1

Thanks for your help, Dom

Re: touchscreen inversion stopped working PIXEL

Posted: Tue Jan 24, 2017 2:05 pm
by dasmanul
Can somebody explain to me why the transformation matrix for transforming 2D coordinates is 3x3?

Re: touchscreen inversion stopped working PIXEL

Posted: Tue Jan 24, 2017 3:12 pm
by dom
dasmanul wrote:Can somebody explain to me why the transformation matrix for transforming 2D coordinates is 3x3?
You can't achieve a translation with a 2x2 matrix. You may want (0,0) to end up at (1280,720) when display is rotated 180 degrees.

Re: touchscreen inversion stopped working PIXEL

Posted: Tue Jan 24, 2017 4:52 pm
by dasmanul
Thanks. I still don't quite get it though. The linked page gives the matrix for 180° rotation as

Code: Select all

⎡ -1  0 1 ⎤
⎜  0 -1 1 ⎥
⎣  0  0 1 ⎦
How would that turn (0,0) into (1280,720)?

Re: touchscreen inversion stopped working PIXEL

Posted: Tue Jan 24, 2017 4:56 pm
by dom
The multiplication would be:

Code: Select all

⎡ -1  0 1 ⎤⎡x⎤
⎜  0 -1 1 ⎥⎜y⎥
⎣  0  0 1 ⎦⎣1⎦
with x and y normalised to [0,1]

So (0,0) would give (1, 1, 1) which when un-normalised gives (1280, 720)

Re: touchscreen inversion stopped working PIXEL

Posted: Tue Jan 24, 2017 5:08 pm
by divejunk
Finally it is working!

This line did the job:
xinput --set-prop 'FT5406 memory based driver' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1

But:
after a reboot it's gone.
I placed it in /etc/xdg/lxsession/LXDE-pi/autostart

Any one any thoughts?

Re: touchscreen inversion stopped working PIXEL

Posted: Tue Jan 24, 2017 6:13 pm
by dasmanul
@dom: Thanks, got it now!