Stylus events with zero pressure are detected as finger
Opened this issue · 0 comments
First of all, thanks a lot for this great project!
I'm using linux and my own https://github.com/ardera/flutter-pi embedder to transform my old Surface Book into a full-time note taking device. I got it mostly working, I had to remove some unsupported stuff, also added a battery indicator.
One thing that took a bit longer to fix is that the logic in the app relies on stylus events having a non-zero pressure value, rather than a device kind to detect wether they come from a stylus or not:
saber/lib/pages/editor/editor.dart
Lines 726 to 728 in ca99e4f
saber/lib/pages/editor/editor.dart
Lines 542 to 549 in ca99e4f
However, AFAICT there's currently no way for any platform, except web, Android and iOS, to specify a pressure value for an input event. The embedder API simply does not have a way to specify pressure for input events right now. So all stylus events coming from desktop embedders and linux-embedded embedders will have a pressure value of zero.
I just fixed that by replacing the code here:
saber/lib/components/canvas/canvas_gesture_detector.dart
Lines 396 to 399 in ca99e4f
with
// ...
if (event.kind == PointerDeviceKind.stylus) {
pressure = switch (event.pressure) {
0.0 => 1.0,
double pressure => pressure,
};
stylusButtonPressed = event.buttons == kPrimaryStylusButton;
} else if (event.kind == PointerDeviceKind.invertedStylus) {
// ...
Make of that what you will, it's obviously a very custom setup so it makes sense it doesn't work OOB. Still wanted to report it :)