From f97e361d5d61f6f5e69a82f2021a50a8e2b5bcfe Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 6 Aug 2019 12:57:51 +1000 Subject: [PATCH] tablet: make the pressure-offset inclusive of the axis minimum The offset handling was inconsistent, stored as relative to the axis minimum but used as absolute in some places. Fix this by always using the absolute value including the minimum (i.e. no pressure offset means offset == minimum). Signed-off-by: Peter Hutterer --- src/evdev-tablet.c | 8 ++++---- src/libinput-private.h | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 5c6a3825..dbd087a7 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -356,8 +356,8 @@ normalize_pressure(const struct input_absinfo *absinfo, { double range = absinfo->maximum - absinfo->minimum; int offset = tool->has_pressure_offset ? - tool->pressure_offset : 0; - double value = (absinfo->value - offset - absinfo->minimum) / range; + tool->pressure_offset : absinfo->minimum; + double value = (absinfo->value - offset) / range; return value; } @@ -1269,7 +1269,7 @@ detect_pressure_offset(struct tablet_dispatch *tablet, if (!pressure || !distance) return; - offset = pressure->value - pressure->minimum; + offset = pressure->value; /* If we have an event that falls below the current offset, adjust * the offset downwards. A fast contact can start with a @@ -1282,7 +1282,7 @@ detect_pressure_offset(struct tablet_dispatch *tablet, return; } - if (offset == 0) + if (offset <= pressure->minimum) return; /* we only set a pressure offset on proximity in */ diff --git a/src/libinput-private.h b/src/libinput-private.h index 56e37a4a..1950e663 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -386,7 +386,8 @@ struct libinput_tablet_tool { /* The pressure threshold assumes a pressure_offset of 0 */ struct threshold pressure_threshold; - int pressure_offset; /* in device coordinates */ + /* pressure_offset includes axis->minimum */ + int pressure_offset; bool has_pressure_offset; };