Touchscreen input rotation

Screen resolution, 3D Acceleration, nVidia, ATI
Forum rules
Before you post please read this
Post Reply
RandomByte
Level 1
Level 1
Posts: 1
Joined: Wed Sep 26, 2018 7:24 pm

Touchscreen input rotation

Post by RandomByte » Wed Sep 26, 2018 7:38 pm

Hi!

My machine:

Code: Select all

System:    Host: randombyte-ThinkPad-X1-Yoga-3rd Kernel: 4.15.0-34-generic x86_64 bits: 64 gcc: 7.3.0
           Desktop: Cinnamon 3.8.9 (Gtk 3.22.30-1ubuntu1) Distro: Linux Mint 19 Tara
Machine:   Device: laptop System: LENOVO product: 20LDCTO1WW v: ThinkPad X1 Yoga 3rd serial: N/A
           Mobo: LENOVO model: 20LDCTO1WW v: SDK0J40709 WIN serial: N/A
           UEFI: LENOVO v: N25ET26W (1.12 ) date: 04/16/2018
Battery    BAT0: charge: 41.9 Wh 79.4% condition: 52.8/54.1 Wh (98%) model: Celxpert 01AV475 status: Discharging
CPU:       Quad core Intel Core i7-8550U (-MT-MCP-) arch: Kaby Lake rev.10 cache: 8192 KB
           flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 15936
           clock speeds: max: 4000 MHz 1: 800 MHz 2: 800 MHz 3: 800 MHz 4: 800 MHz 5: 800 MHz 6: 800 MHz
           7: 800 MHz 8: 800 MHz
Graphics:  Card: Intel UHD Graphics 620 bus-ID: 00:02.0
           Display Server: x11 (X.Org 1.19.6 ) drivers: modesetting (unloaded: fbdev,vesa)
           Resolution: 2560x1440@59.99hz
           OpenGL: renderer: Mesa DRI Intel UHD Graphics 620 (Kabylake GT2)
           version: 4.5 Mesa 18.0.5 Direct Render: Yes
Audio:     Card Intel Sunrise Point-LP HD Audio driver: snd_hda_intel bus-ID: 00:1f.3
           Sound: Advanced Linux Sound Architecture v: k4.15.0-34-generic
Network:   Card-1: Intel Ethernet Connection (4) I219-V driver: e1000e v: 3.2.6-k bus-ID: 00:1f.6
           IF: enp0s31f6 state: down mac: <filter>
           Card-2: Intel Wireless 8265 / 8275 driver: iwlwifi bus-ID: 02:00.0
           IF: wlp2s0 state: up mac: <filter>
Drives:    HDD Total Size: 512.1GB (18.0% used)
           ID-1: /dev/nvme0n1 model: SAMSUNG_MZVLB512HAJQ size: 512.1GB
Partition: ID-1: / size: 173G used: 69G (42%) fs: ext4 dev: /dev/nvme0n1p6
           ID-2: swap-1 size: 20.00GB used: 0.00GB (0%) fs: swap dev: /dev/nvme0n1p5
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   System Temperatures: cpu: 50.0C mobo: N/A
           Fan Speeds (in rpm): cpu: 4468
Info:      Processes: 271 Uptime: 33 min Memory: 1771.7/15803.2MB Init: systemd runlevel: 5 Gcc sys: 7.3.0
           Client: Shell (zsh 5.4.2) inxi: 2.3.56
When turning automatic screen rotation on, the screen rotates correctly. But the touchscreen input seems not to rotate, so the original upper left corner is after the rotation still the upper left corner. So the input is always in some direction mirrored, and ofc unusable. How would you go about fixing it?

Kind regards
RandomByte

kryssb
Level 1
Level 1
Posts: 15
Joined: Fri Apr 28, 2017 5:11 pm

Re: Touchscreen input rotation

Post by kryssb » Fri Oct 19, 2018 6:14 pm

Hi RandomByte,

I find exactly the same as you are describing. It's a pity, rotation is useless in these conditions.
My hardware is a Dell XPS 13 9365.
I would like to add that both the touchscreen and the mousepad input do not take rotation into account. One may agree or disagree about the latter, but there is no doubt that on the touchscreen it's quite disappointing to see the mouse going to a place that is different from the point you're pressing.
I found the solution. Please see next post.
Regards

Cristiano
Last edited by kryssb on Sat Oct 20, 2018 5:31 pm, edited 1 time in total.

kryssb
Level 1
Level 1
Posts: 15
Joined: Fri Apr 28, 2017 5:11 pm

Re: Touchscreen input rotation - SOLVED

Post by kryssb » Sat Oct 20, 2018 5:22 pm

Here is the solution to your problem, adapted from another forum to Dell XPS 13.
The xinput device numbers change for each machine and can be obtained by typing

Code: Select all

xinput
on the terminal and reading the output. For Dell XPS 13, device numbers 12, 13 and 20 are found to work well.
Put the following into a script and put it in the list of startup applications. If you use a device number that does not exist on your machine, you get a "Badmatch" error message.

Code: Select all

#!/bin/sh
# Auto rotate touch screen based on device orientation for Dell XPS-13 (9365)
# adapted by Cristiano Bozza
#
#   Based on chadm's script at https://linuxappfinder.com/blog/auto_screen_rotation_in_ubuntu.

# Receives input from monitor-sensor (part of iio-sensor-proxy package) and sets the touchscreen
# orientation based on the accellerometer positionn. We assume that the display rotation is 
# handled by Linux Mint 18.1, Cinnamon 3.2.7. If this is not the case, add the appropriate
# xrandr command into each case block.

# Notice the device numbers 12, 13 and 20 are obtained by running
#   xinput
# and reading the output, which for Dell XPS 13 is:
# ⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
# ⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
# ⎜   ↳ Wacom HID 4831 Pen stylus               	id=12	[slave  pointer  (2)]
# ⎜   ↳ Wacom HID 4831 Finger touch             	id=13	[slave  pointer  (2)]
# ⎜   ↳ DLL077A:01 06CB:76AF Touchpad           	id=14	[slave  pointer  (2)]
# ⎜   ↳ SynPS/2 Synaptics TouchPad              	id=19	[slave  pointer  (2)]
# ⎜   ↳ Wacom HID 4831 Pen eraser               	id=20	[slave  pointer  (2)]
# + other lines

# This script should be added to startup applications for the user.

# Kill any existing monitor-sensor instance, for example if manually invoking
# from a terminal for testing.
killall monitor-sensor

# Launch monitor-sensor and store the output in a RAM based file that can be checked by the rest of the script.
# We use the RAM based file system to save wear where an SSD is being used.
monitor-sensor > /dev/shm/sensor.log 2>&1 &

# Initialise display orientation to 'normal'
# Without this, the display often starts in 'inverted' (or 'bottom-up') mode!
xrandr --output eDP1 --rotate normal
xinput set-prop 12 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
xinput set-prop 13 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
xinput set-prop 20 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1

# Parse output of monitor sensor to get the new orientation whenever the log file is updated
# Possibles are: normal, bottom-up, right-up, left-up
# Light data will be ignored
while inotifywait -e modify /dev/shm/sensor.log; do

# Read the last few lines that were added to the file and get the last orientation line.
ORIENTATION=$(tail /dev/shm/sensor.log | grep 'orientation' | tail -1 | grep -oE '[^ ]+$')

# Set the actions to be taken for each possible orientation
case "$ORIENTATION" in
bottom-up)
xinput set-prop 12 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
xinput set-prop 13 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
xinput set-prop 20 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1;;
normal)
xinput set-prop 12 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
xinput set-prop 13 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
xinput set-prop 20 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1;;
right-up)
xinput set-prop 12 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
xinput set-prop 13 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
xinput set-prop 20 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1;;
left-up)
xinput set-prop 12 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1
xinput set-prop 13 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1
xinput set-prop 20 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1;;
esac
done

# On stopping this script, don't forget that "monitor-sensor" is still running - hence the "killall" !

Post Reply

Return to “Graphics Cards & Monitors”