From 78b474ee37ed01910244838a809d2c3e1fec0c66 Mon Sep 17 00:00:00 2001 From: Stephen Chandler Paul Date: Sun, 20 Jul 2014 22:20:41 -0400 Subject: [PATCH] tablet: fix get_x_transformed() and get_y_transformed() Because the values for each axis were stored in struct tablet_dispatch in millimeters, coordinates were not being translated properly to screen coordinates. This stores the values internally as raw coordinates, and only translates them to millimeters if the client asks for it. Signed-off-by: Stephen Chandler Paul Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- src/evdev-tablet.c | 3 +-- src/libinput.c | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index d1ad4bb0..31dd8d7c 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -142,8 +142,7 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, switch (a) { case LIBINPUT_TABLET_AXIS_X: case LIBINPUT_TABLET_AXIS_Y: - tablet->axes[a] = evdev_convert_to_mm(absinfo, - absinfo->value); + tablet->axes[a] = absinfo->value; break; case LIBINPUT_TABLET_AXIS_DISTANCE: case LIBINPUT_TABLET_AXIS_PRESSURE: diff --git a/src/libinput.c b/src/libinput.c index e013f490..9aa7cbcf 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -504,11 +504,27 @@ LIBINPUT_EXPORT double libinput_event_tablet_get_axis_value(struct libinput_event_tablet *event, enum libinput_tablet_axis axis) { + struct evdev_device *device = + (struct evdev_device *) event->base.device; + if (event->base.type != LIBINPUT_EVENT_TABLET_AXIS) return 0; - return (axis >= 0 && axis < LIBINPUT_TABLET_AXIS_CNT) ? - event->axes[axis] : 0; + switch(axis) { + case LIBINPUT_TABLET_AXIS_X: + return evdev_convert_to_mm(device->abs.absinfo_x, + event->axes[axis]); + case LIBINPUT_TABLET_AXIS_Y: + return evdev_convert_to_mm(device->abs.absinfo_y, + event->axes[axis]); + case LIBINPUT_TABLET_AXIS_DISTANCE: + case LIBINPUT_TABLET_AXIS_PRESSURE: + case LIBINPUT_TABLET_AXIS_TILT_X: + case LIBINPUT_TABLET_AXIS_TILT_Y: + return event->axes[axis]; + default: + return 0; + } } LIBINPUT_EXPORT double