mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 03:38:01 +02:00
tablet: move setting the pressure offset into a helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
a88d107c0d
commit
71f5dc6e23
1 changed files with 17 additions and 10 deletions
|
|
@ -1313,6 +1313,21 @@ sanitize_tablet_axes(struct tablet_dispatch *tablet,
|
||||||
sanitize_mouse_lens_rotation(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
|
static void
|
||||||
detect_pressure_offset(struct tablet_dispatch *tablet,
|
detect_pressure_offset(struct tablet_dispatch *tablet,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
|
|
@ -1372,17 +1387,9 @@ detect_pressure_offset(struct tablet_dispatch *tablet,
|
||||||
tablet_tool_type_to_string(tool->type),
|
tablet_tool_type_to_string(tool->type),
|
||||||
tool->serial,
|
tool->serial,
|
||||||
HTTP_DOC_LINK);
|
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
|
set_offset:
|
||||||
* device coordinates) between upper and lower as before which isn't
|
set_pressure_offset(tool, offset);
|
||||||
* 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
|
static void
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue