diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2019-08-06 13:15:48 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2019-08-08 13:58:54 +1000 |
commit | 72121d6f6ce8f7e52b91906536d66b75312585ec (patch) | |
tree | ded7928b9453541c2cabf6924acd38f27a1cb882 | |
parent | f97e361d5d61f6f5e69a82f2021a50a8e2b5bcfe (diff) | |
download | libinput-72121d6f6ce8f7e52b91906536d66b75312585ec.tar.gz |
tablet: reduce the pressure range by the offset
Previously, the pressure range was calculated from the axis total range. A
device with a pressure offset making the bottom 10% inaccessible would lose
10% of that range as non-accessible. Due to the implementation, this affected
the upper range of the device, so the top N percent became unaccessible. Which
may be why no-one's noticed this yet.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/evdev-tablet.c | 2 | ||||
-rw-r--r-- | test/test-tablet.c | 26 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index dbd087a7..18c8fbee 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -354,9 +354,9 @@ static inline double normalize_pressure(const struct input_absinfo *absinfo, struct libinput_tablet_tool *tool) { - double range = absinfo->maximum - absinfo->minimum; int offset = tool->has_pressure_offset ? tool->pressure_offset : absinfo->minimum; + double range = absinfo->maximum - offset; double value = (absinfo->value - offset) / range; return value; diff --git a/test/test-tablet.c b/test/test-tablet.c index 21983833..51eaae49 100644 --- a/test/test-tablet.c +++ b/test/test-tablet.c @@ -3567,6 +3567,7 @@ START_TEST(tablet_pressure_offset) }; double pressure; + /* This activates the pressure thresholds */ litest_tablet_proximity_in(dev, 5, 100, axes); litest_drain_events(li); @@ -3594,9 +3595,8 @@ START_TEST(tablet_pressure_offset) pressure = libinput_event_tablet_tool_get_pressure(tev); /* we can't actually get a real 0.0 because that would trigger a tip - * up. but it's close enough to zero that ck_assert_double_eq won't - * notice */ - ck_assert_double_eq(pressure, 0.0); + up. but it's close enough to zero. */ + ck_assert_double_lt(pressure, 0.01); libinput_event_destroy(event); litest_drain_events(li); @@ -3613,6 +3613,22 @@ START_TEST(tablet_pressure_offset) ck_assert_double_lt(pressure, 0.015); libinput_event_destroy(event); + + + /* Make sure we can reach the upper range too */ + litest_axis_set_value(axes, ABS_PRESSURE, 100); + litest_tablet_motion(dev, 70, 70, axes); + + libinput_dispatch(li); + event = libinput_get_event(li); + tev = litest_is_tablet_event(event, + LIBINPUT_EVENT_TABLET_TOOL_AXIS); + + pressure = libinput_event_tablet_tool_get_pressure(tev); + + ck_assert_double_ge(pressure, 1.0); + libinput_event_destroy(event); + } END_TEST @@ -3713,8 +3729,8 @@ START_TEST(tablet_pressure_offset_increase) tev = litest_is_tablet_event(event, LIBINPUT_EVENT_TABLET_TOOL_AXIS); pressure = libinput_event_tablet_tool_get_pressure(tev); - /* Pressure should be around 10% */ - ck_assert_double_eq_tol(pressure, 0.10, 0.01); + /* offset 20, value 30 leaves us with 12% of the remaining 90 range */ + ck_assert_double_eq_tol(pressure, 0.12, 0.01); libinput_event_destroy(event); litest_drain_events(li); |