mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 10:38:23 +02:00
evdev: always store user calibration matrix
In evdev_device_calibrate, the user matrix was not being stored when it was the identity matrix. This resulted in libinput_device_config_calibration_get_matrix not providing the correct matrix. Instead of giving the identity matrix, the last non-identity matrix set was given. This just moves the storage of the user matrix in evdev_device_calibrate to be above the identity matrix early return so that it always get stored. Signed-off-by: Brian Ashworth <bosrsf04@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
f5fc850a08
commit
801485afda
2 changed files with 32 additions and 3 deletions
|
|
@ -2210,6 +2210,9 @@ evdev_device_calibrate(struct evdev_device *device,
|
||||||
matrix_from_farray6(&transform, calibration);
|
matrix_from_farray6(&transform, calibration);
|
||||||
device->abs.apply_calibration = !matrix_is_identity(&transform);
|
device->abs.apply_calibration = !matrix_is_identity(&transform);
|
||||||
|
|
||||||
|
/* back up the user matrix so we can return it on request */
|
||||||
|
matrix_from_farray6(&device->abs.usermatrix, calibration);
|
||||||
|
|
||||||
if (!device->abs.apply_calibration) {
|
if (!device->abs.apply_calibration) {
|
||||||
matrix_init_identity(&device->abs.calibration);
|
matrix_init_identity(&device->abs.calibration);
|
||||||
return;
|
return;
|
||||||
|
|
@ -2238,9 +2241,6 @@ evdev_device_calibrate(struct evdev_device *device,
|
||||||
* order.
|
* order.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* back up the user matrix so we can return it on request */
|
|
||||||
matrix_from_farray6(&device->abs.usermatrix, calibration);
|
|
||||||
|
|
||||||
/* Un-Normalize */
|
/* Un-Normalize */
|
||||||
matrix_init_translate(&translate,
|
matrix_init_translate(&translate,
|
||||||
device->abs.absinfo_x->minimum,
|
device->abs.absinfo_x->minimum,
|
||||||
|
|
|
||||||
|
|
@ -489,6 +489,34 @@ START_TEST(touch_calibrated_screen_path)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(touch_calibration_config)
|
||||||
|
{
|
||||||
|
struct litest_device *dev = litest_current_device();
|
||||||
|
float identity[6] = {1, 0, 0, 0, 1, 0};
|
||||||
|
float nonidentity[6] = {1, 2, 3, 4, 5, 6};
|
||||||
|
float matrix[6];
|
||||||
|
enum libinput_config_status status;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = libinput_device_config_calibration_has_matrix(dev->libinput_device);
|
||||||
|
ck_assert_int_eq(rc, 1);
|
||||||
|
|
||||||
|
/* Twice so we have every to-fro combination */
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
status = libinput_device_config_calibration_set_matrix(dev->libinput_device, identity);
|
||||||
|
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||||||
|
libinput_device_config_calibration_get_matrix(dev->libinput_device, matrix);
|
||||||
|
ck_assert_int_eq(memcmp(matrix, identity, sizeof(matrix)), 0);
|
||||||
|
|
||||||
|
status = libinput_device_config_calibration_set_matrix(dev->libinput_device, nonidentity);
|
||||||
|
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||||||
|
libinput_device_config_calibration_get_matrix(dev->libinput_device, matrix);
|
||||||
|
ck_assert_int_eq(memcmp(matrix, nonidentity, sizeof(matrix)), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
static int open_restricted(const char *path, int flags, void *data)
|
static int open_restricted(const char *path, int flags, void *data)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
@ -1306,6 +1334,7 @@ TEST_COLLECTION(touch)
|
||||||
litest_add("touch:calibration", touch_calibration_translation, LITEST_SINGLE_TOUCH, LITEST_TOUCHPAD);
|
litest_add("touch:calibration", touch_calibration_translation, LITEST_SINGLE_TOUCH, LITEST_TOUCHPAD);
|
||||||
litest_add_for_device("touch:calibration", touch_calibrated_screen_path, LITEST_CALIBRATED_TOUCHSCREEN);
|
litest_add_for_device("touch:calibration", touch_calibrated_screen_path, LITEST_CALIBRATED_TOUCHSCREEN);
|
||||||
litest_add_for_device("touch:calibration", touch_calibrated_screen_udev, LITEST_CALIBRATED_TOUCHSCREEN);
|
litest_add_for_device("touch:calibration", touch_calibrated_screen_udev, LITEST_CALIBRATED_TOUCHSCREEN);
|
||||||
|
litest_add("touch:calibration", touch_calibration_config, LITEST_TOUCH, LITEST_ANY);
|
||||||
|
|
||||||
litest_add("touch:left-handed", touch_no_left_handed, LITEST_TOUCH, LITEST_ANY);
|
litest_add("touch:left-handed", touch_no_left_handed, LITEST_TOUCH, LITEST_ANY);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue