linuxwacom / xf86-input-wacom

X.Org driver for Wacom devices
356 stars 45 forks source link

Wacom Intuos4: eraser button mislabeled as pen tip in JS PointerEvent #321

Closed FelixBrakel closed 9 months ago

FelixBrakel commented 10 months ago

When trying to diagnose an issue with using the eraser on the back of the stylus in an electron application I noticed that it is not possible to distinguish between the eraser and the pen tip using the PointerEvent API.

According to the documentation (https://w3c.github.io/pointerevents/#the-buttons-property) a PointerEvent object with the buttons property set to 32 means the eraser is in contact with the tablet while a value of 1 means the pen tip is in contact.

Currently this value is set to 1 no matter what.

The following code shows this in action: https://codesandbox.io/s/pointer-events-test-forked-hytm8j

Not sure where this is going wrong but I figured I'd start at the bottom of the stack.

whot commented 9 months ago

Probably somewhere in chrome/chromium. the wacom driver forwards the eraser tip as button 1 of the eraser X11 device (see xinput list). That then goes to chromium via XI2 (see xinput test-xi2) and from there into JS-land.

Do make sure you're actually using the xf86-input-wacom driver (xinput list-props <device name>, the props will have a "Wacom" prefix) because if you're using the xf86-input-libinput driver then it's really on "our" side of the stack (see this mr). IF that's the case then installing the wacom driver is enough, it should take over.