From c093ac47db77724da008bce2b082cd41dd94442c Mon Sep 17 00:00:00 2001 From: Jens Peters Date: Sun, 13 Jul 2025 21:38:00 +0200 Subject: [PATCH 1/2] input: support tablet tool pressure range configuration Needs a wlroots addition to expose libinputs tablet tool handle... --- include/config/rcxml.h | 2 ++ src/config/rcxml.c | 8 ++++++++ src/input/tablet.c | 23 +++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/include/config/rcxml.h b/include/config/rcxml.h index 6036be9c..39623f10 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -139,6 +139,8 @@ struct rcxml { struct tablet_tool_config { enum lab_motion motion; double relative_motion_sensitivity; + double min_pressure; + double max_pressure; } tablet_tool; /* libinput */ diff --git a/src/config/rcxml.c b/src/config/rcxml.c index c1b73c35..4d45917a 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -1353,6 +1353,12 @@ entry(xmlNode *node, char *nodename, char *content) } else if (!strcasecmp(nodename, "relativeMotionSensitivity.tabletTool")) { rc.tablet_tool.relative_motion_sensitivity = tablet_get_dbl_if_positive(content, "relativeMotionSensitivity"); + } else if (!strcasecmp(nodename, "minPressure.tabletTool")) { + rc.tablet_tool.min_pressure = + tablet_get_dbl_if_positive(content, "minPressure"); + } else if (!strcasecmp(nodename, "maxPressure.tabletTool")) { + rc.tablet_tool.max_pressure = + tablet_get_dbl_if_positive(content, "maxPressure"); } else if (!strcasecmp(nodename, "ignoreButtonReleasePeriod.menu")) { rc.menu_ignore_button_release_period = atoi(content); } else if (!strcasecmp(nodename, "showIcons.menu")) { @@ -1473,6 +1479,8 @@ rcxml_init(void) tablet_load_default_button_mappings(); rc.tablet_tool.motion = LAB_MOTION_ABSOLUTE; rc.tablet_tool.relative_motion_sensitivity = 1.0; + rc.tablet_tool.min_pressure = 0.0; + rc.tablet_tool.max_pressure = 1.0; rc.repeat_rate = 25; rc.repeat_delay = 600; diff --git a/src/input/tablet.c b/src/input/tablet.c index 319c06b3..a2228a66 100644 --- a/src/input/tablet.c +++ b/src/input/tablet.c @@ -2,11 +2,13 @@ #include "input/tablet.h" #include #include +#include "wlr/backend/libinput.h" #include #include #include #include #include +#include #include "common/macros.h" #include "common/mem.h" #include "common/scene-helpers.h" @@ -336,6 +338,27 @@ handle_tablet_tool_proximity(struct wl_listener *listener, void *data) tool = tablet_tool_create(tablet->seat, ev->tool); } + struct libinput_tablet_tool *libinput_tool = + wlr_libinput_get_tablet_tool_handle(tool->tool_v2->wlr_tool); + + /* + * Configure tool pressure range using libinput. Note that a runtime change + * needs two proximity-in events. First one is for applying the pressure range + * here and second one until it is effectively applied, probably because of + * how lininput applies pressure range changes internally. + */ + if (libinput_tablet_tool_config_pressure_range_is_available(libinput_tool) > 0 + && rc.tablet_tool.min_pressure >= 0.0 + && rc.tablet_tool.max_pressure <= 1.0) { + double min = libinput_tablet_tool_config_pressure_range_get_minimum(libinput_tool); + double max = libinput_tablet_tool_config_pressure_range_get_maximum(libinput_tool); + if (min != rc.tablet_tool.min_pressure || max != rc.tablet_tool.max_pressure) { + wlr_log(WLR_INFO, "tablet tool pressure range configured"); + libinput_tablet_tool_config_pressure_range_set(libinput_tool, + rc.tablet_tool.min_pressure, rc.tablet_tool.max_pressure); + } + } + /* * Enforce mouse emulation when the current tool is a tablet mouse. * Client support for tablet mouses in tablet mode is often incomplete From 650a2e196f53847b43a2a61b557ff1336de42721 Mon Sep 17 00:00:00 2001 From: Jens Peters Date: Mon, 14 Jul 2025 21:50:32 +0200 Subject: [PATCH 2/2] docs: document tablet tool pressure range --- docs/labwc-config.5.scd | 13 ++++++++++++- docs/rc.xml.all | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index a1cedb20..eb31e859 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -1090,7 +1090,8 @@ Note: To rotate touch events with output rotation, use the libinput ## TABLET TOOL ``` - + ``` ** [absolute|relative] @@ -1105,6 +1106,16 @@ Note: To rotate touch events with output rotation, use the libinput speed, using a value greater than 1.0 increases the speed of the cursor. The default is "1.0". +** +** + The pressure range of a tablet tool can be controlled by adjusting + *minPressure* and *maxPressure*. Setting the minimum pressure to + a value greater than zero requires more pressure for the tip + threshold, setting the maximum pressure to a value less than 1.0 + requires less pressure for the user before the maximum is reached. + The default is 0 for the minimum pressure and 1.0 for the maximum + pressure. + ## LIBINPUT ``` diff --git a/docs/rc.xml.all b/docs/rc.xml.all index bc9566fe..73249d11 100644 --- a/docs/rc.xml.all +++ b/docs/rc.xml.all @@ -573,8 +573,11 @@ *relativeMotionSensitivity* controls the speed of the cursor. Using a value lower than 1.0 decreases the speed, using a value greater than 1.0 increases the speed of the cursor. + The pressure range of a tablet tool can be controlled by adjusting + *minPressure* and *maxPressure*. --> - +