mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-27 22:00:07 +01:00
evdev: move reading the calibration prop into a helper function
No functional changes.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
(cherry picked from commit 50e4a1fada)
This commit is contained in:
parent
690dd44121
commit
84c12a8a63
3 changed files with 43 additions and 25 deletions
39
src/evdev.c
39
src/evdev.c
|
|
@ -2975,6 +2975,45 @@ evdev_device_calibrate(struct evdev_device *device,
|
|||
matrix_mult(&device->abs.calibration, &transform, &scale);
|
||||
}
|
||||
|
||||
void
|
||||
evdev_read_calibration_prop(struct evdev_device *device)
|
||||
{
|
||||
const char *calibration_values;
|
||||
float calibration[6];
|
||||
int nread;
|
||||
|
||||
calibration_values =
|
||||
udev_device_get_property_value(device->udev_device,
|
||||
"LIBINPUT_CALIBRATION_MATRIX");
|
||||
|
||||
if (calibration_values == NULL)
|
||||
return;
|
||||
|
||||
if (!device->abs.absinfo_x || !device->abs.absinfo_y)
|
||||
return;
|
||||
|
||||
nread = sscanf(calibration_values,
|
||||
"%f %f %f %f %f %f",
|
||||
&calibration[0],
|
||||
&calibration[1],
|
||||
&calibration[2],
|
||||
&calibration[3],
|
||||
&calibration[4],
|
||||
&calibration[5]);
|
||||
if (nread != 6)
|
||||
return;
|
||||
|
||||
evdev_device_set_default_calibration(device, calibration);
|
||||
log_info(evdev_libinput_context(device),
|
||||
"Applying calibration: %f %f %f %f %f %f\n",
|
||||
calibration[0],
|
||||
calibration[1],
|
||||
calibration[2],
|
||||
calibration[3],
|
||||
calibration[4],
|
||||
calibration[5]);
|
||||
}
|
||||
|
||||
bool
|
||||
evdev_device_has_capability(struct evdev_device *device,
|
||||
enum libinput_device_capability capability)
|
||||
|
|
|
|||
|
|
@ -337,6 +337,9 @@ void
|
|||
evdev_init_calibration(struct evdev_device *device,
|
||||
struct libinput_device_config_calibration *calibration);
|
||||
|
||||
void
|
||||
evdev_read_calibration_prop(struct evdev_device *device);
|
||||
|
||||
void
|
||||
evdev_device_init_pointer_acceleration(struct evdev_device *device,
|
||||
struct motion_filter *filter);
|
||||
|
|
|
|||
|
|
@ -51,8 +51,6 @@ device_added(struct udev_device *udev_device,
|
|||
struct evdev_device *device;
|
||||
const char *devnode;
|
||||
const char *device_seat, *output_name;
|
||||
const char *calibration_values;
|
||||
float calibration[6];
|
||||
struct udev_seat *seat;
|
||||
|
||||
device_seat = udev_device_get_property_value(udev_device, "ID_SEAT");
|
||||
|
|
@ -94,29 +92,7 @@ device_added(struct udev_device *udev_device,
|
|||
return 0;
|
||||
}
|
||||
|
||||
calibration_values =
|
||||
udev_device_get_property_value(udev_device,
|
||||
"LIBINPUT_CALIBRATION_MATRIX");
|
||||
|
||||
if (device->abs.absinfo_x && device->abs.absinfo_y &&
|
||||
calibration_values && sscanf(calibration_values,
|
||||
"%f %f %f %f %f %f",
|
||||
&calibration[0],
|
||||
&calibration[1],
|
||||
&calibration[2],
|
||||
&calibration[3],
|
||||
&calibration[4],
|
||||
&calibration[5]) == 6) {
|
||||
evdev_device_set_default_calibration(device, calibration);
|
||||
log_info(&input->base,
|
||||
"Applying calibration: %f %f %f %f %f %f\n",
|
||||
calibration[0],
|
||||
calibration[1],
|
||||
calibration[2],
|
||||
calibration[3],
|
||||
calibration[4],
|
||||
calibration[5]);
|
||||
}
|
||||
evdev_read_calibration_prop(device);
|
||||
|
||||
output_name = udev_device_get_property_value(udev_device, "WL_OUTPUT");
|
||||
if (output_name)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue