libinput: move calibration printing into do_set_calibration()
Move calibration printing here and call do_set_calibration() from evdev_device_set_calibration() so that all matrix setting paths print the same way. Print the matrix values in a matrix style to help readability, and mention the input device. v2: - use 'cal' instead of 'calb' as variable name 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>
This commit is contained in:
+24
-27
@@ -346,10 +346,17 @@ do_set_calibration(struct evdev_device *evdev_device,
|
|||||||
{
|
{
|
||||||
enum libinput_config_status status;
|
enum libinput_config_status status;
|
||||||
|
|
||||||
|
weston_log("input device %s: applying calibration:\n",
|
||||||
|
libinput_device_get_sysname(evdev_device->device));
|
||||||
|
weston_log_continue(STAMP_SPACE " %f %f %f\n",
|
||||||
|
cal->m[0], cal->m[1], cal->m[2]);
|
||||||
|
weston_log_continue(STAMP_SPACE " %f %f %f\n",
|
||||||
|
cal->m[3], cal->m[4], cal->m[5]);
|
||||||
|
|
||||||
status = libinput_device_config_calibration_set_matrix(evdev_device->device,
|
status = libinput_device_config_calibration_set_matrix(evdev_device->device,
|
||||||
cal->m);
|
cal->m);
|
||||||
if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
|
if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
|
||||||
weston_log("Failed to apply calibration.\n");
|
weston_log("Error: Failed to apply calibration.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -559,8 +566,7 @@ evdev_device_set_calibration(struct evdev_device *device)
|
|||||||
const char *sysname = libinput_device_get_sysname(device->device);
|
const char *sysname = libinput_device_get_sysname(device->device);
|
||||||
const char *calibration_values;
|
const char *calibration_values;
|
||||||
uint32_t width, height;
|
uint32_t width, height;
|
||||||
float calibration[6];
|
struct weston_touch_device_matrix calibration;
|
||||||
enum libinput_config_status status;
|
|
||||||
|
|
||||||
if (!libinput_device_config_calibration_has_matrix(device->device))
|
if (!libinput_device_config_calibration_has_matrix(device->device))
|
||||||
return;
|
return;
|
||||||
@@ -570,7 +576,7 @@ evdev_device_set_calibration(struct evdev_device *device)
|
|||||||
* output to load a calibration. */
|
* output to load a calibration. */
|
||||||
if (libinput_device_config_calibration_get_default_matrix(
|
if (libinput_device_config_calibration_get_default_matrix(
|
||||||
device->device,
|
device->device,
|
||||||
calibration) != 0)
|
calibration.m) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* touch_set_calibration() has updated the values, do not load old
|
/* touch_set_calibration() has updated the values, do not load old
|
||||||
@@ -614,35 +620,26 @@ evdev_device_set_calibration(struct evdev_device *device)
|
|||||||
|
|
||||||
if (!calibration_values || sscanf(calibration_values,
|
if (!calibration_values || sscanf(calibration_values,
|
||||||
"%f %f %f %f %f %f",
|
"%f %f %f %f %f %f",
|
||||||
&calibration[0],
|
&calibration.m[0],
|
||||||
&calibration[1],
|
&calibration.m[1],
|
||||||
&calibration[2],
|
&calibration.m[2],
|
||||||
&calibration[3],
|
&calibration.m[3],
|
||||||
&calibration[4],
|
&calibration.m[4],
|
||||||
&calibration[5]) != 6)
|
&calibration.m[5]) != 6)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
weston_log("Applying calibration: %f %f %f %f %f %f "
|
|
||||||
"(normalized %f %f)\n",
|
|
||||||
calibration[0],
|
|
||||||
calibration[1],
|
|
||||||
calibration[2],
|
|
||||||
calibration[3],
|
|
||||||
calibration[4],
|
|
||||||
calibration[5],
|
|
||||||
calibration[2] / width,
|
|
||||||
calibration[5] / height);
|
|
||||||
|
|
||||||
/* normalize to a format libinput can use. There is a chance of
|
/* normalize to a format libinput can use. There is a chance of
|
||||||
this being wrong if the width/height don't match the device
|
this being wrong if the width/height don't match the device
|
||||||
width/height but I'm not sure how to fix that */
|
width/height but I'm not sure how to fix that */
|
||||||
calibration[2] /= width;
|
calibration.m[2] /= width;
|
||||||
calibration[5] /= height;
|
calibration.m[5] /= height;
|
||||||
|
|
||||||
status = libinput_device_config_calibration_set_matrix(device->device,
|
do_set_calibration(device, &calibration);
|
||||||
calibration);
|
|
||||||
if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
|
weston_log_continue(STAMP_SPACE " raw translation %f %f for output %s\n",
|
||||||
weston_log("Failed to apply calibration.\n");
|
calibration.m[2] * width,
|
||||||
|
calibration.m[5] * height,
|
||||||
|
device->output->name);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (udev_device)
|
if (udev_device)
|
||||||
|
|||||||
Reference in New Issue
Block a user