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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2019-08-06 12:57:51 +10:00
parent ad13116f4e
commit f97e361d5d
2 changed files with 6 additions and 5 deletions

View file

@ -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 */

View file

@ -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;
};