summaryrefslogtreecommitdiff
path: root/src/evdev-tablet.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-04-26 10:55:37 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-04-28 09:23:27 +1000
commit4552d686f8559cd3f688d0af0bd98eb4e5bc23a8 (patch)
tree061a13e1f9b65f05690c0153cb4e23645e1c6704 /src/evdev-tablet.c
parent248912f1ef2dff4cf37a00d6580468b605598b54 (diff)
tablet: fix distance normalization range after 25a9f39
25a9f39 changed the range to [-1, 1] but that's incorrect for the distance values. Split the normalization up into two functions and make sure our distance range is correct. https://bugs.freedesktop.org/show_bug.cgi?id=95074 And while we're at it, sneak in a test for pressure ranges too. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com>
Diffstat (limited to 'src/evdev-tablet.c')
-rw-r--r--src/evdev-tablet.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 5262230..4e8b920 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -231,7 +231,7 @@ tablet_update_tool(struct tablet_dispatch *tablet,
}
static inline double
-normalize_dist_slider(const struct input_absinfo *absinfo)
+normalize_slider(const struct input_absinfo *absinfo)
{
double range = absinfo->maximum - absinfo->minimum;
double value = (absinfo->value - absinfo->minimum) / range;
@@ -240,6 +240,15 @@ normalize_dist_slider(const struct input_absinfo *absinfo)
}
static inline double
+normalize_distance(const struct input_absinfo *absinfo)
+{
+ double range = absinfo->maximum - absinfo->minimum;
+ double value = (absinfo->value - absinfo->minimum) / range;
+
+ return value;
+}
+
+static inline double
normalize_pressure(const struct input_absinfo *absinfo,
struct libinput_tablet_tool *tool)
{
@@ -420,7 +429,7 @@ tablet_handle_distance(struct tablet_dispatch *tablet,
if (bit_is_set(tablet->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE)) {
absinfo = libevdev_get_abs_info(device->evdev, ABS_DISTANCE);
- tablet->axes.distance = normalize_dist_slider(absinfo);
+ tablet->axes.distance = normalize_distance(absinfo);
}
return tablet->axes.distance;
@@ -435,7 +444,7 @@ tablet_handle_slider(struct tablet_dispatch *tablet,
if (bit_is_set(tablet->changed_axes,
LIBINPUT_TABLET_TOOL_AXIS_SLIDER)) {
absinfo = libevdev_get_abs_info(device->evdev, ABS_WHEEL);
- tablet->axes.slider = normalize_dist_slider(absinfo);
+ tablet->axes.slider = normalize_slider(absinfo);
}
return tablet->axes.slider;