Diagnosing issues with Wacom input on surface pro 2

This is a problem I’ve been struggling with for a long time across multiple distros.
I have a surface pro 2 that I run linux on I’ve tried several distros and DEs out. Hands down Gnome is the absolute best user experience on the tablet, and out of distros Fedora 30 has been the one to get nearly everything working OOTB and stable. As such I’m running fedora 30 ws with gnome in Wayland.

The issue I’m struggling with has to do with using the wacom stylus input. The core of the problem is in krita, gimp, etc. I’ll start drawing and everything works perfectly. then later I will go to use the eraser side, it also works perfectly (it might be lacking pressure but not important yet), then I’ll draw again and it’s still fine. When I go to use the eraser side again the application will recognize I’m using that side and switch the brush, but it won’t recognize any input from that side, I can go back to using the pen side just fine but after using the erase side once it won’t erase again until I restart the application, at which point I can use it one more time and I’m right back to not working.

I’ve spent many days over months trying to find anyone experiencing this issue but I have yet to find anything related to this issue. Additionally I tried watching the input device with

sudo cat /dev/input/by-id/usb-MICROSOFT_SAM_0.1.0000-if01-event-mouse

and what will happen is fairly telling. I hover the pens side over the screen and get input garbage in the terminal, then I try the erase side and get the same, go back to pen side still fine, go back to erase one more time and the terminal crashes. I can’t find any relevant logs though and I’m not sure what to look for.

edit1: while playing around with stuff I discovered that the terminal crashes from the procession of events even if I’m not monitoring that event device. still can’t find related logs, additionally if it helps at all below is the device info from /proc/bus/input/devices

I: Bus=0003 Vendor=045e Product=0799 Version=0111
N: Name=“MICROSOFT SAM”
P: Phys=usb-0000:00:14.0-3/input1
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.1/0003:045E:0799.0002/input/input3
U: Uniq=0.1.0000
H: Handlers=mouse0 event3
B: PROP=2
B: EV=1b
B: KEY=c03 0 0 0 0 0
B: ABS=1000003
B: MSC=10

I wanted to come back and say I’ve made major progress. writing this all out helped me A LOT even if no one responded. One small thing I found before I get into the big stuff was a forehead slapper once I got everything else done. I found at least in X11 I could get past the eraser lockup by changing it’s brush while it was in range of the digitizer after doing that even one time the lockup problem just goes away completely. however, there is other small issues that I’ve fixed along the way here. In case anyone ever comes across this in the future, I’ve gone back to using X11 because of better configuration access via xorg. I also had to hop back to using Ubuntu once I found my solution because Fedora 30 was very unstable in X11 for some reason. The solution to my issue from here was to add entries in but existing solutions all had flaws

/usr/share/X11/xorg.conf.d/70-wacom.conf

# Surface Pro 2 Wacom
Section "InputClass"
    Identifier "Surface Wacom"
    MatchProduct "MICROSOFT SAM"
    MatchDevicePath "/dev/input/event3"
    Driver "wacom"
EndSection

Section "InputDevice"
    Driver "wacom"
    Identifier "stylus"
    Option "USB" "on"
    Option "Device" "/dev/input/event3"
    Option "Type" "stylus"
    Option "Threshold" "5"
    Option        "Mode"         "Relative"
EndSection

Section "InputDevice"
    Driver        "wacom"
    Identifier    "eraser"
    Option "USB" "on"
    Option        "Device"       "/dev/input/event3"  
    Option        "Type"         "eraser"
    Option        "Mode"         "Relative"
    Option        "Threshold"    "5"  
EndSection

Section "InputDevice"
    Driver        "wacom"
    Identifier    "cursor"
    Option "USB" "on"
    Option        "Device"       "/dev/input/event3"  
    Option        "Type"         "cursor"
    Option        "Mode"         "Relative"
EndSection

anyone who just wants the fix can stop here the rest is just explaining how I learned this because there isn’t even resources out there explaining how to figure this stuff out.
The problem I was really running into was everyone’s attempts I had found at these entries were done poorly and either didn’t capture pressure, or captured too many events. from

cat /proc/bus/input/devices

we can find these devices listed

I: Bus=0003 Vendor=045e Product=0799 Version=0111
N: Name="MICROSOFT SAM"
P: Phys=usb-0000:00:14.0-3/input1
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.1/0003:045E:0799.0002/input/input3
U: Uniq=0.1.0000
H: Handlers=mouse0 event3 
B: PROP=2
B: EV=1b
B: KEY=c03 0 0 0 0 0
B: ABS=1000003
B: MSC=10

I: Bus=0003 Vendor=045e Product=0799 Version=0111
N: Name="MICROSOFT SAM Consumer Control"
P: Phys=usb-0000:00:14.0-3/input1
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.1/0003:045E:0799.0002/input/input4
U: Uniq=0.1.0000
H: Handlers=kbd event4 
B: PROP=0
B: EV=13
B: KEY=e000000000000 0
B: MSC=10

I: Bus=0003 Vendor=045e Product=0799 Version=0111
N: Name="MICROSOFT SAM Keyboard"
P: Phys=usb-0000:00:14.0-3/input1
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.1/0003:045E:0799.0002/input/input5
U: Uniq=0.1.0000
H: Handlers=sysrq kbd event5 
B: PROP=0
B: EV=100013
B: KEY=300000000000000 2000800000000000 100000020000000
B: MSC=10

I: Bus=0003 Vendor=045e Product=0799 Version=0111
N: Name="MICROSOFT SAM Mouse"
P: Phys=usb-0000:00:14.0-3/input1
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.1/0003:045E:0799.0002/input/input6
U: Uniq=0.1.0000
H: Handlers=mouse1 event6 
B: PROP=0
B: EV=17
B: KEY=30000 0 0 0 0
B: REL=3
B: MSC=10

By testing each of these inputs using

sudo cat /dev/input/event{x}

I found that event3 is the wacom digitizer. unfortunately is also has the simplest name. All of these input devices have a product name that starts with MICROSOFT SAM so filtering by that pulls too many objects. then when you combine this with all of the example entries from other people using event* to filter out you can see that 3 of the four inputs listed will still get pulled. which is how another frequent issue with the volume and home buttons on the tablet happen. unfortunately this means there isn’t a clean way to point at the one correct event device without just straight up pointing at exactly the correct event device by it’s number afaik.

I would still like to try tackling this in Wayland as well but I have no idea where to even start there.