Commit f97e361d authored by Peter Hutterer's avatar Peter Hutterer

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's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent ad13116f
......@@ -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 */
......
......@@ -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;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment