diff options
author | Fabien Lahoudere <fabien.lahoudere@collabora.co.uk> | 2017-09-07 15:11:58 +0200 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2017-09-18 12:16:49 +0300 |
commit | e80bdcdad2082b6710f9a47c355f8ace20ed788b (patch) | |
tree | ea8c7871346358c710e12b981189d8f0ffc04250 | |
parent | c05ee89ab0c08eab4c3a839be6181513cc4852a4 (diff) |
calibrator: Make mouse button optional
When calibrating touchscreen with weston-calibrator, you can use the mouse to
click on the cross which is recorded as a touch event. This event is used to
compute the final calibration of the touchscreen which results in invalid
touchscreen calibration and broken touchscreen behaviour.
In order to avoid to use the mouse in weston-calibrator, we disable mouse
operation by default and add a parameter "--enable-mouse" to enable it.
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.co.uk>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
-rw-r--r-- | clients/calibrator.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/clients/calibrator.c b/clients/calibrator.c index 04c1cfcb..778c23cf 100644 --- a/clients/calibrator.c +++ b/clients/calibrator.c @@ -24,12 +24,14 @@ #include "config.h" #include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <cairo.h> #include <math.h> #include <assert.h> +#include <getopt.h> #include <linux/input.h> #include <wayland-client.h> @@ -218,7 +220,7 @@ redraw_handler(struct widget *widget, void *data) } static struct calibrator * -calibrator_create(struct display *display) +calibrator_create(struct display *display, bool enable_button) { struct calibrator *calibrator; @@ -233,7 +235,8 @@ calibrator_create(struct display *display) calibrator->current_test = ARRAY_LENGTH(test_ratios) - 1; - widget_set_button_handler(calibrator->widget, button_handler); + if (enable_button) + widget_set_button_handler(calibrator->widget, button_handler); widget_set_touch_down_handler(calibrator->widget, touch_handler); widget_set_redraw_handler(calibrator->widget, redraw_handler); @@ -250,13 +253,40 @@ calibrator_destroy(struct calibrator *calibrator) free(calibrator); } +static void +help(const char *name) +{ + fprintf(stderr, "Usage: %s [args...]\n", name); + fprintf(stderr, " -m, --enable-mouse Enable mouse for testing the touchscreen\n"); + fprintf(stderr, " -h, --help Display this help message\n"); +} int main(int argc, char *argv[]) { struct display *display; struct calibrator *calibrator; - + int c; + bool enable_mouse = 0; + struct option opts[] = { + { "enable-mouse", no_argument, NULL, 'm' }, + { "help", no_argument, NULL, 'h' }, + { 0, 0, NULL, 0 } + }; + + while ((c = getopt_long(argc, argv, "mh", opts, NULL)) != -1) { + switch (c) { + case 'm': + enable_mouse = 1; + break; + case 'h': + help(argv[0]); + exit(EXIT_FAILURE); + default: + break; + } + } + display = display_create(&argc, argv); if (display == NULL) { @@ -264,7 +294,7 @@ main(int argc, char *argv[]) return -1; } - calibrator = calibrator_create(display); + calibrator = calibrator_create(display, enable_mouse); if (!calibrator) return -1; |