Linux rotate touch screen

Ubuntu Wiki

Recent X.org servers have incorporated a property for setting how input device events are translated to screen coordinates. This property can be used to ensure a touchscreen is not stretched across a multi-monitor setup or to rotate the touch screen input when you rotate the physical device.

Printing the Coordinate Transformation Matrix

First, we need to determine the name of the input device. Run the following:

⎡ Virtual core pointer [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer [slave pointer (2)] ⎜ ↳ SynPS/2 Synaptics TouchPad [slave pointer (2)] ⎣ Virtual core keyboard [master keyboard (2)] ↳ Virtual core XTEST keyboard [slave keyboard (3)] ↳ Power Button [slave keyboard (3)] ↳ Video Bus [slave keyboard (3)] ↳ Power Button [slave keyboard (3)] ↳ HID 413c:8161 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard [slave keyboard (3)]

We’ll operate on the «SynPS/2 Synaptics TouchPad». To print the Coordinate Transformation Matrix (CTM), run the following:

$ xinput list-props 'SynPS/2 Synaptics TouchPad' | grep "Coordinate Transformation Matrix"

By default, this will output:

Coordinate Transformation Matrix (137): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

This is a 3×3 coordinate transformation matrix. It’s encoded in row-major order, so the matrix would look like the following in a text book:

Astute readers will recognize that this is the identity matrix.

Using the Coordinate Transformation Matrix

By default, the CTM for every input device in X is the identity matrix. As an example, lets say you touch a touchscreen at point (400, 197) on the screen:

⎡ 1 0 0 ⎤ ⎡ 400 ⎤ ⎡ 400 ⎤ ⎜ 0 1 0 ⎥ · ⎜ 197 ⎥ = ⎜ 197 ⎥ ⎣ 0 0 1 ⎦ ⎣ 1 ⎦ ⎣ 1 ⎦

The X and Y coordinates of the device event are input in the second matrix of the calculation. The result of the calculation is where the X and Y coordinates of the event are mapped to the screen. As shown, the identity matrix maps the device coordinates to the screen coordinates without any changes.

Читайте также:  Почему линукс быстрее виндовс

The transformation matrix used is called an affine transformation matrix. Note that the translation values are in normalized floating point coordinates.

Left rotate (clockwise 90°)

Lets say we physically rotate the screen by 90° (from left) to the right. The X server screen can be rotated so that the display output matches the new orientation:

Not all graphics drivers support rotation

Now we want to map our touchscreen to the new orientation (90° (from left) to the right) as well. Using the affine transformation rules we would want our transformation matrix to be:

Right rotate (counterclockwise 90°)

For 90° (from right) to the left.

Not all graphics drivers support rotation

with a transformation matrix of:

Invert rotate (clockwise or counterclockwise 180°)

Not all graphics drivers support rotation

with a transformation matrix of:

Limit Range

Instead, lets say we have two monitors side by side, and our touchscreen is on the right monitor. They have the same resolution in the X direction. We don’t want our touchscreen mapped across both monitors, so we need to map the device coordinates to only the right half of the screen. Again, using the affine transformation rules we would want our transformation matrix to be:

Setting the Coordinate Transformation Matrix

Once we have determined the CTM, we need to set the matrix for the input device. We’ll assume the device name has been retrieved using ‘xinput list’ as described above. To set the matrix, run:

$ xinput set-prop » ‘Coordinate Transformation Matrix’

For example, to set the CTM to:

xinput set-prop '' 'Coordinate Transformation Matrix' 0.5 0 1 0 1 0 0 0 1

X/InputCoordinateTransformation (последним исправлял пользователь li200-146 2014-09-04 02:33:09)

The material on this wiki is available under a free license, see Copyright / License for details.

Читайте также:  Linux remove file recursively

Источник

How to rotate touch screen input on Ubuntu 16.04?

A system got a fresh install of Ubuntu 16.04.2 LTS. The connected ELO touch display works fine in landscape mode. Having the display being installed in clockwise rotated portrait format, led to switching the display mode to portrait via the System Settings > Displays dialog, similar to this resolution change description. The portrait display setting works fine, but the touch screen input does not rotate appropriately. Installation and start up of xinput-calibrator seems to work, as no error is given, but all touch input events result in (then calibrated) upper right hand touch events on the portrait format display, irrespectively of the actual touch position on the screen. The console output of xinput_calibrator is:

$ sudo xinput_calibrator Setting calibration data: 0, 4095, 0, 4095 Calibrating EVDEV driver for "Elo TouchSystems, Inc. Elo TouchSystems 2700 IntelliTouch(r) USB Touchmonitor Interface" current calibration values (from XInput): min_x=0, max_x=4095 and min_y=0, max_y=4095 Doing dynamic recalibration: Swapping X and Y axis. Setting calibration data: 2604, 2599, 1620, 1635 --> Making the calibration permanent  

As calibration does not work, no permanent configurations were made to the suggested 99-calibration.conf . I did not find a similar problem were all touch events were calibrated to a single corner of the screen. I tried then calibration with the display in landscape mode, which works fine. Any hints?

Источник

Rotate Touch Input with touchscreen and/or touchpad

So I just bought an Asus x202e, and have installed Xubuntu 13.04 on it. All working great. However, I want to be able to rotate the screen from landscape to portrait, and still use the touch. When I currently rotate it, the touch doesn't correspond with it. How do I fix it?

3 Answers 3

In the end, I found out how to do it, although it's a little tricky. Still, if a non-mega-Geek like me can do it, I'm sure most of you can too! 🙂

Firstly, Go to Terminal, and type this to find the name of your touchscreen, and if you have one, your touchpad (say, if you have a laptop with a touchscreen):

The names should be pretty obvious for each.

Now, make two "shell scripts": these are little text documents that contain several commands, which are joined up in the document to be done together (effectively creating a little program). Make them using gedit, naming them "portrait.sh" and "landscape.sh" respectively. Save them in a new folder: /home/your username/Scripts/

#!/bin/sh #portrait (left) xrandr -o left xinput set-prop "Your Touchscreen's Name" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1 xinput set-prop "Your Touchpad's name, if applicable" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1 
#!/bin/sh #landscape (normal) xrandr -o normal xinput set-prop "Your Touchscreen's Name" --type=float "Coordinate Transformation Matrix" 0 0 0 0 0 0 0 0 0 xinput set-prop "Your Touchpad's name, if applicable" --type=float "Coordinate Transformation Matrix" 0 0 0 0 0 0 0 0 0 

If you don't have a touchpad, you can leave out that line of code for each shell script.

Afterwards, I also made launchers to automatically run each shell script when I tapped on them (this is possible in Xubuntu, Ubuntu MATE, and many other Ubuntu flavours). To do so, go to your panel, right-click, click on "add to panel" (or equivalent, for all these subsequent commands, too), create a custom application launcher. For portrait's launcher, put in this command:

sh /home/username/Scripts/portrait 

For landscape's launcher, put in this command:

sh /home/username/Scripts/landscape 

I also made a "super+" keyboard shortcut for each of them. Find your "keyboard shortcuts" settings program (under Settings in many flavours, or just search for it). Effectively, do the same thing as you did with the panel launchers: Add a new keyboard shortcut, Name it Portrait and give it the command, "sh /home/username/Scripts/portrait", and do the equivalent for Landscape. Then give each of them a keyboard shortcut (say Super+P and Super+L respectively. although be aware Super+P is sometimes the standard keyboard shortcut for your Display Settings).

I STRONGLY recommend you make a keyboard shortcut for LANDSCAPE - that way, if your touch stops working, you can at least get out of Portrait, and back to Landscape successfully (VERY USEFUL).

Источник

Оцените статью
Adblock
detector