lime
lime copied to clipboard
Ability to discern between touch and pen/stylus input
It might be useful to be able to tell whether a touch event was caused by a regular finger touch or by a pen/stylus input. An example use case would be to allow for programs to use only pens for drawing, while ignoring regular touch on a canvas (for palm rejection, for example, or using regular touch to pan the drawing canvas instead).
I originally wanted to implement this in HaxeFlixel (https://github.com/HaxeFlixel/flixel/pull/2588) assuming that support existed in Lime and was not being passed down or exposed, and assumed that I could determine the input type based on reported pressure
values. However, this seems to vary between browsers and even platforms:
- Chromium-based browsers (on Windows, at least) report that regular touch has a pressure of
1.0
, whereas Firefox reports0
- iOS Safari reports
0
for regular touch, and while it correctly reports pressure from an Apple Pencil stylus- It also seems to allow
0
as a validpressure
value from pen input, usually for extremely light taps or the end of a pen touch.
- It also seems to allow
Because of these cross-browser and -platform differences, it would be easier to determine the input device getting it straight from the root touch event as reported by Lime.