0

I'm working on a HP Envy X360 Ryzen Laptop(13-ag0xxx ) Ubuntu 20.04. When I add an external (non-touch) screen to the laptop, the location of the HP pen on the laptop-screen is not correct anymore. As soon as I add the external screen on top of the laptop screen, the location of the pen is still good on the lowest point of my notebook screen, but the more I go upward on the touchscreen of my notebook, the worse the position of the cursor on the screen becomes. The cursor then even switches to the external screen, though I am still only touching the notebook screen.

This is the same problem as in post askubuntu.com/questions/1146029/, but the solution 'Toggle on/off Display for TV' did not help unfortunately...

Help on this is very appreciated! Switching from Windows to Ubuntu this is my last unsolved problem...

xinput --list-props (of Pen):
*'ELAN0732:00 04F3:262B Pen (0)':
    Device Enabled (147):   1
    Coordinate Transformation Matrix (149): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    Device Node (272):  "/dev/input/event17"
    Device Product ID (273):    1267, 9771
    libinput Tablet Tool Pressurecurve (579):   0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000, 1.000000*
Nmath
  • 12,333

2 Answers2

1

I managed to do a workaround. Since my touchscreen is working when using my fingers, I just copy the "coordination matrix" properties of the touchscreen to my stylus pen. After doing that the stylus pen cursor position is perfect.

$ xinput 
Virtual core pointer                          id=2    [master pointer  (3)]
   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
   ↳ Dell Dell Universal Receiver Mouse        id=10   [slave  pointer  (2)]          
   ↳ Dell Dell Universal Receiver Consumer Control     id=11   [slave  pointer  (2)]
   ↳ ELAN0732:00 04F3:262B                     id=15   [slave  pointer  (2)]
   ↳ SynPS/2 Synaptics TouchPad                id=18   [slave  pointer  (2)]
   ↳ ELAN0732:00 04F3:262B Pen (0)             id=22   [slave  pointer  (2)]

id=15 is my touchscreen and id=22 is my stylus pen

First check out their properties:

xinput --list-props 15 
    Device 'ELAN0732:00 04F3:262B':
    Device Enabled (147):   1
    Coordinate Transformation Matrix (149): 1.000000, 0.000000, 0.000000, 0.000000, 0.500000, 0.500000, 0.000000, 0.000000, 1.000000
    libinput Calibration Matrix (304):      1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    libinput Calibration Matrix Default (305):      1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    libinput Send Events Modes Available (269):     1, 0
    libinput Send Events Mode Enabled (270):        0, 0
    libinput Send Events Mode Enabled Default (271):        0, 0
    Device Node (272):      "/dev/input/event8"
    Device Product ID (273):        1267, 9771

xinput --list-props 22: 'ELAN0732:00 04F3:262B Pen (0)': Device Enabled (147): 1 Coordinate Transformation Matrix (149): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000 Device Node (272): "/dev/input/event17" Device Product ID (273): 1267, 9771 libinput Tablet Tool Pressurecurve (579): 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000, 1.000000*

As the touchscreen is working perfectly, I assumed its properties to be wright. The "Coordinate Transformation Matrix" differed between the two. (I also checked when unplugging the external screen - these scores were equal)

Then I just set the Coordinate Transformation Matrix Settings from the touchscreen to my stylus:

Solution for the external screen being on top of my Notebook-Screen:

xinput --set-prop 22 "Coordinate Transformation Matrix" 1.000000, 0.000000, 0.000000, 0.000000, 0.500000, 0.500000, 0.000000, 0.000000, 1.000000

General solution for all positions of the external screen: First saving the correct numbers to an object I called 'correct_matrix':

correct_matrix=$(xinput --list-props {insert id of your touchscreen} | grep "Coordinate Transformation Matrix" | sed -E 's/.*Coordinate Transformation Matrix.*:(.*)$/\1/')

If you want check what is in correct_matrix with $ echo $correct_matrix

Then set the stylus matrix settings to the numbers in 'correct_matrix':

xinput --set-prop {insert id of your stylus} "Coordinate Transformation Matrix" $correct_matrix

That works fine for me. I just made a small shell script out of these two commands, which I run whenever I connect an external monitor or change position settings of the external monitor.

Shell script:

#!/bin/bash
correct_matrix=$(xinput --list-props {insert id of your touchscreen} | grep "Coordinate Transformation Matrix" | sed -E 's/.*Coordinate Transformation Matrix.*:(.*)$/\1/')
xinput --set-prop {insert id of your stylus} "Coordinate Transformation Matrix" $correct_matrix

I put this into a 'stylus-correct.sh' shell file, which I can then run with

bash ./stylus-correct.sh

That solves the issue for me very quickly. Whenever I connect a new screen I just go to the directory of this shell file and run it with the given command.

  • I sometimes get this, my solution is to run my older screen orientation script again from when auto sensor orientation did not work. goes like this
     xrandr --output eDP --rotate inverted &&  xinput set-prop 'ELAN0732:00 04F3:2536 Pen (0)' --type=float "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1 && xinput map-to-output 'ELAN0732:00 04F3:2536 Pen (0)' eDP && xinput map-to-output 14 eDP 
    
    

    note that as IDs often change with boots my setptops used the name

    – pierrely Nov 01 '20 at 05:27
  • normal orientation is

    xrandr --output eDP --rotate normal && xinput set-prop 'ELAN0732:00 04F3:2536 Pen (0)' --type=float "Coordinate Transformation Matrix" 0 0 0 0 0 0 0 0 0 && xinput map-to-output 'ELAN0732:00 04F3:2536 Pen (0)' eDP && xinput map-to-output 14 eDP

    – pierrely Nov 01 '20 at 05:27
  • and I set those scripts with ubuntu keyboard shortcuts customs
    eg

    bash /home//MyScripts/RotateNormal.sh

    – pierrely Nov 01 '20 at 05:30
  • @ pierrely: thanks for the explanations. I was also struggling with changing IDs and will use your solution now with accessing them by name! And I will also give it a Ubuntu keyboard shortcut. Last thing is that I can only of of the two keys of the pen - xinput only lists the normal 'Pen' and one button 'Erasor', but no second button. If you found any solution to that please reach out to me :) – Konstantin Hebenstreit Nov 06 '20 at 09:28
  • no, I have not gone there with the pen buttons, my sony pen buttons are very awkward to locate anyway. – pierrely Nov 07 '20 at 05:02
  • Ok, I will just stick to using one of the two buttons then... – Konstantin Hebenstreit Nov 09 '20 at 07:34
0

For any one having this issue, I think that this thread is more suitable and easier (worked for me).

If you have multiple input devices you have to repeat the command there for each one (for instance, i had the touchscreen, a stylus pen, and the stylus pen eraser)