From 6fd00f74d46ac838a48510470a1cf42f42a658e1 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 18 Jun 2014 11:23:58 +1000 Subject: [PATCH] tablet: normalize the distance to 0..1 The actual data provided by current tablets is not anywhere close to accurate. While it'd be nice to have this in mm, this is unlikely to happen anytime soon. Use the same 0..1 normalized range as pressure has. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-tablet.c | 6 ++---- src/libinput.h | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 09bb454f..e87d2522 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -104,7 +104,7 @@ tablet_update_tool(struct tablet_dispatch *tablet, } static inline double -normalize_pressure(const struct input_absinfo * absinfo) { +normalize_pressure_or_dist(const struct input_absinfo * absinfo) { double range = absinfo->maximum - absinfo->minimum + 1; double value = (absinfo->value + absinfo->minimum) / range; @@ -145,10 +145,8 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, absinfo->value); break; case LIBINPUT_TABLET_AXIS_DISTANCE: - tablet->axes[a] = absinfo->value; - break; case LIBINPUT_TABLET_AXIS_PRESSURE: - tablet->axes[a] = normalize_pressure(absinfo); + tablet->axes[a] = normalize_pressure_or_dist(absinfo); break; case LIBINPUT_TABLET_AXIS_TILT_VERTICAL: case LIBINPUT_TABLET_AXIS_TILT_HORIZONTAL: diff --git a/src/libinput.h b/src/libinput.h index ada68296..0a914569 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -866,8 +866,8 @@ libinput_event_tablet_axis_has_changed(struct libinput_event_tablet *event, * tablet. Use libinput_event_tablet_get_x_transformed() and * libinput_event_tablet_get_y_transformed() for transforming each * respective axis value. - * - @ref LIBINPUT_TABLET_AXIS_DISTANCE - Approximately how many millimeters - * away from the tablet's sensor the tool is + * - @ref LIBINPUT_TABLET_AXIS_DISTANCE - The distance from the tablet's + * sensor, normalized from 0 to 1 * - @ref LIBINPUT_TABLET_AXIS_PRESSURE - The current pressure being applied on * the tool in use, normalized from 0 to 1 * - @ref LIBINPUT_TABLET_AXIS_TILT_VERTICAL and @ref