mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-03 20:08:05 +02:00
evdev: factor out resolution changing code
No functional changes. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
20d48e4181
commit
37ca93c535
1 changed files with 32 additions and 25 deletions
57
src/evdev.c
57
src/evdev.c
|
|
@ -1037,13 +1037,31 @@ evdev_tag_device(struct evdev_device *device)
|
|||
udev_unref(udev);
|
||||
}
|
||||
|
||||
static inline int
|
||||
evdev_fix_abs_resolution(struct libevdev *evdev,
|
||||
unsigned int code,
|
||||
const struct input_absinfo *absinfo)
|
||||
{
|
||||
struct input_absinfo fixed;
|
||||
|
||||
if (absinfo->resolution == 0) {
|
||||
fixed = *absinfo;
|
||||
fixed.resolution = 1;
|
||||
/* libevdev_set_abs_info() changes the absinfo we already
|
||||
have a pointer to, no need to fetch it again */
|
||||
libevdev_set_abs_info(evdev, code, &fixed);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
evdev_configure_device(struct evdev_device *device)
|
||||
{
|
||||
struct libinput *libinput = device->base.seat->libinput;
|
||||
struct libevdev *evdev = device->evdev;
|
||||
const struct input_absinfo *absinfo;
|
||||
struct input_absinfo fixed;
|
||||
int has_abs, has_rel, has_mt;
|
||||
int has_button, has_keyboard, has_touch;
|
||||
struct mt_slot *slots;
|
||||
|
|
@ -1062,22 +1080,18 @@ evdev_configure_device(struct evdev_device *device)
|
|||
if (libevdev_has_event_type(evdev, EV_ABS)) {
|
||||
|
||||
if ((absinfo = libevdev_get_abs_info(evdev, ABS_X))) {
|
||||
if (absinfo->resolution == 0) {
|
||||
fixed = *absinfo;
|
||||
fixed.resolution = 1;
|
||||
libevdev_set_abs_info(evdev, ABS_X, &fixed);
|
||||
if (evdev_fix_abs_resolution(evdev,
|
||||
ABS_X,
|
||||
absinfo))
|
||||
device->abs.fake_resolution = 1;
|
||||
}
|
||||
device->abs.absinfo_x = absinfo;
|
||||
has_abs = 1;
|
||||
}
|
||||
if ((absinfo = libevdev_get_abs_info(evdev, ABS_Y))) {
|
||||
if (absinfo->resolution == 0) {
|
||||
fixed = *absinfo;
|
||||
fixed.resolution = 1;
|
||||
libevdev_set_abs_info(evdev, ABS_Y, &fixed);
|
||||
if (evdev_fix_abs_resolution(evdev,
|
||||
ABS_Y,
|
||||
absinfo))
|
||||
device->abs.fake_resolution = 1;
|
||||
}
|
||||
device->abs.absinfo_y = absinfo;
|
||||
has_abs = 1;
|
||||
}
|
||||
|
|
@ -1087,24 +1101,17 @@ evdev_configure_device(struct evdev_device *device)
|
|||
if (libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) &&
|
||||
libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y)) {
|
||||
absinfo = libevdev_get_abs_info(evdev, ABS_MT_POSITION_X);
|
||||
if (absinfo->resolution == 0) {
|
||||
fixed = *absinfo;
|
||||
fixed.resolution = 1;
|
||||
libevdev_set_abs_info(evdev,
|
||||
ABS_MT_POSITION_X,
|
||||
&fixed);
|
||||
if (evdev_fix_abs_resolution(evdev,
|
||||
ABS_MT_POSITION_X,
|
||||
absinfo))
|
||||
device->abs.fake_resolution = 1;
|
||||
}
|
||||
device->abs.absinfo_x = absinfo;
|
||||
|
||||
absinfo = libevdev_get_abs_info(evdev, ABS_MT_POSITION_Y);
|
||||
if (absinfo->resolution == 0) {
|
||||
fixed = *absinfo;
|
||||
fixed.resolution = 1;
|
||||
libevdev_set_abs_info(evdev,
|
||||
ABS_MT_POSITION_Y,
|
||||
&fixed);
|
||||
if (evdev_fix_abs_resolution(evdev,
|
||||
ABS_MT_POSITION_Y,
|
||||
absinfo))
|
||||
device->abs.fake_resolution = 1;
|
||||
}
|
||||
device->abs.absinfo_y = absinfo;
|
||||
device->is_mt = 1;
|
||||
has_touch = 1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue