Stylus tracking suddenly out of calibration
I am having issues with pen tracking on a microsoft surface running Ubuntu 22.04 LTS with the custom linux-surface kernel. What troubleshooting I have been able to do leads me to believe the issue is occurring somewhere in Wayland (switching to Xorg has "fixed" the issue).
Environment:
Hardware model: Surface Pro 3 - Intel® Core™ i7-4650U CPU @ 1.70GHz × 4
Kernel version:
Linux hippoglossus 6.1.12-surface #2 SMP PREEMPT_DYNAMIC Mon Feb 20 01:41:34 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Distribution: Ubuntu 22.04.2 LTS
To the best of my knowledge Wayland is the default on Ubuntu at the moment and had been working fine for about a month. A few days ago my surface suddenly couldn't track my surface pen accurately - it was drawing strokes about 7cm down and to the right of where the pen tip actually was.
I did my best to chase the issue down but ultimately could not determine the cause or how to force a re-calibration. I've since switch to Xorg as I am a student and use the surface for taking notes/doing assignments (I cannot afford the time required to chase the bug - at least with my limited knowledge as I am relatively new to desktop linux). If anyone could help me out it would be greatly appreciated. Xorg is working okay for me at the moment but has it's own idiosyncrasies that I don't necessarily have the time to iron out either.
Troubleshooting I have already done:
- Tried two sets of new batteries for the surface pen.
- Run
evtest
to determine that the surface is receiving pen events:
lloach@hippoglossus:~ $ sudo evtest | grep BTN_TOUCH
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: Lid Switch
/dev/input/event1: NTRG0001:01 1B96:1B05 Stylus
/dev/input/event2: NTRG0001:01 1B96:1B05
/dev/input/event3: Microsoft Surface Type Cover Keyboard
/dev/input/event4: Microsoft Surface Type Cover Mouse
/dev/input/event5: Microsoft Surface Type Cover Consumer Control
/dev/input/event6: Microsoft Surface Type Cover UNKNOWN
/dev/input/event7: Microsoft Surface Type Cover Touchpad
/dev/input/event8: Microsoft Surface Type Cover UNKNOWN
/dev/input/event9: Microsoft Surface Type Cover UNKNOWN
/dev/input/event10: Microsoft Surface Type Cover UNKNOWN
/dev/input/event11: Microsoft Surface Type Cover Tablet Mode Switch
/dev/input/event12: Microsoft Surface Type Cover Tablet Mode Switch
/dev/input/event13: Surface Pro 3/4 Buttons
/dev/input/event14: Microsoft Surface Type Cover Tablet Mode Switch
/dev/input/event15: Microsoft Surface Type Cover Tablet Mode Switch
/dev/input/event16: Microsoft Surface Type Cover Tablet Mode Switch
/dev/input/event17: Microsoft Surface Type Cover Tablet Mode Switch
/dev/input/event18: Microsoft Surface Type Cover Tablet Mode Switch
/dev/input/event19: Microsoft Surface Type Cover Tablet Mode Switch
/dev/input/event20: Microsoft Surface Type Cover Tablet Mode Switch
/dev/input/event21: Microsoft Surface Type Cover Tablet Mode Switch
/dev/input/event22: Microsoft LifeCam Front: Micros
/dev/input/event23: Microsoft LifeCam Rear: Microso
/dev/input/event24: Video Bus
/dev/input/event25: HDA Intel HDMI HDMI/DP,pcm=3
/dev/input/event26: HDA Intel HDMI HDMI/DP,pcm=7
/dev/input/event27: HDA Intel HDMI HDMI/DP,pcm=8
/dev/input/event28: HDA Intel PCH Mic
/dev/input/event29: HDA Intel PCH Headphone
Select the device event number [0-29]: 1
Event code 330 (BTN_TOUCH)
Event: time 1677183759.750043, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1677183762.196786, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 1677183763.608434, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1677183765.334548, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 1677183766.626168, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1677183767.061188, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
- run
libinput
(which did show processing errors) :
loach@hippoglossus:~ $ sudo libinput debug-gui
(libinput-debug-gui:5803): Gtk-CRITICAL **: 12:54:53.043: gtk_widget_set_events: assertion '!_gtk_widget_get_realized (widget)' failed
info: event24 Video Bus added
info: event13 Surface Pro 3/4 Buttons added
info: event0 Lid Switch added
info: event3 Microsoft Surface Type Cover Keyboard added
info: event4 Microsoft Surface Type Cover Mouse added
info: event5 Microsoft Surface Type Cover Consumer Control added
info: event7 Microsoft Surface Type Cover Touchpad added
info: event15 Microsoft Surface Type Cover Tablet Mode Switch added
info: event22 Microsoft LifeCam Front: Micros added
info: event23 Microsoft LifeCam Rear: Microso added
info: event1 NTRG0001:01 1B96:1B05 Stylus added
info: event2 NTRG0001:01 1B96:1B05 added
info: event30 Surface Pen Keyboard added
event1 - NTRG0001:01 1B96:1B05 Stylus: client bug: event processing lagging behind by 24ms, your system is too slow
event2 - NTRG0001:01 1B96:1B05: client bug: event processing lagging behind by 24ms, your system is too slow
- Using
libinput debug-tablet
appears to show the correct bounds of the touchscreen when I move the pen around but with the caveat thatlibinput debug-tablet
does not label its axis units. So I'm really only going on if I go up and to the left both x and y (ABS and otherwise) do reach 0. This is confusing since if I try to draw in something like xournal++ the stroke is definitely not in the correct spot.
Edit: I went back and examined the behviour more closely and realized I was wrong. While libinput debug-tablet
does indeed show the x and y touchscreen coordinates converging towards 0 as I move the pen up and to the left if I watched the cursor I observed that it converged to the where then pen was touching the screen as well. However, if I moved away from the upper left hand corner the cursor would **accelerate away ** from where the pen was touching the screen (ie. get further and further away from the correct position).
I would be very appreciative of any suggestions for how to debug in a more targeted manner.