summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2023-04-18 17:05:41 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2023-04-27 13:15:14 +1000
commitbee70901ecc0e37b48ca72515031f2aa8d363018 (patch)
tree2d27c38a594edc19ec284fc623669106ff5aa9aa
parenta328ada6efc282a893ce4a283552a832197f6c94 (diff)
downloadlibinput-bee70901ecc0e37b48ca72515031f2aa8d363018.tar.gz
tools: add rotation support to debug-events and debug-gui
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--tools/libinput-debug-events.man3
-rw-r--r--tools/shared.c11
-rw-r--r--tools/shared.h5
-rwxr-xr-xtools/test_tool_option_parsing.py1
4 files changed, 19 insertions, 1 deletions
diff --git a/tools/libinput-debug-events.man b/tools/libinput-debug-events.man
index 849765d1..2eeefd4b 100644
--- a/tools/libinput-debug-events.man
+++ b/tools/libinput-debug-events.man
@@ -119,6 +119,9 @@ This only applies to the custom profile.
.TP 8
.B \-\-set\-tap\-map=[lrm|lmr]
Set button mapping for tapping
+.TP 8
+.B \-\-set\-rotation\-angle=<degrees>
+Set the rotation angle in degrees (0 to 360).
.SH NOTES
.PP
Events shown by this tool may not correspond to the events seen by a
diff --git a/tools/shared.c b/tools/shared.c
index 7a730278..cc8396a7 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -315,6 +315,14 @@ tools_parse_option(int option,
return 1;
}
break;
+ case OPT_ROTATION_ANGLE:
+ if (!optarg)
+ return 1;
+
+ if (!safe_atou(optarg, &options->angle)) {
+ fprintf(stderr, "Invalid --set-rotation-angle value\n");
+ return 1;
+ }
}
return 0;
}
@@ -520,6 +528,9 @@ tools_device_apply_config(struct libinput_device *device,
libinput_device_config_accel_apply(device, config);
libinput_config_accel_destroy(config);
}
+
+ if (options->angle != 0)
+ libinput_device_config_rotation_set_angle(device, options->angle % 360);
}
static char*
diff --git a/tools/shared.h b/tools/shared.h
index 825a51f5..45230741 100644
--- a/tools/shared.h
+++ b/tools/shared.h
@@ -62,6 +62,7 @@ enum configuration_options {
OPT_CUSTOM_POINTS,
OPT_CUSTOM_STEP,
OPT_CUSTOM_TYPE,
+ OPT_ROTATION_ANGLE,
};
#define CONFIGURATION_OPTIONS \
@@ -93,7 +94,8 @@ enum configuration_options {
{ "apply-to", required_argument, 0, OPT_APPLY_TO },\
{ "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-custom-type", required_argument, 0, OPT_CUSTOM_TYPE },\
+ { "set-rotation-angle", required_argument, 0, OPT_ROTATION_ANGLE }
enum tools_backend {
BACKEND_NONE,
@@ -124,6 +126,7 @@ struct tools_options {
double custom_step;
size_t custom_npoints;
double *custom_points;
+ unsigned int angle;
};
void tools_init_options(struct tools_options *options);
diff --git a/tools/test_tool_option_parsing.py b/tools/test_tool_option_parsing.py
index c63d85e8..303e3840 100755
--- a/tools/test_tool_option_parsing.py
+++ b/tools/test_tool_option_parsing.py
@@ -222,6 +222,7 @@ options = {
# options with a range (and increment)
"ranges": {
"set-speed": (-1.0, +1.0, 0.1),
+ "set-rotation": (0, 360, 10),
},
}