libinput: add support for touchscreen set matrix

My android pad emit a strange touch input from libinput, need to rotate it in 270 degree clockwise to fix.
This commit is contained in:
SnowNF 2024-03-20 03:32:41 +08:00 committed by Johan Malm
parent 8b8652e2b3
commit bd4d92bad8
5 changed files with 28 additions and 7 deletions

View file

@ -504,6 +504,9 @@
- 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">
@ -519,6 +522,7 @@
<disableWhileTyping></disableWhileTyping>
<clickMethod></clickMethod>
<sendEventsMode></sendEventsMode>
<calibrationMatrix></calibrationMatrix>
</device>
</libinput>

View file

@ -30,6 +30,8 @@ struct libinput_category {
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);

View 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

View 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;
}
}
}

View 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 *