summaryrefslogtreecommitdiff
path: root/compositor
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2017-12-15 02:02:56 -0500
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2018-05-30 14:46:24 +0300
commit5a1b0cf0e76d01478dbfb76009d8e986fbe83e4b (patch)
tree566beae870593fb6d6e0e6d071f5a9c31b91d4ba /compositor
parent83630983ad5335d8a28a9a86ee9b0e9a682d6643 (diff)
downloadweston-5a1b0cf0e76d01478dbfb76009d8e986fbe83e4b.tar.gz
weston-5a1b0cf0e76d01478dbfb76009d8e986fbe83e4b.tar.bz2
weston-5a1b0cf0e76d01478dbfb76009d8e986fbe83e4b.zip
weston: add touchscreen_calibrator option
Add an option to enable the touchscreen calibrator interface. This is a global on/off toggle, in lack of more fine-grained access restrictions. As Weston should not hardcode system specifics, the actual permanent saving of a new calibration is left for a user supplied script or a program. Usually this script would write an appropriate udev rule to set LIBINPUT_CALIBRATION_MATRIX for the touch device. Co-developed by Louis-Francis and Pekka. v2: - use syspath instead of devpath Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com> Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'compositor')
-rw-r--r--compositor/main.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/compositor/main.c b/compositor/main.c
index 1092204f..e84857f7 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -765,6 +765,64 @@ load_modules(struct weston_compositor *ec, const char *modules,
}
static int
+save_touch_device_calibration(struct weston_compositor *compositor,
+ struct weston_touch_device *device,
+ const struct weston_touch_device_matrix *calibration)
+{
+ struct weston_config_section *s;
+ struct weston_config *config = wet_get_config(compositor);
+ char *helper = NULL;
+ char *helper_cmd = NULL;
+ int ret = -1;
+ int status;
+ const float *m = calibration->m;
+
+ s = weston_config_get_section(config,
+ "libinput", NULL, NULL);
+
+ weston_config_section_get_string(s, "calibration_helper",
+ &helper, NULL);
+
+ if (!helper || strlen(helper) == 0) {
+ ret = 0;
+ goto out;
+ }
+
+ if (asprintf(&helper_cmd, "\"%s\" '%s' %f %f %f %f %f %f",
+ helper, device->syspath,
+ m[0], m[1], m[2],
+ m[3], m[4], m[5]) < 0)
+ goto out;
+
+ status = system(helper_cmd);
+ free(helper_cmd);
+
+ if (status < 0) {
+ weston_log("Error: failed to run calibration helper '%s'.\n",
+ helper);
+ goto out;
+ }
+
+ if (!WIFEXITED(status)) {
+ weston_log("Error: calibration helper '%s' possibly killed.\n",
+ helper);
+ goto out;
+ }
+
+ if (WEXITSTATUS(status) == 0) {
+ ret = 0;
+ } else {
+ weston_log("Calibration helper '%s' exited with status %d.\n",
+ helper, WEXITSTATUS(status));
+ }
+
+out:
+ free(helper);
+
+ return ret;
+}
+
+static int
weston_compositor_init_config(struct weston_compositor *ec,
struct weston_config *config)
{
@@ -772,7 +830,9 @@ weston_compositor_init_config(struct weston_compositor *ec,
struct weston_config_section *s;
int repaint_msec;
int vt_switching;
+ int cal;
+ /* weston.ini [keyboard] */
s = weston_config_get_section(config, "keyboard", NULL, NULL);
weston_config_section_get_string(s, "keymap_rules",
(char **) &xkb_names.rules, NULL);
@@ -797,6 +857,7 @@ weston_compositor_init_config(struct weston_compositor *ec,
&vt_switching, true);
ec->vt_switching = vt_switching;
+ /* weston.ini [core] */
s = weston_config_get_section(config, "core", NULL, NULL);
weston_config_section_get_int(s, "repaint-window", &repaint_msec,
ec->repaint_msec);
@@ -809,6 +870,13 @@ weston_compositor_init_config(struct weston_compositor *ec,
weston_log("Output repaint window is %d ms maximum.\n",
ec->repaint_msec);
+ /* weston.ini [libinput] */
+ s = weston_config_get_section(config, "libinput", NULL, NULL);
+ weston_config_section_get_bool(s, "touchscreen_calibrator", &cal, 0);
+ if (cal)
+ weston_compositor_enable_touch_calibrator(ec,
+ save_touch_device_calibration);
+
return 0;
}