]> git.mdlowis.com Git - proto/labwc.git/commitdiff
libinput: add support for touchscreen set matrix
authorSnowNF <SnowNF@outlook.com>
Tue, 19 Mar 2024 19:32:41 +0000 (03:32 +0800)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 20 Mar 2024 22:52:19 +0000 (22:52 +0000)
My android pad emit a strange touch input from libinput, need to rotate it in 270 degree clockwise to fix.

docs/rc.xml.all
include/config/libinput.h
src/config/libinput.c
src/config/rcxml.c
src/seat.c

index 65a6ab542f2722a90ca62437ca836cb49fc86774..546ee010c304443f9d6c6ef565e14d342f59bd4b 100644 (file)
       - tapButtonMap [lrm|lmr]
       - clickMethod [none|buttonAreas|clickfinger]
       - sendEventsMode [yes|no|disabledOnExternalMouse]
+      - calibrationMatrix [six float values split by space],
+      visit https://wayland.freedesktop.org/libinput/doc/latest/absolute-axes.html#calibration-of-absolute-devices
+      for more information
   -->
   <libinput>
     <device category="default">
       <disableWhileTyping></disableWhileTyping>
       <clickMethod></clickMethod>
       <sendEventsMode></sendEventsMode>
+      <calibrationMatrix></calibrationMatrix>
     </device>
   </libinput>
 
index 912009ea3d1eb15cdaa993cd92f8cc5dac1300b7..59fbf76aec54dddbddc172d23d375ad554cf0673 100644 (file)
@@ -23,13 +23,15 @@ struct libinput_category {
        int left_handed;
        enum libinput_config_tap_state tap;
        enum libinput_config_tap_button_map tap_button_map;
-       int tap_and_drag;     /* -1 or libinput_config_drag_state */
-       int drag_lock;        /* -1 or libinput_config_drag_lock_state */
-       int accel_profile;    /* -1 or libinput_config_accel_profile */
-       int middle_emu;       /* -1 or libinput_config_middle_emulation_state */
-       int dwt;              /* -1 or libinput_config_dwt_state */
-       int click_method;     /* -1 or libinput_config_click_method */
-       int send_events_mode; /* -1 or libinput_config_send_events_mode */
+       int tap_and_drag;               /* -1 or libinput_config_drag_state */
+       int drag_lock;                  /* -1 or libinput_config_drag_lock_state */
+       int accel_profile;              /* -1 or libinput_config_accel_profile */
+       int middle_emu;                 /* -1 or libinput_config_middle_emulation_state */
+       int dwt;                        /* -1 or libinput_config_dwt_state */
+       int click_method;               /* -1 or libinput_config_click_method */
+       int send_events_mode;           /* -1 or libinput_config_send_events_mode */
+       bool no_calibration_matrix;     /* false if have calibration matrix */
+       float calibration_matrix[6];    /* calibration matrix */
 };
 
 enum lab_libinput_device_type get_device_type(const char *s);
index 93ab9af262361fcab1b447612ab38f22418f3763..65ee42c8bd4f416d872014cf3fe4b2589658786a 100644 (file)
@@ -25,6 +25,7 @@ libinput_category_init(struct libinput_category *l)
        l->dwt = -1;
        l->click_method = -1;
        l->send_events_mode = -1;
+       l->no_calibration_matrix = true;
 }
 
 enum lab_libinput_device_type
index f749821b3aa1c9b670013049cf9435a77f3b1288..83adc4f0400f8239bb9e8fb7f8404ef6f2cbee9b 100644 (file)
@@ -611,6 +611,12 @@ fill_libinput_category(char *nodename, char *content)
        } else if (!strcasecmp(nodename, "sendEventsMode")) {
                current_libinput_category->send_events_mode =
                        get_send_events_mode(content);
+       } else if (!strcasecmp(nodename, "calibrationMatrix")) {
+               float *m = current_libinput_category->calibration_matrix;
+               int r = sscanf(content, "%f%f%f%f%f%f", &m[0], &m[1], &m[2], &m[3], &m[4], &m[5]);
+               if (r == 6) {
+                       current_libinput_category->no_calibration_matrix = false;
+               }
        }
 }
 
index 8da507e7e2d11fafd799377283efe7217c1d9891..8975088600f6cb8bb57ea532495459251741c338 100644 (file)
@@ -237,6 +237,14 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
                wlr_log(WLR_INFO, "send events mode configured");
                libinput_device_config_send_events_set_mode(libinput_dev, dc->send_events_mode);
        }
+
+       if (libinput_device_config_calibration_has_matrix(libinput_dev) == 0
+                       || dc->no_calibration_matrix) {
+               wlr_log(WLR_INFO, "calibration matrix not configured");
+       } else {
+               wlr_log(WLR_INFO, "calibration matrix configured");
+               libinput_device_config_calibration_set_matrix(libinput_dev, dc->calibration_matrix);
+       }
 }
 
 static struct wlr_output *