From 01ec18e80228739bbc099ccb35356d198729ab42 Mon Sep 17 00:00:00 2001 From: Sergei Dolgov Date: Mon, 17 Jun 2019 11:38:41 +0200 Subject: Add calibration_matrix config option Can be used to change the orientation of a touchscreen. Example usage with swaymsg: # identity swaymsg input type:touch calibration_matrix '"1 0 0 0 1 0"' # 90 degree clockwise swaymsg input type:touch calibration_matrix '"0 -1 1 1 0 0"' # 180 degree clockwise swaymsg input type:touch calibration_matrix '"-1 0 1 0 -1 1"' # 270 degree clockwise swaymsg input type:touch calibration_matrix '"0 1 0 -1 0 1"' Documentation: https://wayland.freedesktop.org/libinput/doc/latest/absolute-axes.html#calibration-of-absolute-devices --- sway/input/input-manager.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'sway/input/input-manager.c') diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index a2a1e274..195acc6f 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -281,6 +281,13 @@ static void input_manager_libinput_config_touch( log_libinput_config_status(libinput_device_config_send_events_set_mode( libinput_device, ic->send_events)); } + float *m = ic->calibration_matrix.matrix; + if (ic->calibration_matrix.configured) { + sway_log(SWAY_DEBUG, "libinput_config_touch(%s) calibration_set_matrix(%f %f %f %f %f %f)", + ic->identifier, m[0], m[1], m[2], m[3], m[4], m[5]); + log_libinput_config_status(libinput_device_config_calibration_set_matrix( + libinput_device, ic->calibration_matrix.matrix)); + } } static void input_manager_libinput_reset_touch( @@ -300,6 +307,12 @@ static void input_manager_libinput_reset_touch( input_device->identifier, send_events); log_libinput_config_status(libinput_device_config_send_events_set_mode( libinput_device, send_events)); + float m[6]; + libinput_device_config_calibration_get_default_matrix(libinput_device, m); + sway_log(SWAY_DEBUG, "libinput_reset_touch(%s) calibration_set_matrix(%f %f %f %f %f %f)", + input_device->identifier, m[0], m[1], m[2], m[3], m[4], m[5]); + log_libinput_config_status(libinput_device_config_calibration_set_matrix( + libinput_device, m)); } static void input_manager_libinput_config_pointer( -- cgit v1.2.3-54-g00ecf