Ubuntu 22.04 LTS: Touchscreen calibration not working

Hello all,
I’m having troubles getting a “Dialogue Tech PenMount USB” touchscreen to calibrate properly on Ubuntu 22.04 LTS and kernel 5.15.0. I’ve tried the standard methods (i.e. input_calibrator both with the device number and without) and it seems to work but produces output like this:

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "!!Name_Of_TouchScreen!!"
        Option  "MinX"  "534"
        Option  "MaxX"  "3621"
        Option  "MinY"  "451"
        Option  "MaxY"  "3563"
        Option  "SwapXY"        "0" # unless it was already set to 1
        Option  "InvertX"       "0"  # unless it was already set
        Option  "InvertY"       "0"  # unless it was already set
EndSection

Obviously, this doesn’t work, I’ve tried replacing the product name with “Dialogue Technology Corp. PenMount USB”, “PenMount Touch USB” and a bunch of other wordings, I’ve even tried leaving out the MatchProduct statement altogether, but no matter what I do, the touchscreen always misaligns, not allowing me to get to the topmost and bottom-most lines on screen.

I had previously run a 14.04 LTS (I know, ancient) on the same touchscreen, and there the calibration ran fine and reported different results in between roughly 100 and 1200.

Can anybody tell me what else to try or where to look for more clues? My xorg.conf is just the default (i.e. empty, except for the calibration data).

Best regard
Michael

Hello and welcome!

Maybe it’s not calibration of touchscreen that’s not working properly. To me it sounds like your screen resolution isn’t set correctly. Please check screen resolution and correct it if necessary. Afterwards try calibrating the touchscreen again.

The screen is 1280x1024 pixels screen which is shown correctly with the configuration at hand. An application is running in full-screen mode after the calibration, you just can’t press anything in the first (or last) circa 100 lines with the calibration the touchscreen uses, whatever that is.

The calibration data listed above clearly does nothing. I’ve already tried setting the data way lower or changing the X calibration (which is about right) so vastly different values and saw no change whatsoever.

BR,
michael

Maybe man:xinput_calibrator is of some help.
What’s the output of calibrator using option -v?

Hi,
Well, this produces (note: I’m currently vnc’ing into the device, so the actual calibration data might be incorrect, as it’s derived from virtual click):

DEBUG: XInputExtension version is 2.4
DEBUG: Skipping virtual master devices and devices without axis valuators.
DEBUG: Skipping device 'Virtual core XTEST pointer' id=4, does not report Absolute events.
DEBUG: Selected device: PenMount TouchScreen
DEBUG: Not usbtouchscreen calibrator: Not a usbtouchscreen device
DEBUG: Not evdev calibrator: Evdev: invalid "Evdev Axis Calibration" property format
Calibrating standard Xorg driver "PenMount TouchScreen"
        current calibration values: min_x=0, max_x=4096 and min_y=0, max_y=4096
        If these values are estimated wrong, either supply it manually with the --precalib option, or run the 'get_precalib.sh' script to automatically get it (through HAL).
DEBUG: Name 'PenMount TouchScreen' does not match any in '/sys/class/input/event*/device/name'
DEBUG: Adding click 0 (X=161, Y=129)
DEBUG: Adding click 1 (X=1118, Y=133)
DEBUG: Adding click 2 (X=159, Y=902)
DEBUG: Mis-click detected, click 3 (X=1137, Y=900) not aligned with click 1 (X=1118, Y=133) or click 2 (X=159, Y=902) (threshold=15)
DEBUG: Adding click 0 (X=166, Y=126)
DEBUG: Adding click 1 (X=1116, Y=132)
DEBUG: Adding click 2 (X=159, Y=894)
DEBUG: Adding click 3 (X=1117, Y=897)
        --> Making the calibration permanent <--
DEBUG: Name 'PenMount TouchScreen' does not match any in '/sys/class/input/event*/device/name'
  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    "!!Name_Of_TouchScreen!!"
        Option  "MinX"  "11"
        Option  "MaxX"  "4082"
        Option  "MinY"  "5"
        Option  "MaxY"  "4093"
        Option  "SwapXY"        "0" # unless it was already set to 1
        Option  "InvertX"       "0"  # unless it was already set
        Option  "InvertY"       "0"  # unless it was already set
EndSection

Change '!!Name_Of_TouchScreen!!' to your device's name in the config above.

During the first try, I mis-clicked in the lower right corner.

BR,
Michael

Did you try as advised under --> Making the calibration permanent <-- in the output using the device name PenMount TouchScreen?
If this doesn’t work you may try as advised in the output under Calibrating standard Xorg driver (...).

I’ll try that tomorrow and will get back to you.

Thanks,
Michael

I have taken over the task of getting the touchscreen to properly calibrate from Michael.

We use a monolithic xorg.conf, so putting the calibration data into /etc/X11/xorg.conf.d/99-calibration.conf would not work.

We have tried:

MatchProduct "PenMount TouchScreen"

as well as

MatchUSBID "14e1:6000"

without any change in behavior. The data xinput_calibrator collects just seems wrong; the first and the last 100 lines remain unreachable via touchscreen. Manually changing the MinY and MaxY values does not seem to change anything, either.

Help!

Our current configuration:

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "PenMount TouchScreen"
        #Option "MinX"  "519"
        #Option "MaxX"  "3623"
        #Option "MinY"  "467"
        #Option "MaxY"  "3577"
        Option  "MinX"  "519"
        Option  "MaxX"  "3623"
        Option  "MinY"  "100"
        Option  "MaxY"  "3900"
        Option  "SwapXY"        "0" # unless it was already set to 1
        Option  "InvertX"       "0"  # unless it was already set
        Option  "InvertY"       "0"  # unless it was already set
EndSection

Perhaps Option "TransformationMatrix" is worth trying (see arch - Talk:Calibrating Touchscreen but it may be outdated).

I do not know what to do with this parameter, From what I read, it is used to transform the Min/Max values - but they seem not to do anything. so no matter what I put into them, the mouse pointer alway is too low on the upper half and too high on the lower half of the screen, making buttons in these areas essentially unreachable.

For example, I tried out:

Option  "MinY"  "100"
Option  "MaxY"  "1300"
Option  "MinY"  "1000"
Option  "MaxY"  "2000"

and

Option  "MinY"  "467"
Option  "MaxY"  "3577"

all resulting in the same false pointer placement.

So, don’t see how putting anything (and what exactly) in “TransformationMatrix” could help.

Best regards
Karim

Hi all,
this is the output of xinput list-props “PenMount TouchScreen”:

Device 'PenMount TouchScreen':
        Device Enabled (180):   1
        Coordinate Transformation Matrix (182): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        Device Accel Profile (311):     0
        Device Accel Constant Deceleration (312):       1.000000
        Device Accel Adaptive Deceleration (313):       1.000000
        Device Accel Velocity Scaling (314):    10.000000
        Device Node (307):      "/dev/input/event4"
        Device BaudRate (315):  19200
        Device Model (316):     24576
        Calibration Enabled (319):      0
        libinput Tapping Enabled (321): 1
        Device Type (322):      1

The transformation matrix is used to configure how input device events are mapped to screen coordinates. And I think this is exactly what you need for your device because it technically works, but input coordinates do not match screen coordinates. See also Input Coordinate Transformation

In my previously posted link to archlinux wiki the calculation of these values is described. Maybe the page Calibrating Touchscreen (page linked to previously posted link) is also helpful.

Hello,
okay, so I should set

TransformationMatrix "c0 0 c1 0 c2 c3 0 0 1"

where the values are set to:

c0 = touch_area_width / total_width
c2 = touch_area_height / total_height
c1 = touch_area_x_offset / total_width
c3 = touch_area_y_offset / total_height

But I don’t know what to calculate here; the touchscreen and the monitor are a unit, to my knowledge, the touch area is as large as the screen. The screen is 1280x1024 pixel.

Best regards
Karim

Okay in Arch Linux, I found

DEBUG: Adding click 0 (X=181, Y=132)
DEBUG: Adding click 1 (X=862, Y=129)
DEBUG: Adding click 2 (X=186, Y=661)
DEBUG: Adding click 3 (X=868, Y=665)

and

a = (screen_width * 6 / 8) / (click_3_X - click_0_X)
c = ((screen_width / 8) - (a * click_0_X)) / screen_width
e = (screen_height * 6 / 8) / (click_3_Y - click_0_Y)
f = ((screen_height / 8) - (e * click_0_Y)) / screen_height

For my screen, I got:

DEBUG: Adding click 0 (X=166, Y=126)
DEBUG: Adding click 1 (X=1116, Y=132)
DEBUG: Adding click 2 (X=159, Y=894)
DEBUG: Adding click 3 (X=1117, Y=897)

I will calculate the matrix value accordingly and see if this helps

BR
Karim

Hello.
I now have the following xorg.conf:

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "PenMount TouchScreen"
        Option  "MinX"  "519"
        Option  "MaxX"  "3623"
        Option  "MinY"  "467"
        Option  "MaxY"  "3577"
        Option  "SwapXY"        "0" # unless it was already set to 1
        Option  "InvertX"       "0"  # unless it was already set
        Option  "InvertY"       "0"  # unless it was already set
        Option  "TransformationMatrix"  "1.3973799126637554585152838427948 0.0 -0.07259825327 0.0 1.4409005628517823639774859287054 -0.0607410881801 0.0 0.0 1.0"
EndSection

But the “TransformationMatrix” option does nothing - the touchscreen still put the mouse pointer too low in the upper and too high in the lower area. This whole calibration section seems to do nothing at all - no matter what I enter into Max/MaxX/Y or the transformation matrix it always looks the same when touching the screen.

BR
Karim

Did you try to apply these settings for actual session using the command
xinput set-prop "Device Name" --type=float "Coordinate Transformation Matrix" c0 0 c1 0 c2 c3 0 0 1 as mentioned in provided links?

Yes, I did. I put:

 DISPLAY=":0" xinput set-prop 'PenMount TouchScreen' 'Coordinate Transformation Matrix' 1.3973799126637554585152838427948 0.0 -0.07259825327 0.0 1.4409005628517823639774859287054 -0.0607410881801 0.0 0.0 1.0

to the console. I could test the result only this morning when I got directly to the screen, and if anything, the pointer is now moved further to the right and down - the upper areas of the touchscreen remain inaccessible, though.

Did miscsculate the transformation matrix?

BR
Karim

Please post technical details on your setup especially the exact type of touchscreen and how it is connected.

This is a "PenMount PM6000 Touchscreen connected via USB, a 1280x1024 screed behind it.

This is listed as:

ID 14e1:6000 Dialogue Technology Corp. PenMount USB

and operated by the hid-penmount driver.

The four presses regested by xinput_calibrator are:

DEBUG: Adding click 0 (X=166, Y=126)
DEBUG: Adding click 1 (X=1116, Y=132)
DEBUG: Adding click 2 (X=159, Y=894)
DEBUG: Adding click 3 (X=1117, Y=897)

which I calculated into the following matrix:

xinput set-prop 'PenMount TouchScreen' 'Coordinate Transformation Matrix' 1.3973799126637554585152838427948 0.0 -0.07259825327 0.0 1.4409005628517823639774859287054 -0.0607410881801 0.0 0.0 1.0

which I tried after putting it into the xorg.conf with no effect:

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "PenMount TouchScreen"
        Option  "MinX"  "519"
        Option  "MaxX"  "3623"
        Option  "MinY"  "467"
        Option  "MaxY"  "3577"
        Option  "SwapXY"        "0" # unless it was already set to 1
        Option  "InvertX"       "0"  # unless it was already set
        Option  "InvertY"       "0"  # unless it was already set
        Option  "TransformationMatrix"  "1.3973799126637554585152838427948 0.0 -0.07259825327 0.0 1.4409005628517823639774859287054 -0.0607410881801 0.0 0.0 1.0"
EndSection

Adding it with xinput set-prop had an effect, but the mouse cursor now always displays about 100 pixel right and below where I press the screen, whereas before applying the matrix, the y-position was such that the upper and lower 100 lines were unreachable while this x position was just a little off.

I can try to get further details upon request.

How can I get the presses on screen and the calibration and matrix to actually match up?

Other Touchscreens work fine, by the way, e.g.

222a:1515 ILITEK Corporation Multi-Touch V5000

BR
Karim

Are you sure your xorg.conf is read and applied correctly at start up? Maybe your MinX, MaxX, MinY and MaxY never get applied correctly … (You probably want to try your values without TransformationMatrix first.)
Maybe the values from post #5 are worth trying ( “MinX” “11”, “MaxX” “4082”, “MinY” “5”, “MaxY” “4093”).

I will have time to go through the data later today.

Meanwhile - if you not already did - you may take a look at PenMount-6000-Controller-Installation-Guide and driver download page.