mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-31 17:00:09 +01:00
Add support for --set-pressure-range to the debugging tools
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1009>
This commit is contained in:
parent
9267147ebd
commit
1725b7d606
6 changed files with 53 additions and 3 deletions
|
|
@ -940,9 +940,15 @@ handle_and_print_events(struct libinput *li)
|
|||
case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
|
||||
print_tablet_axis_event(ev);
|
||||
break;
|
||||
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
|
||||
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY: {
|
||||
struct libinput_event_tablet_tool *tev =
|
||||
libinput_event_get_tablet_tool_event(ev);
|
||||
struct libinput_tablet_tool *tool =
|
||||
libinput_event_tablet_tool_get_tool(tev);
|
||||
tools_tablet_tool_apply_config(tool, &options);
|
||||
print_proximity_event(ev);
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_TABLET_TOOL_TIP:
|
||||
print_tablet_tip_event(ev);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -125,6 +125,9 @@ Set button mapping for tapping
|
|||
.TP 8
|
||||
.B \-\-set\-rotation\-angle=<degrees>
|
||||
Set the rotation angle in degrees (0 to 360).
|
||||
.TP 8
|
||||
.B \-\-set\-pressure\-range=<min>:<max>
|
||||
Set the tablet tool pressure range to min:max. min and max must be in range [0.0, 1.0].
|
||||
.SH NOTES
|
||||
.PP
|
||||
Events shown by this tool may not correspond to the events seen by a
|
||||
|
|
|
|||
|
|
@ -1655,6 +1655,7 @@ static void
|
|||
handle_event_tablet(struct libinput_event *ev, struct window *w)
|
||||
{
|
||||
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
|
||||
struct libinput_tablet_tool *tool = libinput_event_tablet_tool_get_tool(t);
|
||||
double x, y;
|
||||
struct point point;
|
||||
int idx;
|
||||
|
|
@ -1667,6 +1668,7 @@ handle_event_tablet(struct libinput_event *ev, struct window *w)
|
|||
|
||||
switch (libinput_event_get_type(ev)) {
|
||||
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
|
||||
tools_tablet_tool_apply_config(tool, &w->options);
|
||||
if (libinput_event_tablet_tool_get_proximity_state(t) ==
|
||||
LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) {
|
||||
w->tool.x_in = 0;
|
||||
|
|
|
|||
|
|
@ -381,9 +381,15 @@ handle_libinput_events(struct context *ctx)
|
|||
case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
|
||||
handle_tablet_axis_event(ctx, ev);
|
||||
break;
|
||||
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
|
||||
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY: {
|
||||
struct libinput_event_tablet_tool *tev =
|
||||
libinput_event_get_tablet_tool_event(ev);
|
||||
struct libinput_tablet_tool *tool =
|
||||
libinput_event_tablet_tool_get_tool(tev);
|
||||
tools_tablet_tool_apply_config(tool, &options);
|
||||
handle_tablet_proximity_event(ctx, ev);
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_TABLET_TOOL_TIP:
|
||||
handle_tablet_tip_event(ctx, ev);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ tools_init_options(struct tools_options *options)
|
|||
options->custom_npoints = ARRAY_LENGTH(points);
|
||||
options->custom_type = LIBINPUT_ACCEL_TYPE_FALLBACK;
|
||||
options->custom_step = 1.0;
|
||||
options->pressure_range[0] = 0.0;
|
||||
options->pressure_range[1] = 1.0;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -335,6 +337,23 @@ tools_parse_option(int option,
|
|||
fprintf(stderr, "Invalid --set-rotation-angle value\n");
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case OPT_PRESSURE_RANGE: {
|
||||
if (!optarg)
|
||||
return 1;
|
||||
|
||||
size_t npoints = 0;
|
||||
double *range = double_array_from_string(optarg, ":", &npoints);
|
||||
if (npoints != 2 || range[0] < 0.0 || range[1] > 1.0 || range[0] >= range[1]) {
|
||||
free(range);
|
||||
fprintf(stderr, "Invalid pressure range, must be in format \"min:max\"\n");
|
||||
return 1;
|
||||
}
|
||||
options->pressure_range[0] = range[0];
|
||||
options->pressure_range[1] = range[1];
|
||||
free(range);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -549,6 +568,15 @@ tools_device_apply_config(struct libinput_device *device,
|
|||
libinput_device_config_rotation_set_angle(device, options->angle % 360);
|
||||
}
|
||||
|
||||
void
|
||||
tools_tablet_tool_apply_config(struct libinput_tablet_tool *tool,
|
||||
struct tools_options *options)
|
||||
{
|
||||
libinput_tablet_tool_config_pressure_range_set(tool,
|
||||
options->pressure_range[0],
|
||||
options->pressure_range[1]);
|
||||
}
|
||||
|
||||
static char*
|
||||
find_device(const char *udev_tag)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ enum configuration_options {
|
|||
OPT_CUSTOM_STEP,
|
||||
OPT_CUSTOM_TYPE,
|
||||
OPT_ROTATION_ANGLE,
|
||||
OPT_PRESSURE_RANGE,
|
||||
};
|
||||
|
||||
#define CONFIGURATION_OPTIONS \
|
||||
|
|
@ -97,7 +98,8 @@ enum configuration_options {
|
|||
{ "set-custom-points", required_argument, 0, OPT_CUSTOM_POINTS },\
|
||||
{ "set-custom-step", required_argument, 0, OPT_CUSTOM_STEP },\
|
||||
{ "set-custom-type", required_argument, 0, OPT_CUSTOM_TYPE },\
|
||||
{ "set-rotation-angle", required_argument, 0, OPT_ROTATION_ANGLE }
|
||||
{ "set-rotation-angle", required_argument, 0, OPT_ROTATION_ANGLE }, \
|
||||
{ "set-pressure-range", required_argument, 0, OPT_PRESSURE_RANGE }
|
||||
|
||||
enum tools_backend {
|
||||
BACKEND_NONE,
|
||||
|
|
@ -130,6 +132,7 @@ struct tools_options {
|
|||
size_t custom_npoints;
|
||||
double *custom_points;
|
||||
unsigned int angle;
|
||||
double pressure_range[2];
|
||||
};
|
||||
|
||||
void tools_init_options(struct tools_options *options);
|
||||
|
|
@ -142,6 +145,8 @@ struct libinput* tools_open_backend(enum tools_backend which,
|
|||
bool *grab);
|
||||
void tools_device_apply_config(struct libinput_device *device,
|
||||
struct tools_options *options);
|
||||
void tools_tablet_tool_apply_config(struct libinput_tablet_tool *tool,
|
||||
struct tools_options *options);
|
||||
int tools_exec_command(const char *prefix, int argc, char **argv);
|
||||
|
||||
bool find_touchpad_device(char *path, size_t path_len);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue