1

Introduction

This is a follow up from my previous question here.

When I connect my tablet to a projector, due to change of resolution the pen is not calibrated any more. I found this wiki post from ArchLinux and it does exactly what I need to do, except the numbers are a little off. Here is what I've done:

From xrandr I get:

Screen 0: minimum 8 x 8, current 1024 x 768, maximum 32767 x 32767
LVDS1 connected primary 1024x768+0+0 (normal left inverted right x axis y axis) 277mm x 156mm
   1366x768      60.02 +
   1280x720      60.00  
   1024x768      60.00* 
   1024x576      60.00  
   ...

The one with + is maximum resolution my monitor supports and the one with * is the current resolution. So, I conclude

total_width = 1024
touch_area_width = 1366
touch_area_x_offset = (1024 - 1366) /2 = -171

This is probably what I'm doing wrong, because at the end I don't get exactly what I need, but almost there.

Then I look at the output of xinput list

⎡ Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
⎜   ↳ Logitech M325                               id=9    [slave  pointer  (2)]
⎜   ↳ Wacom ISDv4 E6 Pen stylus                   id=10    [slave  pointer  (2)]
⎜   ↳ Wacom ISDv4 E6 Finger                       id=11    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                  id=13    [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                       id=14    [slave  pointer  (2)]
⎜   ↳ Wacom ISDv4 E6 Pen eraser                   id=16    [slave  pointer  (2)]
⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
    ↳ Power Button                                id=6    [slave  keyboard (3)]
    ↳ Video Bus                                   id=7    [slave  keyboard (3)]
    ↳ Sleep Button                                id=8    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard                id=12    [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                      id=15    [slave  keyboard (3)]

The lines 4,5, and 8 are the ones that I need, so the DEVICE NAMEs for me will be "Wacom ISDv4 E6 Pen stylus", "Wacom ISDv4 E6 Finger", and "Wacom ISDv4 E6 Pen eraser".

xinput list-props "device name" | grep Matrix should list the current Coordinate Transformation Matrix. The default is the identity matrix which is listed by rows:

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

The transformation matrix is The matrix is

[ c0 0  c1 ]
[ 0  c2 c3 ]
[ 0  0  1  ]

The tutorial says to calculate the matrix as follows: (the numbers on the right are the ones that I calculated for my case)

c0 = touch_area_width / total_width = 1366/1024 = 1.333984375
c2 = touch_area_height / total_height = 768/768 = 1
c1 = touch_area_x_offset / total_width = -171/768 = -0.22265625
c3 = touch_area_y_offset / total_height = 0/768 = 0

The reason c2=1 and c3=0 for me is that in my situation the height is fine, so I only need to scale and shift the width.

All I need to do now is to represent my matrix as an array of rows, that is:

c0 0 c1 0 c2 c3 0 0 1

and that for me becomes:

1.333984375 0 -0.22265625 0 1 0 0 0 1

Then the following command should do the translation for me:

xinput set-prop "DEVICE NAME" --type=float "Coordinate Transformation Matrix" 1.333984375 0 -0.22265625 0 1 0 0 0 1

That almost gets me where I want to be except it's still a little off. So, I did a little bit of trial and error to get the following numbers 1.345 0 -0.17 0 1 0 0 0 1

So, here is my question

How to find the exact values for the transformation matrix? I need to work with different resolutions and I can't repeat the trial and error process for all of them!

  • 1
    your C1 is wrong, it should be -171/1024 and that yields -0.16699218 which is close to -0.17 – Lee Jul 26 '18 at 1:49
  • Oh boy, that makes me feel super stupid now. Thanks very much for pointing out :) – Keivan Aug 8 '18 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.