[PATCH libinput v2] tablet: fix get_x_transformed() and get_y_transformed()
Stephen Chandler Paul
thatslyude at gmail.com
Sun Jul 20 19:20:41 PDT 2014
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.
Changes since last patch:
- Basically just scrapped the other one and rewrote it. We don't keep track of
both the raw x and y plus the millimeter x and y anymore.
Signed-off-by: Stephen Chandler Paul <thatslyude at gmail.com>
---
src/evdev-tablet.c | 5 ++---
src/libinput.c | 20 ++++++++++++++++++--
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index d1ad4bb..ca3cc05 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -142,9 +142,8 @@ 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);
- break;
+ tablet->axes[a] = absinfo->value;
+ break;
case LIBINPUT_TABLET_AXIS_DISTANCE:
case LIBINPUT_TABLET_AXIS_PRESSURE:
tablet->axes[a] = normalize_pressure_or_dist(absinfo);
diff --git a/src/libinput.c b/src/libinput.c
index e013f49..9aa7cbc 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
--
1.8.5.5
More information about the wayland-devel
mailing list