I'm writing a cross-platform JavaScript-based drawing tool and run into severe problems on Linux.
First, Google Chrome's pointer events do not distinguish between the regular tip and the eraser end.
Second, in Firefox pointer events always are mouse events, never pen events.
In Chrome, the Eraser is reported as Contact. In Firefox, the pen pointer type is reported as mouse pointer type. I am aware of there having been some incantations in Firefox's configuration such as dom.w3c_pointer_events.enabled true
and dom.w3c_pointer_events.dispatch_by_pointer_messages true
, but they don't seem to help (anymore?).
In Xournal++, the eraser end of the pen does erase. With PySide6, the eraser end of the stylus is recognized as such (pointerType).
This is a minimal demonstration:
function print(e) {
const theButtons = {
"-1": "-",
0: "Contact",
1: "Middle",
2: "Barrel",
5: "Eraser"
};
log.innerText += ` ${e.pointerType}:${theButtons[e.button]}`;
}
area.addEventListener('contextmenu', e => e.preventDefault());
['pointerdown', 'pointerup', 'pointermove', 'pointerover'].forEach(e => area.addEventListener(e, print));
<div id="area" style="height:100px;background-color:aqua;"><span>Use stylus here</span></div>
<p id="log"></p>
Versions and equipment: Chrome 122.0.6261.94, Firefox 122.0.1, Wacom Cintiq 27QHDT, openSUSE Tumbleweed 2024-02-26, KDE PLasma 5.115.0-1.1, /sys/module/wacom*/version says v2.00
Welcome to the world of stuff that isn't fully implemented yet! Stuff that requires special hardware and thus only a few developers are able to test. You faced multiple bugs, let me try to make some sense out of the current status:
pointerdown
events.Chrome/Chromium/Blink support is the best so far, but not perfect. The behavior you found is known bug: Chromium can't differentiate between pen tip and eraser input on Linux
Otherwise, most stuff seems to be working just fine.
Firefox support is incomplete, but gradually improving.
MOZ_USE_XINPUT2=1
as an environment variable, to tell Firefox to use a newer input library (or code path). This new one works with pen input (and touch, I guess), and it seems to be better overall. I've heard some distros even enable it by default. Firefox itself isn't enabling it by default yet due to some regressions on very specific cases. (Read the bugs linked above.)tiltX
and tiltY
to 1 (or to some other value), instead of the expected zero.altitudeAngle
and azimuthAngle
. It should be possible to work around it by just calculating those based on tiltX
and tiltY
.button=5
and buttons=32
on Windows, but that is not working on Linux or Mac.Good luck! I wish this answer to be obsoleted "soon enough", but I understand it will take some time until we get there.