From ff8aadac7ebff56097a91c2c9f243b6c165383be Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 13 Jun 2023 10:56:10 +1000 Subject: [PATCH] tablet: move setting the pressure offset into a helper function Signed-off-by: Peter Hutterer --- src/evdev-tablet.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index c8d7ebb5..3d1938e5 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -1313,6 +1313,21 @@ sanitize_tablet_axes(struct tablet_dispatch *tablet, sanitize_mouse_lens_rotation(tablet); } +static void +set_pressure_offset(struct libinput_tablet_tool *tool, int offset) +{ + tool->pressure.offset = offset; + tool->pressure.has_offset = true; + + /* Adjust the tresholds accordingly - we use the same gap (4% in + * device coordinates) between upper and lower as before which isn't + * technically correct (our range shrunk) but it's easy to calculate. + */ + int gap = tool->pressure.threshold.upper - tool->pressure.threshold.lower; + tool->pressure.threshold.lower = offset; + tool->pressure.threshold.upper = offset + gap; +} + static void detect_pressure_offset(struct tablet_dispatch *tablet, struct evdev_device *device, @@ -1372,17 +1387,9 @@ detect_pressure_offset(struct tablet_dispatch *tablet, tablet_tool_type_to_string(tool->type), tool->serial, HTTP_DOC_LINK); -set_offset: - tool->pressure.offset = offset; - tool->pressure.has_offset = true; - /* Adjust the tresholds accordingly - we use the same gap (4% in - * device coordinates) between upper and lower as before which isn't - * technically correct (our range shrunk) but it's easy to calculate. - */ - int gap = tool->pressure.threshold.upper - tool->pressure.threshold.lower; - tool->pressure.threshold.lower = offset; - tool->pressure.threshold.upper = offset + gap; +set_offset: + set_pressure_offset(tool, offset); } static void -- 2.34.1