backends: Add support for tablet tool pressure ranges
Introduced in libinput 1.26 this feature allows restricting the tablet tool pressure range to a subset of its physical range. The use-case is either to require some higher-than-usual minimum pressure before the pen reacts, or lower-than-usual pressure to reach the maximum logical pressure. libinput takes a [0.0, 1.0] normalized range which we expose as percent in the gsettings. The wacom driver doesn't have an exact equivalent but it has a Threshold setting (range [1, 2048]) that defines when a button is generated for tip down. See gsettings-desktop-schemas!84 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3794>
This commit is contained in:
parent
d65c89d8b9
commit
d9ead043c7
@ -49,7 +49,7 @@ wayland_server_req = '>= 1.23'
|
|||||||
wayland_protocols_req = '>= 1.36'
|
wayland_protocols_req = '>= 1.36'
|
||||||
|
|
||||||
# native backend version requirements
|
# native backend version requirements
|
||||||
libinput_req = '>= 1.19.0'
|
libinput_req = '>= 1.26.0'
|
||||||
gbm_req = '>= 21.3'
|
gbm_req = '>= 21.3'
|
||||||
libdrm_req = '>= 2.4.118'
|
libdrm_req = '>= 2.4.118'
|
||||||
|
|
||||||
|
@ -188,7 +188,8 @@ static void
|
|||||||
meta_input_settings_dummy_set_stylus_pressure (MetaInputSettings *settings,
|
meta_input_settings_dummy_set_stylus_pressure (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
ClutterInputDeviceTool *tool,
|
ClutterInputDeviceTool *tool,
|
||||||
const gint32 curve[4])
|
const gint32 curve[4],
|
||||||
|
const gdouble range[2])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,8 @@ struct _MetaInputSettingsClass
|
|||||||
void (* set_stylus_pressure) (MetaInputSettings *settings,
|
void (* set_stylus_pressure) (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
ClutterInputDeviceTool *tool,
|
ClutterInputDeviceTool *tool,
|
||||||
const gint32 curve[4]);
|
const gint32 curve[4],
|
||||||
|
const gdouble range[2]);
|
||||||
void (* set_stylus_button_map) (MetaInputSettings *settings,
|
void (* set_stylus_button_map) (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
ClutterInputDeviceTool *tool,
|
ClutterInputDeviceTool *tool,
|
||||||
|
@ -1562,6 +1562,8 @@ update_stylus_pressure (MetaInputSettings *input_settings,
|
|||||||
MetaInputSettingsClass *input_settings_class;
|
MetaInputSettingsClass *input_settings_class;
|
||||||
GSettings *tool_settings;
|
GSettings *tool_settings;
|
||||||
const gint32 *curve;
|
const gint32 *curve;
|
||||||
|
const guint32 *percent;
|
||||||
|
gdouble range[2];
|
||||||
GVariant *variant;
|
GVariant *variant;
|
||||||
gsize n_elems;
|
gsize n_elems;
|
||||||
|
|
||||||
@ -1584,8 +1586,24 @@ update_stylus_pressure (MetaInputSettings *input_settings,
|
|||||||
if (n_elems != 4)
|
if (n_elems != 4)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (clutter_input_device_tool_get_tool_type (tool) ==
|
||||||
|
CLUTTER_INPUT_DEVICE_TOOL_ERASER)
|
||||||
|
variant = g_settings_get_value (tool_settings, "eraser-pressure-range");
|
||||||
|
else
|
||||||
|
variant = g_settings_get_value (tool_settings, "pressure-range");
|
||||||
|
|
||||||
|
percent = g_variant_get_fixed_array (variant, &n_elems, sizeof (guint32));
|
||||||
|
if (n_elems != 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
range[0] = CLAMP (percent[0] / 100.0, 0.0, 1.0);
|
||||||
|
range[1] = CLAMP (percent[1] / 100.0, 0.0, 1.0);
|
||||||
|
|
||||||
|
if (range[0] >= range[1])
|
||||||
|
return;
|
||||||
|
|
||||||
input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings);
|
input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings);
|
||||||
input_settings_class->set_stylus_pressure (input_settings, device, tool, curve);
|
input_settings_class->set_stylus_pressure (input_settings, device, tool, curve, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -117,7 +117,8 @@ meta_input_device_tool_native_new (struct libinput_tablet_tool *tool,
|
|||||||
|
|
||||||
void
|
void
|
||||||
meta_input_device_tool_native_set_pressure_curve_in_impl (ClutterInputDeviceTool *tool,
|
meta_input_device_tool_native_set_pressure_curve_in_impl (ClutterInputDeviceTool *tool,
|
||||||
double curve[4])
|
double curve[4],
|
||||||
|
double range[2])
|
||||||
{
|
{
|
||||||
MetaInputDeviceToolNative *evdev_tool;
|
MetaInputDeviceToolNative *evdev_tool;
|
||||||
graphene_point_t p1, p2;
|
graphene_point_t p1, p2;
|
||||||
@ -141,6 +142,8 @@ meta_input_device_tool_native_set_pressure_curve_in_impl (ClutterInputDeviceTool
|
|||||||
evdev_tool->pressure_curve[1] = p2;
|
evdev_tool->pressure_curve[1] = p2;
|
||||||
init_pressurecurve (evdev_tool);
|
init_pressurecurve (evdev_tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
libinput_tablet_tool_config_pressure_range_set (evdev_tool->tool, range[0], range[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -53,7 +53,8 @@ GDesktopStylusButtonAction meta_input_device_tool_native_get_button_code_in_impl
|
|||||||
uint32_t button);
|
uint32_t button);
|
||||||
|
|
||||||
void meta_input_device_tool_native_set_pressure_curve_in_impl (ClutterInputDeviceTool *tool,
|
void meta_input_device_tool_native_set_pressure_curve_in_impl (ClutterInputDeviceTool *tool,
|
||||||
double curve[4]);
|
double curve[4],
|
||||||
|
double range[2]);
|
||||||
void meta_input_device_tool_native_set_button_code_in_impl (ClutterInputDeviceTool *tool,
|
void meta_input_device_tool_native_set_button_code_in_impl (ClutterInputDeviceTool *tool,
|
||||||
uint32_t button,
|
uint32_t button,
|
||||||
GDesktopStylusButtonAction evcode);
|
GDesktopStylusButtonAction evcode);
|
||||||
|
@ -696,16 +696,21 @@ static void
|
|||||||
meta_input_settings_native_set_stylus_pressure (MetaInputSettings *settings,
|
meta_input_settings_native_set_stylus_pressure (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
ClutterInputDeviceTool *tool,
|
ClutterInputDeviceTool *tool,
|
||||||
const gint curve[4])
|
const gint curve[4],
|
||||||
|
const gdouble range[2])
|
||||||
{
|
{
|
||||||
gdouble pressure_curve[4];
|
gdouble pressure_curve[4];
|
||||||
|
gdouble pressure_range[2];
|
||||||
|
|
||||||
pressure_curve[0] = (gdouble) curve[0] / 100;
|
pressure_curve[0] = (gdouble) curve[0] / 100;
|
||||||
pressure_curve[1] = (gdouble) curve[1] / 100;
|
pressure_curve[1] = (gdouble) curve[1] / 100;
|
||||||
pressure_curve[2] = (gdouble) curve[2] / 100;
|
pressure_curve[2] = (gdouble) curve[2] / 100;
|
||||||
pressure_curve[3] = (gdouble) curve[3] / 100;
|
pressure_curve[3] = (gdouble) curve[3] / 100;
|
||||||
|
|
||||||
meta_input_device_tool_native_set_pressure_curve_in_impl (tool, pressure_curve);
|
pressure_range[0] = (gdouble) range[0];
|
||||||
|
pressure_range[1] = (gdouble) range[1];
|
||||||
|
|
||||||
|
meta_input_device_tool_native_set_pressure_curve_in_impl (tool, pressure_curve, pressure_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -892,12 +892,19 @@ static void
|
|||||||
meta_input_settings_x11_set_stylus_pressure (MetaInputSettings *settings,
|
meta_input_settings_x11_set_stylus_pressure (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
ClutterInputDeviceTool *tool,
|
ClutterInputDeviceTool *tool,
|
||||||
const gint32 pressure[4])
|
const gint32 pressure[4],
|
||||||
|
const gdouble range[2])
|
||||||
{
|
{
|
||||||
guint32 values[4] = { pressure[0], pressure[1], pressure[2], pressure[3] };
|
guint32 values[4] = { pressure[0], pressure[1], pressure[2], pressure[3] };
|
||||||
|
guint32 threshold = (guint32) MAX (2048 * range[0], 1.0);
|
||||||
|
|
||||||
change_property (settings, device, "Wacom Pressurecurve", XA_INTEGER, 32,
|
change_property (settings, device, "Wacom Pressurecurve", XA_INTEGER, 32,
|
||||||
&values, G_N_ELEMENTS (values));
|
&values, G_N_ELEMENTS (values));
|
||||||
|
|
||||||
|
/* The wacom driver doesn't have a full equivalent to the pressure range.
|
||||||
|
* Threshold only applies to the tip down event but that's better than nothing */
|
||||||
|
change_property (settings, device, "Wacom Pressure Threshold", XA_INTEGER, 32,
|
||||||
|
&threshold, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user