mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 05:58:01 +02:00
evdev: move axis dimension handling into a single helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
2469adc852
commit
ad031733f2
1 changed files with 22 additions and 20 deletions
42
src/evdev.c
42
src/evdev.c
|
|
@ -2116,14 +2116,30 @@ evdev_reject_device(struct evdev_device *device)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
evdev_configure_mt_device(struct evdev_device *device)
|
evdev_extract_abs_axes(struct evdev_device *device)
|
||||||
{
|
{
|
||||||
struct libevdev *evdev = device->evdev;
|
struct libevdev *evdev = device->evdev;
|
||||||
|
|
||||||
if (!libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ||
|
if (!libevdev_has_event_code(evdev, EV_ABS, ABS_X) ||
|
||||||
|
!libevdev_has_event_code(evdev, EV_ABS, ABS_Y))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (evdev_fix_abs_resolution(device, ABS_X, ABS_Y))
|
||||||
|
device->abs.fake_resolution = 1;
|
||||||
|
device->abs.absinfo_x = libevdev_get_abs_info(evdev, ABS_X);
|
||||||
|
device->abs.absinfo_y = libevdev_get_abs_info(evdev, ABS_Y);
|
||||||
|
device->abs.point.x = device->abs.absinfo_x->value;
|
||||||
|
device->abs.point.y = device->abs.absinfo_y->value;
|
||||||
|
device->abs.dimensions.x = abs(device->abs.absinfo_x->maximum -
|
||||||
|
device->abs.absinfo_x->minimum);
|
||||||
|
device->abs.dimensions.y = abs(device->abs.absinfo_y->maximum -
|
||||||
|
device->abs.absinfo_y->minimum);
|
||||||
|
|
||||||
|
if (evdev_is_fake_mt_device(device) ||
|
||||||
|
!libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ||
|
||||||
!libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y))
|
!libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y))
|
||||||
return true;
|
return;
|
||||||
|
|
||||||
if (evdev_fix_abs_resolution(device,
|
if (evdev_fix_abs_resolution(device,
|
||||||
ABS_MT_POSITION_X,
|
ABS_MT_POSITION_X,
|
||||||
|
|
@ -2137,8 +2153,6 @@ evdev_configure_mt_device(struct evdev_device *device)
|
||||||
device->abs.dimensions.y = abs(device->abs.absinfo_y->maximum -
|
device->abs.dimensions.y = abs(device->abs.absinfo_y->maximum -
|
||||||
device->abs.absinfo_y->minimum);
|
device->abs.absinfo_y->minimum);
|
||||||
device->is_mt = 1;
|
device->is_mt = 1;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct evdev_dispatch *
|
static struct evdev_dispatch *
|
||||||
|
|
@ -2201,22 +2215,10 @@ evdev_configure_device(struct evdev_device *device)
|
||||||
evdev_fix_android_mt(device);
|
evdev_fix_android_mt(device);
|
||||||
|
|
||||||
if (libevdev_has_event_code(evdev, EV_ABS, ABS_X)) {
|
if (libevdev_has_event_code(evdev, EV_ABS, ABS_X)) {
|
||||||
if (evdev_fix_abs_resolution(device, ABS_X, ABS_Y))
|
evdev_extract_abs_axes(device);
|
||||||
device->abs.fake_resolution = 1;
|
|
||||||
device->abs.absinfo_x = libevdev_get_abs_info(evdev, ABS_X);
|
|
||||||
device->abs.absinfo_y = libevdev_get_abs_info(evdev, ABS_Y);
|
|
||||||
device->abs.point.x = device->abs.absinfo_x->value;
|
|
||||||
device->abs.point.y = device->abs.absinfo_y->value;
|
|
||||||
device->abs.dimensions.x = abs(device->abs.absinfo_x->maximum -
|
|
||||||
device->abs.absinfo_x->minimum);
|
|
||||||
device->abs.dimensions.y = abs(device->abs.absinfo_y->maximum -
|
|
||||||
device->abs.absinfo_y->minimum);
|
|
||||||
|
|
||||||
if (evdev_is_fake_mt_device(device)) {
|
if (evdev_is_fake_mt_device(device))
|
||||||
udev_tags &= ~EVDEV_UDEV_TAG_TOUCHSCREEN;
|
udev_tags &= ~EVDEV_UDEV_TAG_TOUCHSCREEN;
|
||||||
} else if (!evdev_configure_mt_device(device)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* libwacom assigns touchpad (or touchscreen) _and_ tablet to the
|
/* libwacom assigns touchpad (or touchscreen) _and_ tablet to the
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue