tools: add rotation support to debug-events and debug-gui
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 18 Apr 2023 07:05:41 +0000 (17:05 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 27 Apr 2023 03:15:14 +0000 (13:15 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
tools/libinput-debug-events.man
tools/shared.c
tools/shared.h
tools/test_tool_option_parsing.py

index 849765d1cca48a18299cec1de6cc62c29c56045a..2eeefd4bf6691ba8abbf5b64f5c4633af20432d6 100644 (file)
@@ -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
index 7a7302789599907998fd976aa748dc34dd357ec3..cc8396a706b82a318a17fdf988be5c46b06c3b85 100644 (file)
@@ -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*
index 825a51f596d2126b91e49bd4832a940bbcb2330a..45230741cb458f96b3f70c8bf499dc9e30e8bed6 100644 (file)
@@ -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);
index c63d85e8b2e26f69949fd078f911433fa2230e98..303e38402e05d7b2aac278f375d0b0b5ef25ce6e 100755 (executable)
@@ -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),
     },
 }