Some pens keep sending small amounts of pressure even when the tip is up. This
isn't always a sign of the pens worn out, it also happens on the new Pro Pen
3D models.

The X driver uses a default threshould of ~1.3% to paper over this, let's do
the same with a 1% threshold. This threshold only applies to pens that don't
already have a pressure offset anyway.

https://bugs.freedesktop.org/show_bug.cgi?id=103086

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 src/evdev-tablet.c | 5 +++--
 test/test-tablet.c | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 4344da54..f69933dd 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -1057,11 +1057,11 @@ tablet_get_tool(struct tablet_dispatch *tablet,
                if (pressure) {
                        tool->pressure_offset = pressure->minimum;
 
-                       /* 5% of the pressure range */
+                       /* 5 and 1% of the pressure range */
                        tool->pressure_threshold.upper =
                                axis_range_percentage(pressure, 5);
                        tool->pressure_threshold.lower =
-                               pressure->minimum;
+                               axis_range_percentage(pressure, 1);
                }
 
                tool_set_bits(tablet, tool);
@@ -1246,6 +1246,7 @@ detect_pressure_offset(struct tablet_dispatch *tablet,
                 LIBINPUT_VERSION);
        tool->pressure_offset = offset;
        tool->has_pressure_offset = true;
+       tool->pressure_threshold.lower = pressure->minimum;
 }
 
 static void
diff --git a/test/test-tablet.c b/test/test-tablet.c
index bc089389..421e82c3 100644
--- a/test/test-tablet.c
+++ b/test/test-tablet.c
@@ -3458,7 +3458,7 @@ START_TEST(tablet_pressure_range)
        litest_drain_events(li);
        libinput_dispatch(li);
 
-       for (pressure = 1; pressure <= 100; pressure += 10) {
+       for (pressure = 10; pressure <= 100; pressure += 10) {
                litest_axis_set_value(axes, ABS_PRESSURE, pressure);
                litest_tablet_motion(dev, 70, 70, axes);
                libinput_dispatch(li);
-- 
2.13.6

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to