diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index bcb1429d..27a1a96f 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -1202,12 +1202,14 @@ tablet_get_quirked_pressure_thresholds(struct tablet_dispatch *tablet, static void apply_pressure_range_configuration(struct tablet_dispatch *tablet, - struct libinput_tablet_tool *tool) + struct libinput_tablet_tool *tool, + bool force_update) { struct evdev_device *device = tablet->device; if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_PRESSURE) || - (tool->pressure.range.min == tool->pressure.wanted_range.min && + (!force_update && + tool->pressure.range.min == tool->pressure.wanted_range.min && tool->pressure.range.max == tool->pressure.wanted_range.max)) return; @@ -1258,13 +1260,13 @@ tool_init_pressure_thresholds(struct tablet_dispatch *tablet, threshold->tablet_id = tablet->tablet_id; threshold->offset = 0; threshold->has_offset = false; + threshold->threshold.upper = 1; + threshold->threshold.lower = 0; pressure = libevdev_get_abs_info(device->evdev, ABS_PRESSURE); - if (!pressure) { - threshold->threshold.upper = 1; - threshold->threshold.lower = 0; + if (!pressure) return; - } + threshold->abs_pressure = *pressure; distance = libevdev_get_abs_info(device->evdev, ABS_DISTANCE); @@ -1276,7 +1278,7 @@ tool_init_pressure_thresholds(struct tablet_dispatch *tablet, threshold->heuristic_state = PRESSURE_HEURISTIC_STATE_PROXIN1; } - apply_pressure_range_configuration(tablet, tool); + apply_pressure_range_configuration(tablet, tool, true); } static int @@ -2211,7 +2213,7 @@ reprocess: tablet_set_status(tablet, TABLET_BUTTONS_RELEASED); if (tablet_has_status(tablet, TABLET_TOOL_IN_CONTACT)) tablet_set_status(tablet, TABLET_TOOL_LEAVING_CONTACT); - apply_pressure_range_configuration(tablet, tool); + apply_pressure_range_configuration(tablet, tool, false); } else if (!tablet_has_status(tablet, TABLET_TOOL_OUTSIDE_AREA)) { if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY)) { /* If we get into proximity outside the tablet area, we ignore diff --git a/test/test-tablet.c b/test/test-tablet.c index b4d90c6e..6d4662b2 100644 --- a/test/test-tablet.c +++ b/test/test-tablet.c @@ -5131,7 +5131,7 @@ START_TEST(tablet_pressure_across_multiple_tablets) double pressure = libinput_event_tablet_tool_get_pressure(tev); /* We start at device range 10% but we always have a small threshold */ - litest_assert_double_gt(pressure, 0.09); + litest_assert_double_gt_epsilon(pressure, 0.09, 0); litest_assert_double_le(pressure, 0.7); libinput_event_destroy(ev);