wolfefin
Posts: 11
Joined: Thu Sep 28, 2017 10:02 pm

Can't Rotate Full-size Touchscreen (can rotate display though)

Thu Sep 28, 2017 10:13 pm

I've found a lot of posts on how to rotate the display:

/boot/config.txt display_rotate=1

and how to rotate the touchscreen on the official Raspberry Pi touchscreen with lcd_rotate=2

However, I'm trying to rotate the touchscreen attached to a Raspberry Pi via a standard USB cable going into a full-size monitor screen. I can rotate the display, but I can't get the touchscreen to work properly.

Here's what happens

If I don't put any extra parameters in, the touchscreen works fine and the view is in landscape (what most people think of as a regular monitor orientation).

If I use display_rotate=1, it works and the Pi is oriented in portrait mode (90 degrees from original orientation), great! However, now the touchscreen is flipped and x is y and y is x.

If I use lcd_rotate=1 or 2, it has no effect even if I comment out the display_rotate completely, which makes me think it's really only for the official Pi display.

Does anyone have some insights for me? I'm using this with the desktop, I just need to display a web page in portrait instead of landscape, so even if there's something in the GUI to do this, I'm down.

Thanks!

wolfefin
Posts: 11
Joined: Thu Sep 28, 2017 10:02 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 12:53 pm

Updated the subject to be more clear about the problem.

User avatar
DougieLawson
Posts: 35814
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 1:10 pm

Does it appear as an evdev device? Have you looked at xinput-calibrator?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

wolfefin
Posts: 11
Joined: Thu Sep 28, 2017 10:02 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 3:36 pm

DougieLawson wrote:
Fri Sep 29, 2017 1:10 pm
Does it appear as an evdev device? Have you looked at xinput-calibrator?
I'm not sure. How can I check if it is an evdev device and where would I find the xinput-calibrator.

I did see a number of articles regarding the official RPi touchscreen, where there are lines of code in /etc/modules and /etc/X11/xinit/xinitrc (path unsure). But neither of those configs exist for me, meaning, there's only one line in /etc/modules and same for xinitrc. Since the touchscreen is through the standard USB on the front versus a ribbon cable or something else on-board of the RPi, I figured that was the reason these files weren't modified.

Thanks in advance,

User avatar
DougieLawson
Posts: 35814
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 4:46 pm

Are you running Raspbian Stretch?

sudo apt install xinput-calibrator gets the calibrator installed.

Code: Select all

[email protected]:/etc/X11/xinit # cat xinitrc
#!/bin/sh

# /etc/X11/xinit/xinitrc
#
# global xinitrc file, used by all X sessions started by xinit (startx)

# invoke global X session script
. /etc/X11/Xsession
[email protected]:/etc/X11/xinit #
Xsession is a shell script that gets the X11 server running.

The evdev stuff generated by xinput-calibrator goes in /usr/share/X11/xorg.conf.d/45-evdev.conf (which won't exist on your system).
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23385
Joined: Sat Jul 30, 2011 7:41 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 4:49 pm

wolfefin wrote:
Thu Sep 28, 2017 10:13 pm
If I use lcd_rotate=1 or 2, it has no effect even if I comment out the display_rotate completely, which makes me think it's really only for the official Pi display.
Correct, lcd_rotate only works on the RPF touchscreen driver. Anything USB connected and you will need to find the settings for that particular driver. Might need to recompile it to swap x and y, both ordinates and screen size.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

wolfefin
Posts: 11
Joined: Thu Sep 28, 2017 10:02 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 5:03 pm

DougieLawson wrote:
Fri Sep 29, 2017 4:46 pm
Are you running Raspbian Stretch?
Unsure, I did a cat of /etc/os-release and it says Version 8 (jessie) does that help?
DougieLawson wrote:
Fri Sep 29, 2017 4:46 pm

Code: Select all

[email protected]:/etc/X11/xinit # cat xinitrc
Yep same as my xinitrc, sorry I should've been clearer that there was only one non-comment line, but yep I see the same.
DougieLawson wrote:
Fri Sep 29, 2017 4:46 pm
The evdev stuff generated by xinput-calibrator goes in /usr/share/X11/xorg.conf.d/45-evdev.conf (which won't exist on your system).
So I installed the xinput-calibration package, but I'm unsure what do to next. I don't see a file like 45-evdev.conf in /usr/share/X11/xorg.conf.d. I do see three files in there though. 10-quirks.conf, 40-libinput.conf, and 99-fbturbo.conf.

I did confirm that the there's no change in the touchscreen activity. Sorry if this is pretty noobish, but I appreciate the help.

wolfefin
Posts: 11
Joined: Thu Sep 28, 2017 10:02 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 6:33 pm

So, quick update, I got the xinput_calibrator to run (installed it, then ran "xinput_calibrator" from term window) and it gave me four points, I touched them, that worked, it gave me the output, I put it into a file (it suggested /etc/X11/xorg.conf.d/, but I did Dougie's suggestion of /usr/share/X11/xorg.conf.d/ instead) I named it what they suggested 99-calibration.conf. I restarted and no change.

I was able to get nearly what I wanted by using this instead:

Code: Select all

xinput set-prop "Your Touchscreen's Name" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
Where I replaced the "Your touchscreen" with "eGalax Inc. USB Touch Controller" The only issue was that up is down and down is up, but side to side worked fine, and the change is lost on reboot so I'd need to run it on boot up or find a way to add this into the X config files somewhere.

wolfefin
Posts: 11
Joined: Thu Sep 28, 2017 10:02 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 6:54 pm

I was able to find a nice article on xinput Coordinate Transformation Matrix here: https://wiki.ubuntu.com/X/InputCoordinateTransformation

So I was using the Left rotation transformation matrix and I needed the right rotation transform which was:

Code: Select all

xinput set-prop "eGalax Inc. USB TouchController" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
Where the "eGalax..." is the name of your touchscreen when you run:

Code: Select all

xinput --list
I still need to find how to make this a runtime param of X server, but given that I've searched nearly 50 different websites and this forum and no one seemed to have the full answer, I figured I'd help by posting what I know as I go along for anyone else running into the issue.

wolfefin
Posts: 11
Joined: Thu Sep 28, 2017 10:02 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 7:14 pm

Last piece of the puzzle, similar to what Dougie had mentioned, create a conf file in /usr/share/X11/xorg.conf.d/ I called mine 90-right-rotate.conf and use the following:

Code: Select all

Section "InputClass"
    Identifier    "RotateTouchCW"
    MatchProduct    "eGalax Inc. USB TouchController"
    Option    "TransformationMatrix" "0 1 0 -1 0 1 0 0 1"
EndSection
The Identifier can probably be anything, but I used what they mentioned in this article and sub'd out my touchscreen name for the MatchProduct line: https://wiki.ubuntu.com/X/Config/Input

So here's the full recipe:

1) Edit /boot/config.txt and add this line

Code: Select all

display_rotate=1
That will rotate your display 90 degrees clockwise

2) run this to find the name of your touchscreen

Code: Select all

xinput --list
3) create a file in /usr/share/X11/xorg.conf.d/ called something like 90-right-rotate.conf and use the code section noted above swapping out your MatchProduct line with what you found in the xinput list from #2.

and bob's your uncle!

User avatar
DougieLawson
Posts: 35814
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 7:25 pm

I'm currently trying to unzip an archive from a system I built in 2016 with an egalax touch screen so I can take a look at the X11 stuff I wrote for that one. I had to switch the axes round to make the mouse pointer follow the touches on the screen for that one.

Watch this space ...
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

wolfefin
Posts: 11
Joined: Thu Sep 28, 2017 10:02 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 8:38 pm

In case anyone is looking for it at the same time, I'm using this to make an interactive kiosk and I'm using this to be able to autoload a webpage in full screen mode. There are a bunch of ways to do this, but I found this file in the pi autostart subdir of .config to be pretty simple to do. Here's the ref: https://raspberrypi.stackexchange.com/q ... ie-11-2015

Here's the instructions:
1) create a new file (personally I use vi because it's always there, but I understand wanting something else)

Code: Select all

vi ~/.config/autostart/autoChromium.desktop
2) With contents similar to this:

Code: Select all

[Desktop Entry]
Type=Application
Exec=/usr/bin/chromium-browser --noerrdialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://www.website.com
Hidden=false
X-GNOME-Autostart-enabled=true
Name=AutoChromium
Comment=Auto start kiosk site
Worked really well.

User avatar
DougieLawson
Posts: 35814
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 8:59 pm

This is what I found
/usr/share/X11/xorg.conf.d/60-calibration.conf

Code: Select all

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "eGalax Inc. USB TouchController"
        Option  "Calibration"   "3990 153 440 3468"
#       Option "InvertX"
        Option "SwapAxes"
EndSection

Section "ServerLayout"
        Identifier "ServerLayout0"
        Option "BlankTime" "90"
        Option "StandbyTime" "90"
        Option "SuspendTime" "90"
        Option "OffTime" "0"
EndSection
The thing to note there is 'Option "SwapAxes"' and the commented out 'Option "InvertX"' [There's also 'InvertY' if you need to swap just one axis].

/usr/share/X11/xorg.conf.d/10-evdev.conf

Code: Select all

#
# Catch-all evdev loader for udev-based systems
# We don't simply match on any device since that also adds accelerometers
# and other devices that we don't really want to use. The list below
# matches everything but joysticks.

Section "InputClass"
        Identifier "evdev pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

Section "InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

Section "InputClass"
        Identifier "evdev touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

Section "InputClass"
        Identifier "evdev tablet catchall"
        MatchIsTablet "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

Section "InputClass"
        Identifier "evdev touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection
This one is the config that gets the touchscreen running.

I don't think there was anything else that I needed to add to get that X11 config running.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

wolfefin
Posts: 11
Joined: Thu Sep 28, 2017 10:02 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Sep 29, 2017 9:41 pm

Nice, good stuff, thanks Dougie

Lademeister
Posts: 2
Joined: Fri Apr 20, 2018 10:56 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Apr 20, 2018 11:29 pm

That one worked! Thanks one million times!
After googling for days Wolefin‘s hint was what I needed.
I am using a 1024x600 HDMI touchpanel with USB capacitive touch and latest Raspbian on RaspberryPi3.
I am also starting Chromium into kiosk mode to use HabPanel from Openhab home automation.
I have a setup where I needed to rotate screen and touch interface by 90 deg to the right.
Screen rotation was easy, adding

Code: Select all

display_rotate=1
to /boot/config.txt
Nothing seemed to work for the touch rotation - until I tried that great variant using the transformation matrix.
As I am using ssh the command xinput needs the information which display to use. To list devices you put
DISPLAY=:0 xinput --list
I got a double:

Code: Select all

 Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ 2.4GHZ Mouse                              id=7    [slave  pointer  (2)]
⎜   ↳ ILITEK ILITEK-TP                          id=8    [slave  pointer  (2)]
⎜   ↳ ILITEK ILITEK-TP                          id=9    [slave  pointer  (2)]
⎜   ↳ Logitech USB Receiver                     id=11   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ 2.4GHZ Mouse                              id=6    [slave  keyboard (3)]
    ↳ Logitech USB Receiver                     id=10   [slave  keyboard (3)]
    ↳ 2.4GHZ Mouse                              id=12   [slave  keyboard (3)]
    ↳ Logitech USB Receiver                     id=13   [slave  keyboard (3)]
Notice that it found two ILITEK ILITEK-TP devices (I only have one)
This tricked me because most examples use the name - something like 'Displayname from xinput list' and this command returns an error when handling over a name that double exists.


With

Code: Select all

DISPLAY=:0 xinput --set-prop 8 --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
I tell input to explicitly use the device with id=8 (notice the 8 after —set-prop).
This worked right away.
To do: find out how to tell the .conf file (as described above) to use an certain id to make changes permanent.
If that doesn’t work I will follow one of the examples around in the net using a bash script upon start.

Thanks again, after a lot of searching I finally got it working!

Lademeister
Posts: 2
Joined: Fri Apr 20, 2018 10:56 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Apr 20, 2018 11:55 pm

Also found out how to deal with doubled devices:
I added a new file to /usr/share/X11/xorg.conf.d/ :

Code: Select all

sudo nano usr/share/X11/xorg.conf.d/90-rotate-touch.conf
with the following content:

Code: Select all

Section "InputClass"
Identifier "ILITEK ILITEK-TP"
MatchProduct "ILITEK ILITEK-TP"
MatchDevicePath "/dev/input/event3"
Option "TransformationMatrix" "0 1 0 -1 0 1 0 0 1"
EndSection
Notice the line MatchDevicePath.
To find out the event number (3 in my case) I installed evtest

Code: Select all

sudo apt-get install evtest
and called it:

Code: Select all

evtest
This asks me to select one of the found devices and shows you if there is any input.

Code: Select all

[email protected]:~ $ evtest
No device specified, trying to scan all of /dev/input/event*
Not running as root, no devices may be available.
Available devices:
/dev/input/event0:      2.4GHZ Mouse
/dev/input/event1:      2.4GHZ Mouse
/dev/input/event2:      ILITEK ILITEK-TP
/dev/input/event3:      ILITEK ILITEK-TP
/dev/input/event4:      Logitech USB Receiver
/dev/input/event5:      Logitech USB Receiver
Select the device event number [0-5]:
Touching your panel you should see input, if not repeat with another device number. In my case I tried number 2 and 3 because I needed to find out which one to use.

Creating the file as I described above will make the changes permanent so it works right away after booting.
...and bob‘s your uncle :-) (never heard that one before here in Germany btw)

Piefurz
Posts: 7
Joined: Sat Jul 28, 2018 4:36 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Mon Aug 06, 2018 2:47 am

I have an elo 12" touch panel that I can finally get the touch rotated 90 deg cw but can't get it calibrated. The arrows fall short of the x's when using the calibration program. Tried clicking x's with a mouse and using those numbers and touching past the x's to try hitting the spot with the arrow. nothing works. this post is hard to follow from start to finish for a noob and may not even work for me. Spending more time trying to get projects to work than I will ever get use out of them.

wolfefin
Posts: 11
Joined: Thu Sep 28, 2017 10:02 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Tue Aug 07, 2018 5:53 pm

Piefurz wrote:
Mon Aug 06, 2018 2:47 am
I have an elo 12" touch panel that I can finally get the touch rotated 90 deg cw but can't get it calibrated. The arrows fall short of the x's when using the calibration program. Tried clicking x's with a mouse and using those numbers and touching past the x's to try hitting the spot with the arrow. nothing works. this post is hard to follow from start to finish for a noob and may not even work for me. Spending more time trying to get projects to work than I will ever get use out of them.
I had the same issue and tried and tried to get the ELO touchscreen to position the cursor underneath the finger, but no matter what I did, he further away from the center you were, the worse the distance got. I ended up going with a completely different solution to be able get a touchscreen kiosk to work with the ELO screens. I used a small form-factor pc and the Porteus Kiosk, which is free. It might not be what you need for what you're looking to do, but maybe it will help! Cheers.

wolfefin
Posts: 11
Joined: Thu Sep 28, 2017 10:02 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Tue Aug 07, 2018 5:54 pm

Lademeister wrote:
Fri Apr 20, 2018 11:55 pm
...and bob‘s your uncle :-) (never heard that one before here in Germany btw)
Lol, it's something my Dad used to say here in the states, probably a midwest thing. Glad you liked it :D

strato79
Posts: 2
Joined: Fri Dec 21, 2018 1:02 pm

Re: Can't Rotate Full-size Touchscreen (can rotate display though)

Fri Dec 21, 2018 1:16 pm

I found a solution that worked for my 4.3" TFT Capacitive touch display from BuyDisplay.com. Here's a video from the Web, showing how to flip the display 90 deg.
https://www.youtube.com/watch?v=6PSspIiLfAI

Below are the steps outlined in the video, its' quite complicated, these steps are for 180deg rotation:

Rotate 4.3” LCD Touch Display 180° on RPI3

Code: Select all

sudo nano /boot/config.txt
add line: "display_rotate=2" at end of file

Save and exit

Code: Select all

sudo reboot
The display will be rotated, but the touch screen is still reversed.

Code: Select all

sudo apt-get install xserver-xorg-input-libinput
sudo mkdir /etc/X11/xorg.conf.d
sudo cp /usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/
sudo nano /etc/X11/xorg.conf.d/40-libinput.conf
add: Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1"

to the section with Identifier "libinput touchscreen catchall"

Code: Select all

Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchscreen "on"
        Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Save, Exit and Reboot

The touch screen should now match the LCD Rotation

Return to “Troubleshooting”