The Wacom Art Pen 2 came out in May 2026. For a long time after the original Art Pen was discontinued, the Apple Pencil Pro had pretty much been the only stylus with rotation support. I’d started to think Wacom had given up on pen rotation, but it made a comeback with the Art Pen 2!
I eagerly picked one up and took it for a spin in Chrome, but sadly, PointerEvent.twist was only returning values from 0 to 179 degrees, so I figured I’d just patch Chromium myself.
The fix
The following code was in ui/views/win/pen_event_processor.cc.
int rotation_angle = static_cast<int>(pointer_pen_info.rotation) % 180;
if (rotation_angle < 0) {
rotation_angle += 180;
}
pointer_pen_info is a Windows POINTER_PEN_INFO structure.
PointerEvent.twist is derived from its rotation value, but for some reason it was being taken modulo 180, so I fixed the code to use rotation directly.
int rotation_angle = static_cast<int>(pointer_pen_info.rotation) % 180;
int rotation_angle = static_cast<int>(pointer_pen_info.rotation);
if (rotation_angle < 0) {
rotation_angle += 180;
}
How the bug was introduced
Chromium has a PointerDetails struct and an internal ui::TouchEvent class, which is separate from the TouchEvent web API.
PointerDetails holds information about pen and touch input, such as pressure and pen tilt. PointerDetails stores twist, while ui::TouchEvent also stored its own rotation value. The rotation value ranged from 0 to 179 degrees. The code took the value modulo 180 before passing it to ui::TouchEvent as rotation.
This meant that both twist and rotation were stored, even though there was no need to keep both. So the code was refactored to derive rotation from twist. When the separate rotation property was removed, the already-normalized rotation value ended up being stored as twist in PointerDetails.
This might seem harmless if it only affected touch input, but Chromium internally uses ui::TouchEvent while a pen is in contact with the surface. So the twist value for pen input was limited too. Apparently, no one noticed for nine years.
Some thoughts
So I contributed to Chromium for the first time. It was easier than I thought, partly because it wasn’t a major bug. I found some other pointer bugs, so I want to fix them when I get a chance.
I found this bug back in May, when I was using the Art Pen 2. I figured that since the Art Pen 2 had just come out, someone would fix it, so I didn’t do anything about it at the time. But several months later, not only had no one fixed it, no one had even filed an issue. So I dug into the history and found that it had actually been broken for nine whole years.
Back then, the original Art Pen was still available, yet the bug went reported for nine years. Apparently, I’m the only person in the entire world who seriously uses PointerEvent.twist. RIP :)